diff --git a/web/src/components/ApplicationTrackingModule.tsx b/web/src/components/ApplicationTrackingModule.tsx index 5d6ca65..1aa61ba 100644 --- a/web/src/components/ApplicationTrackingModule.tsx +++ b/web/src/components/ApplicationTrackingModule.tsx @@ -18,7 +18,7 @@ import { import { MODULE_ICONS } from './moduleIcons' import { useAuth } from '../contexts/AuthContext' import { markIntroSeen } from '../lib/profiles' -import { MODULE_COLORS } from '../lib/designTokens' +import { C, MODULE_COLORS } from '../lib/designTokens' import { useModuleChecklist } from '../lib/useModuleState' import { useApplications } from '../contexts/ApplicationsContext' import { useToast } from '../contexts/ToastContext' @@ -53,6 +53,7 @@ import { routedItem, routedTab, useRoutedTab } from '../lib/hashRoute' import { useCollegePrefs } from '../lib/useCollegePrefs' const MC = MODULE_COLORS.applications +const font = "'Outfit',sans-serif" const MODULE_NAME = 'applications' const TOUR_INTRO_KEY = 'applications-module-tour' @@ -70,12 +71,39 @@ type TabId = ApplicationsTabId const TABS: Array<{ id: TabId; label: string; icon: ReactNode }> = [ { id: 'overview', label: 'Overview', icon: MODULE_ICONS.overview }, + { id: 'application-101', label: 'Application 101', icon: MODULE_ICONS.article }, { id: 'discover', label: 'Discover', icon: MODULE_ICONS.compass }, { id: 'status', label: 'Application Status', icon: MODULE_ICONS.chart }, ...(FEATURES.aidCompare ? [{ id: 'aid-compare' as const, label: 'Aid Compare', icon: MODULE_ICONS.scale }] : []), ] const TAB_IDS = TABS.map((t) => t.id) +/* ─── overview ─── */ + +/** The list at a glance, as Financial Aid's Overview is the aid: the list's + * map and balance under a word on where this grade stands. */ +function OverviewTab({ year, aside, listLoaded, strip }: { year?: number; aside?: ReactNode; listLoaded: boolean; strip: ReactNode }) { + const intro = (year ?? 11) >= 12 + ? 'Senior year is when it all gets sent. Every school’s deadline and requirements live in Application Status; mark each one off as it goes in.' + : year === 11 + ? 'Junior year is for building the list. Find schools that fit in Discover, and aim for a mix of reaches, targets and likely schools by the end of the summer.' + : 'You’re early, and that’s an advantage. Start a list of schools you’re curious about in Discover. It will change, and that’s the point.' + return ( +
+
+
+ Building Your List +
+

Application Tracking

+

{intro}

+ {/* Before the list is in, "Your list is empty" would be a wrong answer. */} + {listLoaded ? strip :
Loading your list…
} +
+ {aside} +
+ ) +} + /* ─── module shell ─── */ interface Props { @@ -94,11 +122,10 @@ export default function ApplicationTrackingModule({ open, onClose, onEditIncome, const { user, profile, refreshProfile } = useAuth() const tourSeen = profile?.settings?.intros_seen?.includes(TOUR_INTRO_KEY) ?? false const [showTour, setShowTour] = useState(false) - // Opens on Application Status: a returning student wants to see where each - // application stands. The nav keeps its teaching order (the tour walks it). - // The school whose page is open is in the URL too, under its tab, so Back - // returns to the list and a link or refresh lands on the school. - const [tab, setTab, routedSchool, setSchool] = useRoutedTab('Application Tracking', open, TAB_IDS, 'status') + // Opens on Overview, as Financial Aid does. The school whose page is open is + // in the URL too, under its tab, so Back returns to the list and a link or + // refresh lands on the school. + const [tab, setTab, routedSchool, setSchool] = useRoutedTab('Application Tracking', open, TAB_IDS, 'overview') // Changing tab closes the school's page (useRoutedTab does that). const switchTab = setTab const school = tab === 'status' ? routedSchool : null @@ -112,7 +139,7 @@ export default function ApplicationTrackingModule({ open, onClose, onEditIncome, if (open !== wasOpen) { setWasOpen(open) // A tab named in the URL (back/forward, or a refresh) wins over the default. - if (open) { setTab(routedTab('Application Tracking', TAB_IDS) ?? 'status'); setSchool(routedItem('Application Tracking', TAB_IDS)) } + if (open) { setTab(routedTab('Application Tracking', TAB_IDS) ?? 'overview'); setSchool(routedItem('Application Tracking', TAB_IDS)) } } // From the Overview list strip: a school's page, or the whole list. const openInStatus = useCallback((collegeId: string | null) => { setTab('status'); setSchool(collegeId) }, [setTab, setSchool]) @@ -218,7 +245,7 @@ export default function ApplicationTrackingModule({ open, onClose, onEditIncome, if (user) markIntroSeen(FEE_WAIVER_NOTICE_KEY).then(refreshProfile).catch(() => {}) }, [user, refreshProfile]) - // Only on the tabs where fees are actually in view — the overview tab hands + // Only on the tabs where fees are actually in view — Application 101 hands // its whole surface over to article reading, and a banner above that intrudes. const showFeeWaiver = !feeWaiverDismissed @@ -226,7 +253,8 @@ export default function ApplicationTrackingModule({ open, onClose, onEditIncome, && shouldShowFeeWaiverNotice(incomeLevel, profile?.settings?.intros_seen) const content = - tab === 'overview' ? switchTab('discover')} onSeeAll={() => openInStatus(ALL_SCHOOLS)} />} /> : + tab === 'overview' ? switchTab('discover')} onSeeAll={() => openInStatus(ALL_SCHOOLS)} />} /> : + tab === 'application-101' ? : tab === 'aid-compare' && FEATURES.aidCompare ? a.collegeId)} accent={MC} /> : tab === 'discover' ? : switchTab('discover')} apps={apps} onUpdate={handleUpdateApp} onRemove={handleRemoveApp} onSetShared={handleSetSharedTask} onSetSharedDue={handleSetSharedDue} gradeStartIdx={profile?.grade_start_idx} openId={school} onOpen={setSchool} colleges={collegeRows} /> @@ -260,7 +288,7 @@ export default function ApplicationTrackingModule({ open, onClose, onEditIncome, // on file are handed off to the profile page to add it. onPrimary={() => { if (feeWaiverEligibility(incomeLevel) === 'unknown') onEditIncome?.() - else switchTab('overview') + else switchTab('application-101') }} onDismiss={dismissFeeWaiver} /> diff --git a/web/src/components/ApplicationsModuleTour.tsx b/web/src/components/ApplicationsModuleTour.tsx index 715fdb1..bb182d9 100644 --- a/web/src/components/ApplicationsModuleTour.tsx +++ b/web/src/components/ApplicationsModuleTour.tsx @@ -2,7 +2,7 @@ import ModuleTour from './ModuleTour' import { type TourStep } from './moduleTour.helpers' import { MODULE_COLORS } from '../lib/designTokens' -export type ApplicationsTabId = 'overview' | 'discover' | 'status' | 'aid-compare' +export type ApplicationsTabId = 'overview' | 'application-101' | 'discover' | 'status' | 'aid-compare' interface Props { onDismiss: () => void @@ -15,17 +15,25 @@ const STEPS: TourStep[] = [ selector: '[data-tour="sidebar"]', pad: 8, title: 'Module Navigation', - desc: 'Three sections: Applications 101 and your college list, Discover (get matched to best-fit colleges and add to your list), and a status tracker for each application.', + desc: 'Four sections: your college list, Application 101, Discover (get matched to best-fit colleges and add to your list), and a status tracker for each application.', keepClear: ['sidebar'], }, { selector: '[data-tour="tab-overview"]', pad: 6, title: 'Overview', - desc: 'Your college list, pinned on a map, over articles and tasks covering list-building, ED vs. EA strategy, the submission workflow, and what happens after you submit.', + desc: 'Your college list at a glance: pinned on a map, with how reaches, targets and likely schools balance and what they cost.', switchTab: 'overview', keepClear: ['sidebar', 'content'], }, + { + selector: '[data-tour="tab-application-101"]', + pad: 6, + title: 'Application 101', + desc: 'Articles and tasks covering list-building, ED vs. EA strategy, the submission workflow, and what happens after you submit.', + switchTab: 'application-101', + keepClear: ['sidebar', 'content'], + }, { selector: '[data-tour="tab-discover"]', pad: 6, diff --git a/web/src/components/FafsaModuleTour.tsx b/web/src/components/FafsaModuleTour.tsx index 34f366f..128777b 100644 --- a/web/src/components/FafsaModuleTour.tsx +++ b/web/src/components/FafsaModuleTour.tsx @@ -35,16 +35,25 @@ const STEPS: TourStep[] = [ selector: '[data-tour="tab-overview"]', pad: 6, title: 'Overview', - desc: 'Start here — articles, quizzes, and tasks that build your financial aid knowledge step by step.', + desc: 'Start here: when the FAFSA and CSS Profile open and close, and where aid comes from.', switchTab: 'overview', keepClear: ['sidebar', 'content'], }, + + { + selector: '[data-tour="tab-scholarships-101"]', + pad: 6, + title: 'Scholarships 101', + desc: 'Articles, quizzes, and tasks on scholarships, the kinds of aid, the FAFSA, and net price calculators.', + switchTab: 'scholarships-101', + keepClear: ['sidebar', 'content'], + }, { - selector: '[data-tour="overview-progress"]', + selector: '[data-tour="checklist-progress"]', pad: 8, title: 'Your Progress', desc: 'Track how far along you are. Items update automatically as you complete them.', - switchTab: 'overview', + switchTab: 'scholarships-101', keepClear: ['content'], }, { @@ -52,17 +61,8 @@ const STEPS: TourStep[] = [ pad: 10, title: 'Checklist', desc: 'Click any item to open its content — articles, quizzes, and action items. Check them off as you go.', - switchTab: 'overview', - keepClear: ['content'], - }, - - { - selector: '[data-tour="tab-scholarships-101"]', - pad: 6, - title: 'Scholarships 101', - desc: 'How scholarships work, where to find ones you qualify for, and how to apply, in six short steps.', switchTab: 'scholarships-101', - keepClear: ['sidebar', 'content'], + keepClear: ['content'], }, { diff --git a/web/src/components/FinancialAidModule.test.tsx b/web/src/components/FinancialAidModule.test.tsx index 142483d..2b5751f 100644 --- a/web/src/components/FinancialAidModule.test.tsx +++ b/web/src/components/FinancialAidModule.test.tsx @@ -48,6 +48,25 @@ describe('AidForms', () => { expect(screen.queryByText('No date on file')).not.toBeInTheDocument() }) + it('takes the student’s own date where none is on file', async () => { + const set = vi.fn() + const mine: Record = { Duke: {}, UNC: {}, Elon: { fafsa: '2027-01-05' } } + render( mine[id] ?? null, set }} />) + // Elon's own date is the earliest, so it leads. + expect(screen.getByText('Your earliest school date: Jan 5, 2027 (Elon)')).toBeInTheDocument() + + await userEvent.click(screen.getByRole('button', { name: /^FAFSA/ })) + // Duke and UNC have dates on file: nothing to add there. + expect(screen.queryAllByRole('button', { name: /Add a due date/ })).toHaveLength(0) + expect(screen.getByRole('button', { name: /Change the due date for Elon’s FAFSA priority date/ })).toBeInTheDocument() + + await userEvent.click(screen.getByRole('button', { name: /^CSS Profile/ })) + // Elon may need it and has no date: the student can add one. + await userEvent.click(screen.getByRole('button', { name: 'Add a due date for Elon’s CSS Profile date' })) + expect(screen.getByDisplayValue('')).toHaveAttribute('type', 'date') + expect(set).not.toHaveBeenCalled() + }) + it('points an empty list at Application Tracking', async () => { render() expect(screen.getAllByText('Add schools in Application Tracking to see what each one asks for')).toHaveLength(2) @@ -57,21 +76,33 @@ describe('AidForms', () => { }) describe('Scholarships 101', () => { - it('lists the six steps in order and opens each one', async () => { + it('starts with the six scholarship steps and opens each one', async () => { const onToggle = vi.fn() render() - expect(screen.getByText('1/6 completed')).toBeInTheDocument() + expect(screen.getByText('1/18 completed')).toBeInTheDocument() await userEvent.click(screen.getByText('Understanding scholarships: types, eligibility, and how they work')) expect(onToggle).toHaveBeenCalledWith('sr-5') - expect(screen.getByText('1 of 6')).toBeInTheDocument() + expect(screen.getByText('1 of 18')).toBeInTheDocument() expect(screen.getByRole('heading', { name: 'What Is a Scholarship?' })).toBeInTheDocument() expect(screen.getByRole('button', { name: /Back to Scholarships 101/ })).toBeInTheDocument() // Last step's article is there too, and the "next" button stops at it. await userEvent.click(screen.getByRole('button', { name: /Back to Scholarships 101/ })) await userEvent.click(screen.getByText('Identify 10 scholarships to apply to senior year')) - expect(screen.getByText('6 of 6')).toBeInTheDocument() + expect(screen.getByText('6 of 18')).toBeInTheDocument() expect(screen.queryByText('Content not found for this item.')).not.toBeInTheDocument() }) + + it('holds the rest of the checklist, and opens an article to read without starting it', () => { + const onToggle = vi.fn() + const { unmount } = render() + for (const section of ['Scholarships', 'Understanding Aid Types', 'FAFSA Preparation', 'Net Price Calculators']) { + expect(screen.getByRole('button', { name: new RegExp(`^${section}`) })).toBeInTheDocument() + } + unmount() + render() + expect(screen.getByText('What is FAFSA and why every student should file', { exact: false })).toBeInTheDocument() + expect(onToggle).not.toHaveBeenCalled() + }) }) describe('content blocks', () => { diff --git a/web/src/components/FinancialAidModule.tsx b/web/src/components/FinancialAidModule.tsx index e8b6903..695d3c6 100644 --- a/web/src/components/FinancialAidModule.tsx +++ b/web/src/components/FinancialAidModule.tsx @@ -89,7 +89,22 @@ interface ChecklistSection { items: ChecklistItem[] } +/** Everything Scholarships 101 teaches, in its order. The scholarship steps + * come first, in the content team's reading order; they were Overview's + * "Scholarship Research" section, as the rest was the rest of Overview, so + * every item keeps its id and the progress a student already has on it. */ const CHECKLIST_SECTIONS: ChecklistSection[] = [ + { + title: 'Scholarships', + items: [ + { id: 'sr-5', label: 'Understanding scholarships: types, eligibility, and how they work', type: 'article' }, + { id: 'sr-1', label: 'How to find scholarships you actually qualify for', type: 'article' }, + { id: 'sr-3', label: 'Local vs. national scholarships: where to start', type: 'article' }, + { id: 'sr-2', label: 'Build your scholarship tracker', type: 'assignment' }, + { id: 'sr-6', label: 'How to apply for scholarships and improve your chances', type: 'article' }, + { id: 'sr-4', label: 'Identify 10 scholarships to apply to senior year', type: 'task' }, + ], + }, { title: 'Understanding Aid Types', items: [ @@ -119,22 +134,8 @@ const CHECKLIST_SECTIONS: ChecklistSection[] = [ }, ] -/** Scholarships 101's tab, in the content team's reading order. Its items - * were Overview's "Scholarship Research" section, so they keep those ids - * and whatever progress a student already has on them. */ -const SCHOLARSHIPS_101: ChecklistItem[] = [ - { id: 'sr-5', label: 'Understanding scholarships: types, eligibility, and how they work', type: 'article' }, - { id: 'sr-1', label: 'How to find scholarships you actually qualify for', type: 'article' }, - { id: 'sr-3', label: 'Local vs. national scholarships: where to start', type: 'article' }, - { id: 'sr-2', label: 'Build your scholarship tracker', type: 'assignment' }, - { id: 'sr-6', label: 'How to apply for scholarships and improve your chances', type: 'article' }, - { id: 'sr-4', label: 'Identify 10 scholarships to apply to senior year', type: 'task' }, -] - -const OVERVIEW_IDS = CHECKLIST_SECTIONS.flatMap((s) => s.items.map((i) => i.id)) -const SCHOLARSHIPS_101_IDS = SCHOLARSHIPS_101.map((i) => i.id) -/** Every item in the module, for the sidebar's progress. */ -const CHECKLIST_TOTAL_ITEMS = OVERVIEW_IDS.length + SCHOLARSHIPS_101_IDS.length +const CHECKLIST_ALL_IDS = CHECKLIST_SECTIONS.flatMap((s) => s.items.map((i) => i.id)) +const CHECKLIST_TOTAL_ITEMS = CHECKLIST_ALL_IDS.length function nextChecklistStatus(current: ChecklistItemStatus): ChecklistItemStatus { if (current === 'available') return 'in-progress' @@ -285,8 +286,8 @@ const FA_TAB_IDS = FA_TABS.map((t) => t.id) ═══════════════════════════════════════════════════════════════ */ /** The item open for reading, and the status moves that come with it: * opening one starts it, and its button walks it to complete and back. */ -function useChecklistReader(progress: ChecklistProgressMap, onToggle: (itemId: string) => void) { - const [activeId, setActiveId] = useState(null) +function useChecklistReader(progress: ChecklistProgressMap, onToggle: (itemId: string) => void, initialId: string | null = null) { + const [activeId, setActiveId] = useState(initialId) const statusOf = (id: string): ChecklistItemStatus => progress[id] ?? 'available' const open = (itemId: string) => { if (statusOf(itemId) === 'available') onToggle(itemId) @@ -325,15 +326,21 @@ const ChecklistProgress = ({ done, total, tour }: { done: number; total: number; /* ═══════════════════════════════════════════════════════════════ TAB: SCHOLARSHIPS 101 ═══════════════════════════════════════════════════════════════ */ -export const Scholarships101Tab = ({ progress, onToggle }: { progress: ChecklistProgressMap; onToggle: (itemId: string) => void }) => { - const reader = useChecklistReader(progress, onToggle) +export const Scholarships101Tab = ({ progress, onToggle, initialOpenId = null }: { + progress: ChecklistProgressMap + onToggle: (itemId: string) => void + /** Open straight onto this item (Overview's "Start FAFSA prep"), to read: not marked started. */ + initialOpenId?: string | null +}) => { + const reader = useChecklistReader(progress, onToggle, initialOpenId) + const [expanded, setExpanded] = useState>({}) if (reader.activeId) { return ( reader.setActiveId(null)} @@ -342,17 +349,34 @@ export const Scholarships101Tab = ({ progress, onToggle }: { progress: Checklist /> ) } - const done = SCHOLARSHIPS_101_IDS.filter((id) => reader.statusOf(id) === 'completed').length + const done = CHECKLIST_ALL_IDS.filter((id) => reader.statusOf(id) === 'completed').length return (

Scholarships 101

- How scholarships work, where to find ones you qualify for, and how to apply. Work through them in order. + Articles, quizzes and tasks on paying for college: how scholarships work and how to win them, the kinds of aid, the FAFSA, and net price calculators.

- -
- {SCHOLARSHIPS_101.map((item, i) => reader.open(item.id)} />)} -
+ + + Your Checklist + + {CHECKLIST_SECTIONS.map((section, idx) => { + const sdone = section.items.filter((x) => reader.statusOf(x.id) === 'completed').length + const isOpen = expanded[idx] !== false + return ( +
+ + {isOpen && section.items.map((item, i) => ( + reader.open(item.id)} /> + ))} +
+ ) + })} +

Click any item to open its content

) } @@ -362,77 +386,29 @@ export const Scholarships101Tab = ({ progress, onToggle }: { progress: Checklist ═══════════════════════════════════════════════════════════════ */ interface OverviewTabProps { aside?: ReactNode - progress: ChecklistProgressMap - onToggle: (itemId: string) => void /** Two-letter state from the student's ZIP. */ homeState: string | null aid: AidCollegesState onGoToTab: (tab: TabId) => void + /** Open one of Scholarships 101's items, to read. */ + onRead: (itemId: string) => void + ownDates: OwnAidDates /** The student's grade, 9–12. */ year: number /** `profiles.grade_start_idx`, which decides whose FAFSA this is. */ gradeStartIdx: number | null | undefined } -const OverviewTab = ({ progress, onToggle, aside, homeState, aid, onGoToTab, year, gradeStartIdx }: OverviewTabProps) => { - const { activeId: activeContentId, setActiveId: setActiveContentId, statusOf, open: openContent, markComplete: handleMarkComplete } = useChecklistReader(progress, onToggle) - // Lives here, not in the guide, so it survives opening an article and coming back. +const OverviewTab = ({ aside, homeState, aid, onGoToTab, onRead, ownDates, year, gradeStartIdx }: OverviewTabProps) => { const [guideRow, setGuideRow] = useState(null) - const [expanded, setExpanded] = useState>({ 0: true, 1: true, 2: true }) - const toggle = (i: number) => setExpanded((p) => ({ ...p, [i]: !p[i] })) - const done = OVERVIEW_IDS.filter((id) => statusOf(id) === 'completed').length - const handleGuideGoTo = (dest: AidGuideDestination) => { - // Opened to read, not started: going through openContent would mark the - // checklist item in progress just for following a link. - if (dest === 'fafsa') setActiveContentId('fp-1') + if (dest === 'fafsa') onRead('fp-1') else onGoToTab(dest) } - if (activeContentId) { - return ( - setActiveContentId(null)} - onMarkComplete={handleMarkComplete} - onNavigate={openContent} - /> - ) - } - // One school can sit on the list under two ids; the guarantee shows once. const yourSchools = [...new Map(aid.colleges.flatMap((c) => (c.guarantee ? [[c.canonicalId, c.guarantee] as const] : []))).values()] - const checklist = ( -
- - - Your Checklist - - {CHECKLIST_SECTIONS.map((section, idx) => { - const sdone = section.items.filter((x) => statusOf(x.id) === 'completed').length - const isOpen = expanded[idx] !== false - return ( -
- - {isOpen && section.items.map((item, i) => ( - openContent(item.id)} /> - ))} -
- ) - })} -

Click any item to open its content

-
- ) - const guide = return ( @@ -450,7 +426,7 @@ const OverviewTab = ({ progress, onToggle, aside, homeState, aid, onGoToTab, yea : "You're early, and that's an advantage. The FAFSA opens in the fall of senior year; until then, building your scholarship list and running net price calculators puts you miles ahead."}

-
onGoToTab('scholarships')} />
+
onGoToTab('scholarships')} />
{[ @@ -475,10 +451,7 @@ const OverviewTab = ({ progress, onToggle, aside, homeState, aid, onGoToTab, yea
)} -
- {guide} - {checklist} -
+ {guide} {aside} @@ -803,10 +776,11 @@ const TaskBox = ({ done }: { done: boolean }) => ( ) -const ScholarshipsTab = ({ api, aid, gradeStartIdx, initialOpenId, onFindScholarships }: { +const ScholarshipsTab = ({ api, aid, ownDates, gradeStartIdx, initialOpenId, onFindScholarships }: { api: TrackerApi /** The student's schools, for the FAFSA and CSS Profile boxes on top. */ aid: AidCollegesState + ownDates: OwnAidDates gradeStartIdx: number | null | undefined /** Open straight onto this scholarship's page (from the Scholarship Engine's strip). */ initialOpenId: string | null @@ -847,7 +821,7 @@ const ScholarshipsTab = ({ api, aid, gradeStartIdx, initialOpenId, onFindScholar const yourAid = (

Your financial aid

- +
) @@ -1964,11 +1938,28 @@ const FAFSA_TINT = '#1D7FC4' const CSS_TINT = '#7048C8' const ADD_SCHOOLS_HREF = formatRoute({ page: 'dashboard', module: 'Application Tracking', tab: 'discover' }) -const SchoolLine = ({ c, value, color }: { c: AidCollege; value: string; color?: string }) => ( +/** The student's own FAFSA and CSS Profile dates, kept on Application + * Tracking's entry for each school, where the calendar reads them too. */ +export interface OwnAidDates { + /** Null for a school only on the old Deadlines list: no entry to keep a date on. */ + get: (collegeId: string) => { fafsa?: string; css?: string } | null + set: (collegeId: string, form: 'fafsa' | 'css', iso: string | undefined) => void +} + +const SchoolLine = ({ c, value, color, edit }: { + c: AidCollege + value: string + color?: string + /** The student's date picker, where they can give one: after `value`, or in its place once set. */ + edit?: { due: string | undefined; label: string; onCommit: (iso: string | undefined) => void } +}) => (
{c.name} - {value} + + {edit?.due ? 'Your date' : value} + {edit && } +
) @@ -1979,19 +1970,45 @@ const FormNote = ({ children }: { children: ReactNode }) => ( /** The FAFSA and CSS Profile boxes. In Aid Tracker each opens onto the * student's schools (Application Tracking's list, plus any saved in the old * Deadlines tab); on Overview, where they don't open, they go there. */ -export function AidForms({ aid, gradeStartIdx, onSeeSchools }: { +export function AidForms({ aid, gradeStartIdx, onSeeSchools, ownDates }: { aid: AidCollegesState gradeStartIdx: number | null | undefined onSeeSchools?: () => void + ownDates?: OwnAidDates }) { const [open, setOpen] = useState<'fafsa' | 'css' | null>(null) const now = new Date() const seniorFall = seniorFallYear(gradeStartIdx, now) const fafsa = fafsaOpening(seniorFall) const cssOpens = cssProfileOpening(seniorFall) - // One school can sit on the list under two ids; it shows once. - const schools = [...new Map(aid.colleges.map((c) => [c.canonicalId, inCycle(c, seniorFall)])).values()] + const own = (c: AidCollege) => ownDates?.get(c.id) ?? null + // One school can sit on the list under two ids; it shows once, under + // Application Tracking's id where it has one, since that's where its dates live. + const picked = new Map() + for (const c of aid.colleges) if (!picked.has(c.canonicalId) || own(c)) picked.set(c.canonicalId, c) + // The student's own date, where they gave one, stands in for the school's. + const shown = (iso: string | undefined, onFile: string | null) => { + const d = iso ? parseIsoDay(iso) : null + return d ? formatCollegeDate(d) : onFile + } + const rows = [...picked.values()].map((saved) => { + const school = inCycle(saved, seniorFall) + const mine = own(saved) + const f = school.financialAidDeadlines + const c = { ...school, financialAidDeadlines: { ...f, fafsaPriority: shown(mine?.fafsa, f.fafsaPriority), cssProfile: shown(mine?.css, f.cssProfile) } } + return { c, id: saved.id, mine, onFile: { fafsa: f.fafsaPriority, css: f.cssProfile } } + }) + const schools = rows.map((r) => r.c) + const rowFor = new Map(rows.map((r) => [r.c.canonicalId, r])) const n = schools.length + // A picker where there's no date on file, or the student's own is showing. + const editFor = (c: AidCollege, form: 'fafsa' | 'css') => { + const r = rowFor.get(c.canonicalId) + if (!ownDates || !r?.mine) return undefined + const due = r.mine[form] + if (!due && r.onFile[form]) return undefined + return { due, label: `${c.name}’s ${form === 'fafsa' ? 'FAFSA priority' : 'CSS Profile'} date`, onCommit: (iso: string | undefined) => ownDates.set(r.id, form, iso) } + } const priority = (c: AidCollege) => parseCollegeDate(c.financialAidDeadlines.fafsaPriority)?.getTime() ?? Infinity const byPriority = [...schools].sort((a, b) => priority(a) - priority(b) || a.name.localeCompare(b.name)) @@ -2047,9 +2064,9 @@ export function AidForms({ aid, gradeStartIdx, onSeeSchools }: { `${fafsa.date <= now ? 'Opened' : fafsa.known ? 'Opens' : 'Opens by'} ${formatCollegeDate(fafsa.date)} · Closes ${formatCollegeDate(fafsaFederalDeadline(seniorFall))}`, fafsaSummary, <> - {schoolsBody(byPriority.map((c) => ))} + {schoolsBody(byPriority.map((c) => ))} - File by each school’s priority date to be first in line for its aid; the federal deadline comes much later. No date on file? File as soon as it opens.{' '} + File by each school’s priority date to be first in line for its aid; the federal deadline comes much later. No date on file? Add it from the school’s aid page, or file as soon as the FAFSA opens to be safe.{' '} studentaid.gov ↗ )} @@ -2063,10 +2080,11 @@ export function AidForms({ aid, gradeStartIdx, onSeeSchools }: { c={c} value={need === 'required' ? c.financialAidDeadlines.cssProfile ?? 'Required' : need === 'check' ? 'Check its aid page' : c.curated || c.type !== '4-year' ? 'Not needed' : 'Not usually'} color={need === 'required' ? CSS_TINT : need === 'check' ? '#C47A12' : undefined} + edit={need === 'no' ? undefined : editFor(c, 'css')} /> )))} - Mostly private colleges use it to award their own aid. Unlike the FAFSA it charges a fee per school, which College Board waives for many lower-income families.{' '} + Mostly private colleges use it to award their own aid. Unlike the FAFSA it charges a fee per school, which College Board waives for many lower-income families. A due date you add goes on your calendar.{' '} College Board ↗ )} @@ -2104,21 +2122,21 @@ export default function FinancialAidModule({ open, onClose, year = 11, aside }: }, [open, tourSeen]) const isNarrow = useIsNarrow() - // Opens on Aid Tracker, as Application Tracking opens on Application - // Status: a returning student wants to see where each one stands. - const [tab, setTab] = useRoutedTab('Financial Aid', open, FA_TAB_IDS, 'scholarships') - // A tracked scholarship to open straight onto when switching to My - // Scholarships (from the Scholarship Engine's strip). Any other tab change clears it. - const [openScholarship, setOpenScholarship] = useState(null) - const switchTab = useCallback((t: TabId) => { setOpenScholarship(null); setTab(t) }, [setTab]) - // Reopens on Aid Tracker rather than wherever it was left. The module + // Opens on Overview, as Application Tracking does. + const [tab, setTab] = useRoutedTab('Financial Aid', open, FA_TAB_IDS, 'overview') + // What to open straight onto when switching tab: a tracked scholarship in + // Aid Tracker (from the Scholarship Engine's strip), or an article in + // Scholarships 101 (from Overview). Any other tab change clears it. + const [openItem, setOpenItem] = useState(null) + const switchTab = useCallback((t: TabId) => { setOpenItem(null); setTab(t) }, [setTab]) + // Reopens on Overview rather than wherever it was left. The module // stays mounted while closed, so the tab would otherwise survive from a // visit the student no longer remembers. Adjusted on the open transition, // not in an effect, so the first paint is already the right tab. const [wasOpen, setWasOpen] = useState(open) if (open !== wasOpen) { setWasOpen(open) - if (open) { setTab(routedTab('Financial Aid', FA_TAB_IDS) ?? 'scholarships'); setOpenScholarship(null) } // a tab in the URL wins + if (open) { setTab(routedTab('Financial Aid', FA_TAB_IDS) ?? 'overview'); setOpenItem(null) } // a tab in the URL wins } const [progress, setProgress] = useState({}) const [progressError, setProgressError] = useState(null) @@ -2135,13 +2153,31 @@ export default function FinancialAidModule({ open, onClose, year = 11, aside }: // The schools are Application Tracking's, as on the calendar, plus any a // student saved in the old Deadlines tab. Those stay shown, though nothing // here adds to or edits that list any more. - const { apps } = useApplications() + const { apps, appsRef, saveApps, loaded: appsLoaded, loadFailed: appsFailed } = useApplications() + const ownDates = useMemo((): OwnAidDates => ({ + get: (id) => { + const a = apps.find((x) => x.collegeId === id) + return a ? { fafsa: a.fafsaDate, css: a.cssDate } : null + }, + set: (id, form, iso) => { + const next = appsRef.current.map((a) => (a.collegeId !== id ? a : form === 'fafsa' ? { ...a, fafsaDate: iso } : { ...a, cssDate: iso })) + void saveApps(next).then((ok) => { + if (!ok) toast.error('Could not save that date — try again') + else toast.success(iso ? 'Date saved — it’s on your calendar now' : 'Date cleared') + }) + }, + }), [apps, appsRef, saveApps, toast]) const shownCollegeIds = useMemo(() => [...new Set([...apps.map((a) => a.collegeId), ...collegeIds])], [apps, collegeIds]) // One lookup for Overview and Aid Tracker, so moving between them // does not refetch the same rows. Each opening of the module is its own // session, so reopening fetches fresh rather than showing last visit's rows. const [openCount, setOpenCount] = useState(0) - const aidColleges = useAidColleges(shownCollegeIds, openCount) + const lookedUp = useAidColleges(shownCollegeIds, openCount) + // Until Application Tracking's list is in, an empty lookup means "not yet", + // not "no schools": the boxes said "Add schools" to students who had them. + const aidColleges = useMemo(() => ( + appsFailed ? { ...lookedUp, failed: true } : appsLoaded ? lookedUp : { ...lookedUp, loading: true } + ), [lookedUp, appsLoaded, appsFailed]) // "Not interested", kept per student with their other module data. const { data: dismissedIds, dataRef: dismissedRef, saveData: saveDismissed } = @@ -2349,7 +2385,8 @@ export default function FinancialAidModule({ open, onClose, year = 11, aside }: if (!(await saveShared(next))) toast.error('Could not save that — try again') }, } - const openTracked = (id: string | null) => { setTab('scholarships'); setOpenScholarship(id) } + const openTracked = (id: string | null) => { setTab('scholarships'); setOpenItem(id) } + const read101 = (id: string) => { setTab('scholarships-101'); setOpenItem(id) } const saveAidPrefsOrSay = async (p: AidPrefs) => { if (!(await saveAidPrefs(p))) toast.error('Could not save your preferences — try again') } @@ -2357,9 +2394,9 @@ export default function FinancialAidModule({ open, onClose, year = 11, aside }: if (!open) return null const content = - tab === 'overview' ? : - tab === 'scholarships-101' ? : - tab === 'scholarships' ? switchTab('scholarship-search')} /> : + tab === 'overview' ? : + tab === 'scholarships-101' ? : + tab === 'scholarships' ? switchTab('scholarship-search')} /> : void saveAidPrefsOrSay(p)} dismissals={dismissals} onOpenTracked={openTracked} year={year} /> return ( diff --git a/web/src/components/ModuleOverviewTab.tsx b/web/src/components/ModuleOverviewTab.tsx index 91c44f4..22fa9b0 100644 --- a/web/src/components/ModuleOverviewTab.tsx +++ b/web/src/components/ModuleOverviewTab.tsx @@ -38,10 +38,8 @@ interface Props { * passed down, so every panel shares the one set of handlers rather than * each module loading its own copy of the student's dates. */ aside?: ReactNode - /** Rendered above the title, inside the main column. Applications puts the - * student's college list and map here, so the module's front page opens on - * what they have before it teaches what to do next. */ - before?: ReactNode + /** Back's label in the article reader, when this isn't the Overview tab. */ + backLabel?: string } export default function ModuleOverviewTab({ @@ -55,9 +53,9 @@ export default function ModuleOverviewTab({ accent, title, subtitle, - before, itemTypeIcon, aside, + backLabel, }: Props) { const [expanded, setExpanded] = useState>(() => Object.fromEntries(checklist.map((_, i) => [i, true]))) @@ -76,6 +74,7 @@ export default function ModuleOverviewTab({ contentMap={contentMap} allIds={allIds} accentColor={accent} + backLabel={backLabel} onBack={() => setActiveContentId(null)} onMarkComplete={onMarkComplete} onNavigate={setActiveContentId} @@ -86,7 +85,6 @@ export default function ModuleOverviewTab({ return (
- {before}

{title}

{subtitle} diff --git a/web/src/data/applicationDeadlines.test.ts b/web/src/data/applicationDeadlines.test.ts index 3fa24bf..6e74902 100644 --- a/web/src/data/applicationDeadlines.test.ts +++ b/web/src/data/applicationDeadlines.test.ts @@ -107,6 +107,16 @@ describe('deriveDeadlineEvents', () => { expect(events.some((e) => e.id === 'fafsa-harvard')).toBe(true) }) + it('uses the student’s own FAFSA and CSS dates for a school, as given', () => { + const events = derive([{ ...app('sc-1', 'RD', 'Alpha College'), fafsaDate: '2027-02-14', cssDate: '2026-11-20' }, app('sc-2', 'RD', 'Beta College')]) + const fafsa = events.find((e) => e.id === 'fafsa-sc-1')! + expect(fafsa.date.getTime()).toBe(new Date(2027, 1, 14).getTime()) + expect(fafsa.estimated).toBe(false) + expect(events.find((e) => e.id === 'css-sc-1')!.dateDisplay).toBe('Nov 20, 2026') + // Only the school with no date of either kind is left on the shared event. + expect(events.find((e) => e.id === 'fafsa-priority')!.details).toContainEqual({ label: 'No date on file for', value: 'Beta College' }) + }) + it('returns events sorted ascending by date', () => { const events = derive([app('ucla', 'RD'), app('harvard', 'EA')]) for (let i = 1; i < events.length; i++) { diff --git a/web/src/data/applicationDeadlines.ts b/web/src/data/applicationDeadlines.ts index 93da026..dfddf2f 100644 --- a/web/src/data/applicationDeadlines.ts +++ b/web/src/data/applicationDeadlines.ts @@ -423,9 +423,9 @@ export function deriveDeadlineEvents( const aid = [college?.meetsFullNeed && 'meets full need', college?.noLoanPolicy && 'no loans'] .filter(Boolean).join(' · ') if (aid) details.push({ label: 'Aid', value: aid }) - if (college?.financialAidDeadlines.cssProfile) { - details.push({ label: 'CSS Profile due', value: college.financialAidDeadlines.cssProfile }) - } + const cssDue = a.cssDate ? parseIsoDay(a.cssDate) : null + const cssShown = cssDue ? formatCollegeDate(cssDue) : college?.financialAidDeadlines.cssProfile + if (cssShown) details.push({ label: 'CSS Profile due', value: cssShown }) events.push({ id: appEventId(a), collegeId: a.collegeId, @@ -558,15 +558,23 @@ function deriveAidEvents( const active = apps.filter((a) => a.status !== 'withdrawn') const undated: string[] = [] const cssSchools: string[] = [] + // The student's own date as they gave it; else the school's, moved into their cycle. + const schoolDate = (own: string | undefined, onFile: string | null | undefined) => { + const mine = own ? parseIsoDay(own) : null + if (mine) return { date: mine, moved: false } + const d = parseCollegeDate(onFile) + if (!d) return null + const date = dateInCycle(d.getMonth(), d.getDate(), seniorFall) + return { date, moved: d.getFullYear() !== date.getFullYear() } + } for (const a of active) { const college = lookup(a.collegeId) const name = college?.name ?? a.name ?? 'College' const link = linkFor(a.website ?? college?.domain) - const priority = parseCollegeDate(college?.financialAidDeadlines.fafsaPriority) + const priority = schoolDate(a.fafsaDate, college?.financialAidDeadlines.fafsaPriority) if (priority) { - const date = dateInCycle(priority.getMonth(), priority.getDate(), seniorFall) - const moved = priority.getFullYear() !== date.getFullYear() + const { date, moved } = priority events.push({ ...base, id: `fafsa-${a.collegeId}`, @@ -589,13 +597,12 @@ function deriveAidEvents( undated.push(name) } - const css = parseCollegeDate(college?.financialAidDeadlines.cssProfile) + const css = schoolDate(a.cssDate, college?.financialAidDeadlines.cssProfile) // One definition of "this school wants the CSS Profile", shared with the // school's own task list: a date on file, or the task that asks for it. if (css || tasksForEntry(a).some((t) => t.id === 'css')) cssSchools.push(name) if (css) { - const date = dateInCycle(css.getMonth(), css.getDate(), seniorFall) - const moved = css.getFullYear() !== date.getFullYear() + const { date, moved } = css events.push({ ...base, id: `css-${a.collegeId}`, diff --git a/web/src/data/applicationsChecklist.ts b/web/src/data/applicationsChecklist.ts index 48f95d6..a26d16f 100644 --- a/web/src/data/applicationsChecklist.ts +++ b/web/src/data/applicationsChecklist.ts @@ -174,6 +174,13 @@ export interface ApplicationEntry { /** Whether that row's aid dates were checked by hand, so a blank CSS date * means "not asked for" rather than "not on file". Copied alongside. */ aidCurated?: boolean + /** + * The student's own FAFSA priority and CSS Profile dates for this school + * (`YYYY-MM-DD`), entered in Financial Aid where we have none on file. Each + * wins over the school's row wherever the date shows. + */ + fafsaDate?: string + cssDate?: string } export type TaskPhase = 'before' | 'submit' | 'after'