Added College Plan button to ScenarioEditModal

This commit is contained in:
Josh 2025-07-07 17:57:26 +00:00
parent e3b779ea91
commit 8f03aff081

View File

@ -3,6 +3,7 @@ import authFetch from '../utils/authFetch.js';
import { simulateFinancialProjection } from '../utils/FinancialProjectionService.js'; import { simulateFinancialProjection } from '../utils/FinancialProjectionService.js';
import { Button } from './ui/button.js'; import { Button } from './ui/button.js';
import parseFloatOrZero from '../utils/ParseFloatorZero.js'; import parseFloatOrZero from '../utils/ParseFloatorZero.js';
import InfoTooltip from "./ui/infoTooltip.js";
// Data paths // Data paths
const CIP_URL = '/cip_institution_mapping_new.json'; const CIP_URL = '/cip_institution_mapping_new.json';
@ -49,6 +50,26 @@ export default function ScenarioEditModal({
* 5) Combined formData => scenario + college * 5) Combined formData => scenario + college
*********************************************************/ *********************************************************/
const [formData, setFormData] = useState({}); const [formData, setFormData] = useState({});
const [showCollegeForm, setShowCollegeForm] = useState(false);
/*********************************************************
* Auto-expand the college section each time the modal opens.
* --------------------------------------------------------
* The effect runs exactly once per modalopen (`show` true).
* If the saved scenario already says the user is
* currently_enrolled or prospective_student
* we open the section so they immediately see their data.
* Once open, the user can click Hide/Show; we *dont* re-run
* on every keystroke, so the effect wont fight the button.
*********************************************************/
useEffect(() => {
if (!show) return;
setShowCollegeForm(
['currently_enrolled', 'prospective_student']
.includes(formData.college_enrollment_status)
);
}, [show]);
/********************************************************* /*********************************************************
* 6) On show => load CIP, IPEDS, CAREERS * 6) On show => load CIP, IPEDS, CAREERS
@ -844,43 +865,57 @@ if (formData.retirement_start_date) {
</div> </div>
</div> </div>
{/* SECTION: College Profile */} {/* ───────── COLLEGE PROFILE heading + Add plan ───────── */}
<h3 className="text-xl font-medium mb-2">College Profile</h3>
{(formData.college_enrollment_status === 'currently_enrolled' || <div className="flex items-center justify-between mb-2">
formData.college_enrollment_status === 'prospective_student') ? ( {/* left cluster (title + info badge) */}
<div className="flex items-center space-x-2">
<h3 className="text-xl font-medium">College Profile</h3>
<InfoTooltip message="Get this info from the “Educational Programs” tab in Preparing & Upskilling for Your Career." />
</div>
{/* right cluster (toggle button) */}
<Button
variant="secondary"
size="sm"
onClick={() => {
if (
!showCollegeForm &&
formData.college_enrollment_status === 'not_enrolled'
) {
setFormData(prev => ({
...prev,
college_enrollment_status: 'prospective_student'
}));
}
setShowCollegeForm(prev => !prev);
}}
>
{showCollegeForm ? 'Hide' : 'Add plan'}
</Button>
</div>
{/* Collapse / expand the full set of inputs */}
{showCollegeForm ? (
<> <>
{/* District/State/Online */} {/* District / State / Online check-boxes ------------------ */}
<div className="flex items-center space-x-4 mb-4"> <div className="flex items-center space-x-4 mb-4">
<label className="inline-flex items-center"> {[
<input { name: 'is_in_district', label: 'In District' },
type="checkbox" { name: 'is_in_state', label: 'In State' },
name="is_in_district" { name: 'is_online', label: 'Fully Online' }
checked={!!formData.is_in_district} ].map(({ name, label }) => (
onChange={handleFormChange} <label key={name} className="inline-flex items-center">
className="mr-1" <input
/> type="checkbox"
In District name={name}
</label> checked={!!formData[name]}
<label className="inline-flex items-center"> onChange={handleFormChange}
<input className="mr-1"
type="checkbox" />
name="is_in_state" {label}
checked={!!formData.is_in_state} </label>
onChange={handleFormChange} ))}
className="mr-1"
/>
In State
</label>
<label className="inline-flex items-center">
<input
type="checkbox"
name="is_online"
checked={!!formData.is_online}
onChange={handleFormChange}
className="mr-1"
/>
Fully Online
</label>
</div> </div>
{/* Loan Deferral */} {/* Loan Deferral */}
@ -1183,7 +1218,7 @@ if (formData.retirement_start_date) {
</> </>
) : ( ) : (
<p className="text-sm text-gray-500 italic mb-4"> <p className="text-sm text-gray-500 italic mb-4">
Not currently enrolled or prospective. Minimal college fields only. Not currently enrolled or prospective. Add a plan to enter this info.
</p> </p>
)} )}