- Inviting a kid with an adult in charge links the account to the adult (a legacy account linked to the kid moves to the adult and is renamed). - `linkedPersonWhere` lets the account reach the kids of a linked adult, so the adult sees and manages all their kids, including ones added later. - /me, link info and access status follow the adult; siblings share state. - Web: greeting uses the account holder, profile lists each kid's group, and the invitation sheet/message address the adult. - DB tests for the adult account flow. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
44 lines
1.8 KiB
TypeScript
44 lines
1.8 KiB
TypeScript
import { Loader2 } from 'lucide-react'
|
|
import { FeeCard } from './FeeCard'
|
|
import { firstName } from './format'
|
|
import { NextClassCard } from './NextClassCard'
|
|
import { PaymentReviewBanner } from './PaymentReviewBanner'
|
|
import { useStudentApp } from './StudentAppProvider'
|
|
import { TeacherNoticeCard } from './TeacherNoticeCard'
|
|
import { WeekClassesList } from './WeekClassesList'
|
|
import { useTranslation } from 'react-i18next'
|
|
|
|
export function StudentHomeView() {
|
|
const { me, student, classes, classesPending, fees } = useStudentApp()
|
|
const { t } = useTranslation(['student', 'common'])
|
|
if (!student) return null
|
|
|
|
const allClasses = classes?.classes ?? []
|
|
const nextClass = allClasses.find((item) => !item.started) ?? null
|
|
const weekEnd = classes ? Date.parse(classes.weekEndsAt) : 0
|
|
const thisWeek = allClasses.filter((item) => Date.parse(item.startsAt) < weekEnd)
|
|
|
|
return (
|
|
<div className="space-y-6">
|
|
{/* The account holder: the student, or the adult in charge of several kids. */}
|
|
<h1 className="text-2xl font-bold text-primary">{t('home.greeting', { name: firstName(me?.account.name ?? student.fullName) })}</h1>
|
|
|
|
{fees ? <PaymentReviewBanner reports={fees.reports} /> : null}
|
|
|
|
{classesPending ? (
|
|
<div className="flex justify-center py-8" role="status" aria-label={t('loadingClasses')}>
|
|
<Loader2 className="size-6 animate-spin text-accent" aria-hidden="true" />
|
|
</div>
|
|
) : nextClass && classes ? (
|
|
<NextClassCard item={nextClass} timeZone={classes.timeZone} />
|
|
) : null}
|
|
|
|
{fees ? <FeeCard fees={fees.fees} /> : null}
|
|
|
|
{classes ? <WeekClassesList classes={thisWeek} timeZone={classes.timeZone} /> : null}
|
|
|
|
<TeacherNoticeCard teacherName={student.teacherName} />
|
|
</div>
|
|
)
|
|
}
|