import { enterpriseSession } from '../../lib/api' import { Empty } from '../../components/ui/bits' import { findEnterprise, reasonCodesFor, tripWiresFor } from '../../lib/demo/enterprises' import { alertForEnterprise } from '../../lib/demo/ops' import { inr, monthRef } from '../../lib/demo/seed' import { useLang } from '../../lib/i18n' /** * Alert history for the owner. Same reason codes the officer sees, but only * ever as plain sentences — no scores, no model vocabulary, nothing that reads * like a credit rating handed to the borrower. */ export function AppAlertsPage() { const session = enterpriseSession() const { lang, t } = useLang('hi') const hi = lang === 'hi' const e = session ? findEnterprise(session.enterpriseId) : undefined if (!session || !e) return const alert = alertForEnterprise(e.enterpriseId) const reasons = reasonCodesFor(e) const fired = tripWiresFor(e).filter((w) => w.fired) if (!alert) { return (
✓
{t('alerts.none')}

{t('home.allGoodDetail')}

) } const breachRef = alert.breachMonth ? monthRef(new Date(`${alert.breachMonth}-01T00:00:00`)) : null return (
{hi ? alert.titleHi : alert.title}
{t('home.estimate')}: {inr(alert.shortfall)} {t('home.shortfall')} {breachRef && ` · ${hi ? breachRef.fullHi : breachRef.fullEn}`}
{hi ? 'ऐसा क्यों लग रहा है' : 'Why this is expected'}
    {reasons.map((r) => (
  • {hi ? r.sentenceHi : r.sentenceEn}
  • ))}
{t('alerts.whatToDo')}

{hi ? 'अपने फ़ील्ड अधिकारी से बात करें — किस्त की तारीख़ कमाई के मौसम से मिलाई जा सकती है।' : 'Speak to your field officer — the instalment date can be aligned to your earning season.'}

{t('alerts.raisedOn')}: {alert.raisedAt} · {alert.alertId}
{fired.length > 0 && (
{hi ? 'किन बातों पर नज़र है' : 'What is being watched'}
    {fired.map((w) => (
  • ! {hi ? w.labelHi : w.label}
  • ))}
)}
) }