Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 38 additions & 10 deletions web/src/components/ApplicationTrackingModule.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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'

Expand All @@ -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 (
<div className="mov" style={{ display: 'flex', alignItems: 'flex-start', gap: 26, padding: '28px 30px' }}>
<div className="mov-main" style={{ flex: 1, minWidth: 0 }}>
<div style={{ display: 'inline-flex', alignItems: 'center', gap: 6, fontFamily: font, fontSize: 11, fontWeight: 600, color: MC, textTransform: 'uppercase', letterSpacing: '0.07em', background: `${MC}12`, padding: '4px 10px', borderRadius: 99, border: `1px solid ${MC}20`, marginBottom: 12 }}>
<span style={{ width: 5, height: 5, borderRadius: '50%', background: MC }} />Building Your List
</div>
<h1 style={{ fontFamily: "'Young Serif',serif", fontSize: 24, fontWeight: 400, color: C.text, margin: '0 0 8px' }}>Application Tracking</h1>
<p style={{ fontFamily: font, fontSize: 14, color: C.textMuted, margin: '0 0 20px', lineHeight: 1.6, maxWidth: 520 }}>{intro}</p>
{/* Before the list is in, "Your list is empty" would be a wrong answer. */}
{listLoaded ? strip : <div style={{ fontFamily: font, fontSize: 13, color: C.textMuted }}>Loading your list…</div>}
</div>
{aside}
</div>
)
}

/* ─── module shell ─── */

interface Props {
Expand All @@ -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<TabId>('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<TabId>('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
Expand All @@ -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])
Expand Down Expand Up @@ -218,15 +245,16 @@ 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
&& tab === 'status'
&& shouldShowFeeWaiverNotice(incomeLevel, profile?.settings?.intros_seen)

const content =
tab === 'overview' ? <ModuleOverviewTab progress={progress} onToggle={handleToggle} onMarkComplete={handleMarkComplete} checklist={APPLICATIONS_CHECKLIST} contentMap={APPLICATIONS_CONTENT_MAP} allIds={APPLICATIONS_ALL_IDS} totalItems={APPLICATIONS_TOTAL_ITEMS} accent={MC} title="Applications 101" subtitle={"Click an item title to read it. Click the circle to cycle status: empty → in-progress → done."} itemTypeIcon={itemTypeIcon} aside={aside} before={<YourListStrip apps={apps} profile={effectiveProfile} origin={origin} onOpenSchool={openInStatus} onDiscover={() => switchTab('discover')} onSeeAll={() => openInStatus(ALL_SCHOOLS)} />} /> :
tab === 'overview' ? <OverviewTab year={year} aside={aside} listLoaded={appsLoaded} strip={<YourListStrip apps={apps} profile={effectiveProfile} origin={origin} onOpenSchool={openInStatus} onDiscover={() => switchTab('discover')} onSeeAll={() => openInStatus(ALL_SCHOOLS)} />} /> :
tab === 'application-101' ? <ModuleOverviewTab progress={progress} onToggle={handleToggle} onMarkComplete={handleMarkComplete} checklist={APPLICATIONS_CHECKLIST} contentMap={APPLICATIONS_CONTENT_MAP} allIds={APPLICATIONS_ALL_IDS} totalItems={APPLICATIONS_TOTAL_ITEMS} accent={MC} title="Application 101" subtitle={"Click an item title to read it. Click the circle to cycle status: empty → in-progress → done."} itemTypeIcon={itemTypeIcon} backLabel="Back to Application 101" /> :
tab === 'aid-compare' && FEATURES.aidCompare ? <AidCompare collegeIds={apps.map((a) => a.collegeId)} accent={MC} /> :
tab === 'discover' ? <CollegeDiscoverTab open={open} apps={apps} listLoaded={appsLoaded} onAdd={handleAddFromDiscover} onRemove={handleRemoveApp} /> :
<ApplicationStatusTab onFindColleges={() => switchTab('discover')} apps={apps} onUpdate={handleUpdateApp} onRemove={handleRemoveApp} onSetShared={handleSetSharedTask} onSetSharedDue={handleSetSharedDue} gradeStartIdx={profile?.grade_start_idx} openId={school} onOpen={setSchool} colleges={collegeRows} />
Expand Down Expand Up @@ -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}
/>
Expand Down
14 changes: 11 additions & 3 deletions web/src/components/ApplicationsModuleTour.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -15,17 +15,25 @@ const STEPS: TourStep<ApplicationsTabId>[] = [
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,
Expand Down
26 changes: 13 additions & 13 deletions web/src/components/FafsaModuleTour.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,34 +35,34 @@ const STEPS: TourStep<TourTabId>[] = [
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'],
},
{
selector: '[data-tour="content"]',
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'],
},

{
Expand Down
39 changes: 35 additions & 4 deletions web/src/components/FinancialAidModule.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, { fafsa?: string; css?: string }> = { Duke: {}, UNC: {}, Elon: { fafsa: '2027-01-05' } }
render(<AidForms aid={list} gradeStartIdx={null} ownDates={{ get: (id) => 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(<AidForms aid={state([])} gradeStartIdx={null} />)
expect(screen.getAllByText('Add schools in Application Tracking to see what each one asks for')).toHaveLength(2)
Expand All @@ -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(<Scholarships101Tab progress={{ 'sr-1': 'completed' }} onToggle={onToggle} />)
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(<Scholarships101Tab progress={{}} onToggle={onToggle} />)
for (const section of ['Scholarships', 'Understanding Aid Types', 'FAFSA Preparation', 'Net Price Calculators']) {
expect(screen.getByRole('button', { name: new RegExp(`^${section}`) })).toBeInTheDocument()
}
unmount()
render(<Scholarships101Tab progress={{}} onToggle={onToggle} initialOpenId="fp-1" />)
expect(screen.getByText('What is FAFSA and why every student should file', { exact: false })).toBeInTheDocument()
expect(onToggle).not.toHaveBeenCalled()
})
})

describe('content blocks', () => {
Expand Down
Loading
Loading