import { useMemo } from 'react'; import { usePlanning } from '@/app/planning-store'; import { absoluteWindow, dayPart, festivalDay } from '@/domain/festival'; import { indexPlanning } from '@/domain/selectors'; import { DesignNote, PhoneFrame } from '@/pages/mobile/PhoneFrame'; import { t } from '@/i18n'; export function MobileVolunteerPage() { const { state, dispatch } = usePlanning(); const index = useMemo( () => indexPlanning(state.assignments, state.volunteers), [state.assignments, state.volunteers], ); const me = state.volunteers[0]; const slots = (index.byVolunteer.get(me.id) ?? []) .slice() .sort( (a, b) => absoluteWindow(a.dayId, a.dayPartCode).start - absoluteWindow(b.dayId, b.dayPartCode).start, ) .map((assignment) => { const position = state.positions.find((p) => p.id === assignment.positionId)!; const positionIndex = state.positions.findIndex((p) => p.id === assignment.positionId); const lead = state.volunteers[(positionIndex * 5 + 3) % state.volunteers.length]; return { assignmentId: assignment.id, day: festivalDay(assignment.dayId).longLabel, hours: dayPart(assignment.dayPartCode).label, position: position.name.toUpperCase(), zone: position.zone, location: position.location, leadName: lead.fullName, leadPhone: lead.phone, leadPhoneRaw: lead.phone.replace(/\s/g, ''), confirmed: assignment.status === 'CONFIRMED', }; }); const toConfirm = slots.filter((s) => !s.confirmed).length; const totalHours = index.totalHours.get(me.id) ?? 0; return (
{t('mobileVol.kicker')}
{t('mobileVol.greeting', { name: me.firstName.toUpperCase() })}
{t('mobileVol.slots', { count: slots.length })}
{t('mobileVol.hours', { count: totalHours })}
{toConfirm > 0 ? (
{t('mobileVol.toConfirm', { count: toConfirm })}
) : null}
{slots.map((slot) => (
{slot.day} {slot.hours}
{slot.position}
{slot.zone}
{t('mobileVol.location', { location: slot.location })}
{t('mobileVol.lead', { name: slot.leadName })}
{slot.confirmed ? (
{t('mobileVol.confirmed')}
) : ( )}
))}
{t('mobileVol.orgMessageTitle')}

{t('mobileVol.orgMessageBody')}

{t('mobileVol.orgMessageMeta')}
{t('mobileVol.designNote')}
); }