'use client'; import clsx from 'clsx'; import { CheckIcon, ExclamationTriangleIcon, InformationCircleIcon, ClockIcon } from '@heroicons/react/24/outline'; import { useLanguage } from '@/context/LanguageContext'; import type { EventFinance } from '@/lib/api'; import { LIFECYCLE_STEPS, tCount, type Lifecycle } from './derive'; import type { FinanceSection } from './FinanceTab'; /** * Where the event's books stand: Selling -> Adding costs -> Ready to close -> * Finalized, with what is still missing underneath. Closing the books itself * happens in Split & Payouts; this only points the way. */ export function LifecycleStepper({ data, lifecycle, goTo }: { data: EventFinance; lifecycle: Lifecycle; goTo: (s: FinanceSection) => void }) { const { t, locale } = useLanguage(); const current = LIFECYCLE_STEPS.indexOf(lifecycle.step); const open = data.status === 'open'; const dateFmt = (iso: string | null) => iso ? new Date(iso).toLocaleDateString(locale === 'es' ? 'es-PY' : 'en-US', { dateStyle: 'medium' }) : ''; // Once every cost is in, the nudge says so instead of asking for more. const nudgeKey = lifecycle.step === 'ready' ? 'admin.finance.lifecycle.nudgeReady' : 'admin.finance.lifecycle.nudge'; const nudge = open && lifecycle.ended && lifecycle.daysSinceEnd !== null ? lifecycle.daysSinceEnd === 0 ? t(`${nudgeKey}Today`) : tCount(t, nudgeKey, lifecycle.daysSinceEnd) : null; const ready = lifecycle.step === 'ready'; return (
    {LIFECYCLE_STEPS.map((step, i) => { const done = i < current || (step === 'finalized' && !open); const active = i === current && open; return (
  1. {i > 0 && ( )} {done ? : i + 1} {t(`admin.finance.lifecycle.steps.${step}`)}
  2. ); })}
{(nudge || lifecycle.todo.length > 0 || !open) && (
{nudge && (

{ready ? : } {nudge}

{data.viewer.canEditExpenses && !ready && ( )}
)} {!open && (

{t(data.status === 'paid_out' ? 'admin.finance.lifecycle.paidOut' : 'admin.finance.lifecycle.frozen', { date: dateFmt(data.finalizedAt) })}

)} {lifecycle.todo.length > 0 && ( )}
)}
); }