@burdenoff/microfe-healthybowl 2026.902.19 → 2026.902.21

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (30) hide show
  1. package/dist/components/assistant/AssistantChatArea.js +234 -220
  2. package/dist/components/assistant/AssistantChatArea.js.map +1 -1
  3. package/dist/components/assistant/AssistantSpokenTurnsNotice.js +33 -0
  4. package/dist/components/assistant/AssistantSpokenTurnsNotice.js.map +1 -0
  5. package/dist/components/assistant/voice/AssistantVoiceSession.js +16 -16
  6. package/dist/components/assistant/voice/VoiceTranscriptDrawer.js.map +1 -1
  7. package/dist/healthybowl/hooks/useConsultationPayments.js +59 -0
  8. package/dist/healthybowl/hooks/useConsultationPayments.js.map +1 -0
  9. package/dist/healthybowl/hooks/useHealthyBowlData.js +15 -0
  10. package/dist/healthybowl/hooks/useHealthyBowlData.js.map +1 -1
  11. package/dist/healthybowl/offline/graphql.js.map +1 -1
  12. package/dist/healthybowl/offline/syncEngine.js +2 -1
  13. package/dist/healthybowl/offline/syncEngine.js.map +1 -1
  14. package/dist/healthybowl/offline/types.js.map +1 -1
  15. package/dist/healthybowl/pages/government-schemes/ApplicationTrackingPage.js +228 -188
  16. package/dist/healthybowl/pages/government-schemes/ApplicationTrackingPage.js.map +1 -1
  17. package/dist/healthybowl/pages/government-schemes/SchemeDetailsPage.js +261 -191
  18. package/dist/healthybowl/pages/government-schemes/SchemeDetailsPage.js.map +1 -1
  19. package/dist/healthybowl/pages/government-schemes/schemeApplicationTransitions.js +49 -0
  20. package/dist/healthybowl/pages/government-schemes/schemeApplicationTransitions.js.map +1 -0
  21. package/dist/healthybowl/pages/government-schemes/schemeDocumentSlots.js +48 -0
  22. package/dist/healthybowl/pages/government-schemes/schemeDocumentSlots.js.map +1 -0
  23. package/dist/healthybowl/pages/government-schemes/useSchemeApplicationTransition.js +54 -0
  24. package/dist/healthybowl/pages/government-schemes/useSchemeApplicationTransition.js.map +1 -0
  25. package/dist/healthybowl/pages/network/ExpertsPage.js +520 -419
  26. package/dist/healthybowl/pages/network/ExpertsPage.js.map +1 -1
  27. package/dist/hooks/useConversationTurns.js +19 -0
  28. package/dist/hooks/useConversationTurns.js.map +1 -0
  29. package/dist/types/assistant.js.map +1 -1
  30. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"SchemeDetailsPage.js","names":[],"sources":["../../../../src/healthybowl/pages/government-schemes/SchemeDetailsPage.tsx"],"sourcesContent":["import { useState, useMemo } from 'react';\nimport { useParams, useNavigate } from 'react-router';\nimport {\n Landmark,\n Circle,\n CheckCircle2,\n XCircle,\n HelpCircle,\n ArrowLeft,\n CalendarDays,\n DollarSign,\n Clock,\n ChevronDown,\n ChevronUp,\n Upload,\n AlertCircle,\n} from 'lucide-react';\nimport { PageLayout, StatusBadge, Breadcrumbs, EmptyState, ErrorState, PageLoader, Modal } from '../../components';\nimport { ToastContainer } from '../../components/Toast';\nimport { GlassCard, Button } from '@burdenoff/fe-libs/ui';\nimport { useToast } from '../../hooks/useToast';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport { useHealthyBowlData } from '../../hooks/useHealthyBowlData';\nimport { useSchemeEligibility } from '../../hooks/useSchemeEligibility';\nimport { useOfflineSync } from '../../offline/OfflineSyncProvider';\nimport { formatCurrency, formatDate, cn, todayLocalDate } from '../../utils/helpers';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { getEffectiveSchemeStatus, isAcceptingSchemeApplications } from './schemeDiscoveryFilters';\n\nconst statusVariant = (s: string) => {\n switch (s) {\n case 'open':\n return 'success' as const;\n case 'closing_soon':\n return 'warning' as const;\n case 'closed':\n case 'expired':\n return 'error' as const;\n default:\n return 'default' as const;\n }\n};\n\nconst categoryVariant = (c: string) => {\n switch (c) {\n case 'subsidy':\n return 'success' as const;\n case 'credit':\n return 'info' as const;\n case 'insurance':\n return 'warning' as const;\n case 'training':\n return 'default' as const;\n case 'grant':\n return 'success' as const;\n case 'equipment':\n return 'muted' as const;\n default:\n return 'muted' as const;\n }\n};\n\ninterface FaqItem {\n question: string;\n answer: string;\n}\n\nexport const SchemeDetailsPage = () => {\n const { governmentSchemes, errors, loadings, refetch } = useHealthyBowlData();\n // The write is owned by the offline outbox, not Apollo (BOFF-6179).\n const { queueSchemeApplication } = useOfflineSync();\n\n const { schemeId } = useParams<{ schemeId: string }>();\n // BOFF-6110 — the met/unmet verdict from this workspace's own farm data. Advisory: the panel\n // degrades to the scheme's published criteria if the check fails or the scheme has no rules.\n const { eligibility } = useSchemeEligibility(schemeId);\n const navigate = useNavigate();\n const { buildPath } = useBasePath();\n const { toasts, toast, dismiss } = useToast();\n const { t } = useI18n();\n\n const schemeFaqs: FaqItem[] = useMemo(\n () => [\n {\n question: t(\n 'healthybowl.governmentSchemes.schemeDetails.faq.reviewTime.question',\n 'How long does the application review process take?'\n ),\n answer: t(\n 'healthybowl.governmentSchemes.schemeDetails.faq.reviewTime.answer',\n 'Typically, applications are reviewed within 2-4 weeks of submission. You will receive status updates via email and on the Application Tracking page.'\n ),\n },\n {\n question: t(\n 'healthybowl.governmentSchemes.schemeDetails.faq.documents.question',\n 'What documents do I need to submit?'\n ),\n answer: t(\n 'healthybowl.governmentSchemes.schemeDetails.faq.documents.answer',\n 'Required documents include farm ownership or lease proof, valid ID, bank account details, organic certification (if applicable), and any scheme-specific documents mentioned in the eligibility criteria.'\n ),\n },\n {\n question: t(\n 'healthybowl.governmentSchemes.schemeDetails.faq.pendingCertification.question',\n 'Can I apply if my organic certification is pending?'\n ),\n answer: t(\n 'healthybowl.governmentSchemes.schemeDetails.faq.pendingCertification.answer',\n 'For schemes requiring organic certification, you may apply during the transition period. Provide your transition plan and any in-process certification documentation.'\n ),\n },\n {\n question: t(\n 'healthybowl.governmentSchemes.schemeDetails.faq.disbursement.question',\n 'How will the benefits be disbursed?'\n ),\n answer: t(\n 'healthybowl.governmentSchemes.schemeDetails.faq.disbursement.answer',\n 'Approved benefits are transferred directly to your registered bank account. The disbursement typically occurs within 30 days of approval. You will receive a notification when the transfer is initiated.'\n ),\n },\n ],\n [t]\n );\n const [expandedFaq, setExpandedFaq] = useState<number | null>(null);\n const [showApplyModal, setShowApplyModal] = useState(false);\n const [submitting, setSubmitting] = useState(false);\n const [applicationForm, setApplicationForm] = useState({\n applicantName: '',\n farmName: '',\n farmSize: '',\n farmLocation: '',\n declaration: false,\n });\n const [readyDocuments, setReadyDocuments] = useState<Set<string>>(() => new Set());\n\n const scheme = governmentSchemes.find((s) => s.id === schemeId);\n\n const relatedSchemes = useMemo(() => {\n if (!scheme) return [];\n return governmentSchemes.filter((s) => s.id !== scheme.id && s.category === scheme.category);\n }, [governmentSchemes, scheme]);\n\n if (!scheme) {\n return (\n <PageLayout\n title={t('healthybowl.governmentSchemes.schemeDetails.notFound.title', 'Scheme Not Found')}\n description={t(\n 'healthybowl.governmentSchemes.schemeDetails.notFound.description',\n 'The requested scheme could not be found'\n )}\n >\n {loadings.government ? (\n <PageLoader />\n ) : errors.government ? (\n <ErrorState onRetry={refetch} />\n ) : (\n <EmptyState\n icon={<AlertCircle className=\"h-12 w-12\" />}\n title={t('healthybowl.governmentSchemes.schemeDetails.notFound.emptyState.title', 'Scheme Not Found')}\n description={t(\n 'healthybowl.governmentSchemes.schemeDetails.notFound.emptyState.description',\n 'The government scheme you are looking for does not exist or may have been removed.'\n )}\n action={\n <Button onClick={() => navigate(buildPath('government-schemes/discover'))}>\n {t('healthybowl.governmentSchemes.schemeDetails.notFound.browseSchemes', 'Browse Schemes')}\n </Button>\n }\n />\n )}\n </PageLayout>\n );\n }\n\n // BOFF-6110 — the criteria the scheme publishes. Still shown verbatim and in full: the\n // scheme's own wording is the authority, and the structured check below only says which of\n // them this farm's data demonstrably satisfies.\n const eligibilityRequirements = scheme.eligibility ?? [];\n\n const getDaysRemaining = () => {\n if (!scheme.applicationDeadline) return null;\n const deadlineTime = new Date(`${scheme.applicationDeadline.slice(0, 10)}T12:00:00`).getTime();\n const todayTime = new Date(`${todayLocalDate()}T12:00:00`).getTime();\n return Math.max(0, Math.round((deadlineTime - todayTime) / (1000 * 60 * 60 * 24)));\n };\n\n const daysRemaining = getDaysRemaining();\n const effectiveStatus = getEffectiveSchemeStatus(scheme, todayLocalDate());\n const canApply = isAcceptingSchemeApplications(scheme, todayLocalDate());\n\n const openApplication = () => {\n if (!canApply) {\n const expired = effectiveStatus === 'expired';\n toast({\n title: expired\n ? t('healthybowl.governmentSchemes.schemeDetails.toast.schemeExpired.title', 'Scheme Expired')\n : t('healthybowl.governmentSchemes.schemeDetails.toast.schemeClosed.title', 'Scheme Closed'),\n description: expired\n ? t(\n 'healthybowl.governmentSchemes.schemeDetails.toast.schemeExpired.message',\n 'The application deadline for this scheme has passed.'\n )\n : t(\n 'healthybowl.governmentSchemes.schemeDetails.toast.schemeClosed.message',\n 'This scheme is no longer accepting applications.'\n ),\n variant: 'error',\n });\n return;\n }\n setShowApplyModal(true);\n };\n\n const handleSubmitApplication = async () => {\n if (!canApply) {\n setShowApplyModal(false);\n openApplication();\n return;\n }\n if (submitting) return; // guard against a fast double-click firing before the button disables\n if (!applicationForm.applicantName.trim() || !applicationForm.farmName.trim()) {\n toast({\n title: t('healthybowl.governmentSchemes.schemeDetails.toast.requiredFields.title', 'Required Fields Missing'),\n description: t(\n 'healthybowl.governmentSchemes.schemeDetails.toast.requiredFields.message',\n 'Please fill in all required fields.'\n ),\n variant: 'error',\n });\n return;\n }\n if (!applicationForm.declaration) {\n toast({\n title: t('healthybowl.governmentSchemes.schemeDetails.toast.declarationRequired.title', 'Declaration Required'),\n description: t(\n 'healthybowl.governmentSchemes.schemeDetails.toast.declarationRequired.message',\n 'Please accept the declaration to proceed.'\n ),\n variant: 'error',\n });\n return;\n }\n setSubmitting(true);\n try {\n const docsReady =\n scheme.requiredDocuments.filter((document) => readyDocuments.has(document)).join(', ') || 'none';\n const farmMeta = [applicationForm.farmSize.trim(), applicationForm.farmLocation.trim()]\n .filter(Boolean)\n .join(', ');\n // Every submit goes through the offline outbox (BOFF-6179), online or not.\n // One path is what makes the server's idempotency key meaningful: a retry\n // after a dropped connection returns the original application rather than\n // lodging a second one. `schemeName` and `status` are deliberately not\n // sent — the resolver ignores both, and a client-invented status would\n // claim an authority the client does not have.\n const outcome = await queueSchemeApplication(\n {\n schemeId: scheme.id,\n applicantName: applicationForm.applicantName.trim(),\n farmName: applicationForm.farmName.trim(),\n declarationAccepted: true,\n notes: `Applicant: ${applicationForm.applicantName.trim()}; Farm: ${applicationForm.farmName.trim()}${\n farmMeta ? ` (${farmMeta})` : ''\n }; Documents ready: ${docsReady}`,\n },\n scheme.title\n );\n\n if (outcome.status === 'FAILED') {\n // The server declined. Say so and keep the form open so the farmer can\n // correct it — closing the modal here would hide the reason.\n toast({\n title: t('healthybowl.governmentSchemes.schemeDetails.toast.submitFailed.title', 'Submission failed'),\n description: outcome.message,\n variant: 'error',\n });\n return;\n }\n\n if (outcome.status === 'SYNCED') {\n toast({\n title: t('healthybowl.governmentSchemes.schemeDetails.toast.submitted.title', 'Application Submitted'),\n description: t(\n 'healthybowl.governmentSchemes.schemeDetails.toast.submitted.message',\n 'Your application for {{schemeTitle}} has been submitted successfully.',\n { schemeTitle: scheme.title }\n ),\n variant: 'success',\n });\n // The outbox writes straight to the gateway, bypassing the Apollo cache\n // that feeds this page — without this the new application is invisible\n // until a reload.\n void refetch();\n } else {\n toast({\n title: t('healthybowl.governmentSchemes.schemeDetails.toast.queued.title', 'Saved — will submit when online'),\n description: t(\n 'healthybowl.governmentSchemes.schemeDetails.toast.queued.message',\n 'Your application for {{schemeTitle}} is saved on this device and will be submitted automatically when you have a connection. You can see it under Pending Sync.',\n { schemeTitle: scheme.title }\n ),\n variant: 'info',\n });\n }\n\n setShowApplyModal(false);\n setApplicationForm({\n applicantName: '',\n farmName: '',\n farmSize: '',\n farmLocation: '',\n declaration: false,\n });\n setReadyDocuments(new Set());\n } catch (err) {\n // Don't surface raw resolver/DB error text to users — log it, show a generic message.\n console.error('Scheme application submission failed', err);\n toast({\n title: t('healthybowl.governmentSchemes.schemeDetails.toast.submitFailed.title', 'Submission failed'),\n description: t(\n 'healthybowl.governmentSchemes.schemeDetails.toast.submitFailed.message',\n 'Something went wrong while submitting your application. Please try again or contact support.'\n ),\n variant: 'error',\n });\n } finally {\n setSubmitting(false);\n }\n };\n\n return (\n <PageLayout\n title={scheme.title}\n description={scheme.department}\n actions={\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => navigate(-1)}\n className=\"gap-1 text-text-secondary hover:text-text-primary\"\n >\n <ArrowLeft className=\"h-4 w-4\" /> {t('healthybowl.common.back', 'Back')}\n </Button>\n }\n purpose=\"Everything you need to decide on one government scheme — what it offers, who qualifies, what documents you'll need, and how to apply. Read it through, then apply right here if it fits your farm.\"\n nextSteps={[\n {\n id: 'apply',\n label: t('healthybowl.governmentSchemes.schemeDetails.nextSteps.apply.label', 'Apply for this scheme'),\n description: t(\n 'healthybowl.governmentSchemes.schemeDetails.nextSteps.apply.desc',\n 'Start your application once you’ve checked the eligibility.'\n ),\n onClick: openApplication,\n },\n {\n id: 'track',\n label: t('healthybowl.governmentSchemes.schemeDetails.nextSteps.track.label', 'Track your applications'),\n description: t(\n 'healthybowl.governmentSchemes.schemeDetails.nextSteps.track.desc',\n 'Follow the status of schemes you’ve already applied to.'\n ),\n href: buildPath('government-schemes/applications'),\n },\n {\n id: 'discover',\n label: t('healthybowl.governmentSchemes.schemeDetails.nextSteps.discover.label', 'Find more schemes'),\n description: t(\n 'healthybowl.governmentSchemes.schemeDetails.nextSteps.discover.desc',\n 'Browse other programs your farm may qualify for.'\n ),\n href: buildPath('government-schemes/discover'),\n },\n ]}\n nextStepsKey=\"healthybowl-scheme-detail\"\n >\n {/* Breadcrumbs */}\n <Breadcrumbs\n items={[\n {\n label: t('healthybowl.governmentSchemes.schemeDetails.breadcrumbs.governmentSchemes', 'Government Schemes'),\n href: buildPath('government-schemes'),\n },\n {\n label: t('healthybowl.governmentSchemes.schemeDetails.breadcrumbs.schemeDiscovery', 'Scheme Discovery'),\n href: buildPath('government-schemes/discover'),\n },\n { label: scheme.title },\n ]}\n />\n\n {/* Scheme Header Card */}\n <GlassCard treatment=\"glass\" glow className=\"border-border-seam p-6\">\n <div className=\"flex items-start justify-between\">\n <div className=\"flex items-center gap-3\">\n <div className=\"rounded-md bg-bg-sunken p-2\">\n <Landmark className=\"h-6 w-6 text-text-secondary\" />\n </div>\n <div>\n <h2 className=\"text-lg font-semibold text-text-primary\">{scheme.title}</h2>\n <p className=\"text-sm text-text-secondary\">{scheme.department}</p>\n <div className=\"mt-2 flex items-center gap-2\">\n <StatusBadge label={effectiveStatus.replace(/_/g, ' ')} variant={statusVariant(effectiveStatus)} />\n <StatusBadge label={scheme.category} variant={categoryVariant(scheme.category)} />\n </div>\n </div>\n </div>\n </div>\n\n {/* Key Metrics */}\n <div className=\"mt-5 grid gap-3 sm:grid-cols-3\">\n {scheme.maxAmount && (\n <div className=\"rounded-md bg-bg-sunken p-4\">\n <div className=\"flex items-center gap-2\">\n <DollarSign className=\"h-4 w-4 text-text-secondary\" />\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.governmentSchemes.schemeDetails.metrics.maxAmount.label', 'Maximum Amount')}\n </p>\n </div>\n <p className=\"mt-1 text-xl font-bold text-text-primary\">\n {formatCurrency(scheme.maxAmount, scheme.currency)}\n </p>\n </div>\n )}\n {scheme.applicationDeadline && (\n <div className=\"rounded-md bg-bg-sunken p-4\">\n <div className=\"flex items-center gap-2\">\n <CalendarDays className=\"h-4 w-4 text-text-secondary\" />\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.governmentSchemes.schemeDetails.metrics.deadline.label', 'Application Deadline')}\n </p>\n </div>\n <p className=\"mt-1 text-xl font-bold text-text-primary\">{formatDate(scheme.applicationDeadline)}</p>\n </div>\n )}\n {daysRemaining != null && (\n <div className={cn('rounded-md p-4', daysRemaining <= 30 ? 'bg-bg-sunken' : 'bg-bg-surface')}>\n <div className=\"flex items-center gap-2\">\n <Clock className=\"h-4 w-4 text-text-secondary\" />\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.governmentSchemes.schemeDetails.metrics.daysRemaining.label', 'Days Remaining')}\n </p>\n </div>\n <p className=\"mt-1 text-xl font-bold text-text-primary\">\n {daysRemaining === 1\n ? t('healthybowl.governmentSchemes.schemeDetails.metrics.daysRemaining.valueOne', '{{count}} day', {\n count: daysRemaining,\n })\n : t(\n 'healthybowl.governmentSchemes.schemeDetails.metrics.daysRemaining.valueOther',\n '{{count}} days',\n { count: daysRemaining }\n )}\n </p>\n </div>\n )}\n </div>\n </GlassCard>\n\n {/* Description */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {t('healthybowl.governmentSchemes.schemeDetails.sections.description.title', 'Description')}\n </h3>\n <p className=\"mt-2 text-sm leading-relaxed text-text-secondary\">{scheme.description}</p>\n </div>\n\n {/* Benefits */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {t('healthybowl.governmentSchemes.schemeDetails.sections.benefits.title', 'Benefits')}\n </h3>\n <p className=\"mt-2 text-sm leading-relaxed text-text-secondary\">{scheme.benefits}</p>\n </div>\n\n {/* Eligibility Requirements */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {t(\n 'healthybowl.governmentSchemes.schemeDetails.sections.eligibility.requirementsTitle',\n 'Eligibility Requirements'\n )}\n </h3>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t(\n 'healthybowl.governmentSchemes.schemeDetails.sections.eligibility.requirementsHelper',\n 'Review each requirement and confirm you qualify before applying.'\n )}\n </p>\n {/* BOFF-6110 — the verdict from the farm's own data, when the scheme carries structured\n criteria. Absent or still loading, the published requirements stand alone exactly as\n before. */}\n {eligibility && eligibility.criteria.length > 0 && (\n <div\n className={`mt-4 rounded-md border p-3 ${\n eligibility.outcome === 'ELIGIBLE'\n ? 'border-success/40 bg-success/10'\n : eligibility.outcome === 'NOT_ELIGIBLE'\n ? 'border-status-error-bg/40 bg-status-error-bg/10'\n : 'border-border-subtle bg-bg-sunken/50'\n }`}\n >\n <p className=\"text-sm font-medium text-text-primary\">{eligibility.summary}</p>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t(\n 'healthybowl.governmentSchemes.schemeDetails.sections.eligibility.checkedAgainstFarm',\n 'Checked against your farm records. Always confirm against the scheme’s own wording before applying.'\n )}\n </p>\n </div>\n )}\n\n <div className=\"mt-4 space-y-3\">\n {eligibility && eligibility.criteria.length > 0\n ? eligibility.criteria.map((criterion) => (\n <div\n key={criterion.id}\n className=\"flex items-start gap-3 rounded-md border border-border-subtle bg-bg-sunken/50 p-3\"\n >\n {/* The verdict is carried by icon shape and colour, so it needs a text label\n too — without one every row reads identically to a screen reader, which\n would strip the whole feature of meaning for those users. */}\n {criterion.verdict === 'MET' ? (\n <CheckCircle2\n role=\"img\"\n aria-label={t('healthybowl.governmentSchemes.schemeDetails.eligibility.verdict.met', 'Met')}\n className=\"mt-0.5 h-4 w-4 shrink-0 text-success\"\n />\n ) : criterion.verdict === 'UNMET' ? (\n <XCircle\n role=\"img\"\n aria-label={t('healthybowl.governmentSchemes.schemeDetails.eligibility.verdict.unmet', 'Not met')}\n className=\"mt-0.5 h-4 w-4 shrink-0 text-status-error-bg\"\n />\n ) : (\n <HelpCircle\n role=\"img\"\n aria-label={t(\n 'healthybowl.governmentSchemes.schemeDetails.eligibility.verdict.unknown',\n 'Needs checking'\n )}\n className=\"mt-0.5 h-4 w-4 shrink-0 text-text-secondary\"\n />\n )}\n <div className=\"min-w-0\">\n <span className=\"text-sm text-text-primary\">{criterion.label}</span>\n {/* The reason is what keeps an UNKNOWN honest — it says WHY we cannot tell,\n rather than leaving a farmer to read it as a refusal. Omitted when empty so\n it cannot render as a stray gap. */}\n {criterion.reason ? (\n <span className=\"mt-0.5 block text-xs text-text-secondary\">{criterion.reason}</span>\n ) : null}\n </div>\n </div>\n ))\n : eligibilityRequirements.map((label) => (\n <div\n key={label}\n className=\"flex items-center gap-3 rounded-md border border-border-subtle bg-bg-sunken/50 p-3\"\n >\n <Circle className=\"h-4 w-4 shrink-0 text-text-secondary\" />\n <span className=\"text-sm text-text-primary\">{label}</span>\n </div>\n ))}\n </div>\n </div>\n\n {/* Canonical scheme-owned document requirements */}\n <section\n data-testid=\"scheme-required-documents\"\n className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\"\n aria-labelledby=\"scheme-required-documents\"\n >\n <h3 id=\"scheme-required-documents\" className=\"text-sm font-semibold text-text-primary\">\n {t('healthybowl.governmentSchemes.schemeDetails.sections.documents.title', 'Required Documents')}\n </h3>\n {scheme.requiredDocuments.length === 0 ? (\n <p className=\"mt-2 text-sm text-text-secondary\">\n {t(\n 'healthybowl.governmentSchemes.schemeDetails.sections.documents.none',\n 'The scheme provider has not listed any required documents.'\n )}\n </p>\n ) : (\n <ul className=\"mt-3 space-y-2\">\n {scheme.requiredDocuments.map((document) => (\n <li key={document} className=\"flex items-start gap-2 text-sm text-text-secondary\">\n <CheckCircle2 className=\"mt-0.5 h-4 w-4 shrink-0 text-success\" />\n <span>{document}</span>\n </li>\n ))}\n </ul>\n )}\n </section>\n\n {!canApply ? (\n <div\n role=\"status\"\n data-testid=\"scheme-application-blocked\"\n className=\"rounded-md border border-border-subtle bg-bg-sunken p-4\"\n >\n <p className=\"text-sm font-medium text-text-primary\">\n {effectiveStatus === 'expired'\n ? t('healthybowl.governmentSchemes.schemeDetails.expired.title', 'Application deadline has passed')\n : t('healthybowl.governmentSchemes.schemeDetails.closed.title', 'Applications are closed')}\n </p>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {effectiveStatus === 'expired'\n ? t(\n 'healthybowl.governmentSchemes.schemeDetails.expired.description',\n 'This scheme has expired. You can still review its requirements and benefits.'\n )\n : t(\n 'healthybowl.governmentSchemes.schemeDetails.closed.description',\n 'This scheme is no longer accepting applications. You can still review its requirements and benefits.'\n )}\n </p>\n </div>\n ) : null}\n\n {/* Apply Button */}\n <div className=\"flex gap-3\">\n <Button data-testid=\"scheme-apply-button\" onClick={openApplication}>\n {t('healthybowl.governmentSchemes.schemeDetails.actions.apply', 'Apply for This Scheme')}\n </Button>\n <Button variant=\"outline\" onClick={() => navigate(buildPath('government-schemes/discover'))}>\n {t('healthybowl.governmentSchemes.schemeDetails.actions.backToSchemes', 'Back to Schemes')}\n </Button>\n </div>\n\n {/* FAQ Accordion */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {t('healthybowl.governmentSchemes.schemeDetails.faq.title', 'Frequently Asked Questions')}\n </h3>\n <div className=\"mt-4 space-y-2\">\n {schemeFaqs.map((faq, i) => (\n <div key={i} className=\"rounded-md border border-border-subtle\">\n <Button\n variant=\"ghost\"\n onClick={() => setExpandedFaq(expandedFaq === i ? null : i)}\n className=\"h-auto w-full justify-between whitespace-normal px-4 py-3 text-start font-medium text-text-primary\"\n >\n {faq.question}\n {expandedFaq === i ? (\n <ChevronUp className=\"h-4 w-4 shrink-0 text-text-secondary\" />\n ) : (\n <ChevronDown className=\"h-4 w-4 shrink-0 text-text-secondary\" />\n )}\n </Button>\n {expandedFaq === i && (\n <div className=\"border-t border-border-subtle px-4 py-3 text-sm leading-relaxed text-text-secondary\">\n {faq.answer}\n </div>\n )}\n </div>\n ))}\n </div>\n </div>\n\n {/* Related Schemes */}\n {relatedSchemes.length > 0 && (\n <div>\n <h3 className=\"mb-3 text-sm font-semibold text-text-primary\">\n {t('healthybowl.governmentSchemes.schemeDetails.related.title', 'Related Schemes ({{category}})', {\n category: scheme.category,\n })}\n </h3>\n <div className=\"grid gap-4 sm:grid-cols-2\">\n {relatedSchemes.map((related) => (\n <button\n key={related.id}\n type=\"button\"\n onClick={() => navigate(buildPath(`government-schemes/schemes/${related.id}`))}\n className=\"flex items-start gap-3 rounded-lg border border-border-subtle bg-bg-surface p-4 text-start transition-colors hover:bg-bg-sunken/50\"\n >\n <Landmark className=\"mt-0.5 h-5 w-5 shrink-0 text-text-secondary\" />\n <div className=\"flex-1\">\n <p className=\"text-sm font-medium text-text-primary\">{related.title}</p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">{related.department}</p>\n <div className=\"mt-2 flex items-center gap-2\">\n <StatusBadge\n label={getEffectiveSchemeStatus(related, todayLocalDate()).replace(/_/g, ' ')}\n variant={statusVariant(getEffectiveSchemeStatus(related, todayLocalDate()))}\n />\n {related.maxAmount && (\n <span className=\"text-xs text-text-secondary\">\n {t('healthybowl.governmentSchemes.schemeDetails.related.upTo', 'Up to {{amount}}', {\n amount: formatCurrency(related.maxAmount, related.currency),\n })}\n </span>\n )}\n </div>\n </div>\n </button>\n ))}\n </div>\n </div>\n )}\n\n {/* Application Modal */}\n <Modal\n open={showApplyModal && canApply}\n onClose={() => {\n if (!submitting) setShowApplyModal(false);\n }}\n title={t('healthybowl.governmentSchemes.schemeDetails.modal.title', 'Apply for Scheme')}\n description={scheme.title}\n size=\"lg\"\n footer={\n <>\n <Button variant=\"outline\" onClick={() => setShowApplyModal(false)} disabled={submitting}>\n {t('healthybowl.common.cancel', 'Cancel')}\n </Button>\n <Button onClick={handleSubmitApplication} disabled={submitting}>\n {submitting\n ? t('healthybowl.governmentSchemes.schemeDetails.modal.submitting', 'Submitting...')\n : t('healthybowl.governmentSchemes.schemeDetails.modal.submit', 'Submit Application')}\n </Button>\n </>\n }\n >\n <div className=\"space-y-4\">\n {/* Applicant Details */}\n <div>\n <h4 className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.governmentSchemes.schemeDetails.form.applicant.title', 'Applicant Details')}\n </h4>\n <div className=\"mt-2 space-y-3\">\n <div>\n <label htmlFor=\"scheme-applicant-name\" className=\"block text-xs font-medium text-text-secondary\">\n {t('healthybowl.governmentSchemes.schemeDetails.form.fields.fullName.label', 'Full Name *')}\n </label>\n <input\n id=\"scheme-applicant-name\"\n type=\"text\"\n value={applicationForm.applicantName}\n onChange={(e) => setApplicationForm({ ...applicationForm, applicantName: e.target.value })}\n placeholder={t(\n 'healthybowl.governmentSchemes.schemeDetails.form.fields.fullName.placeholder',\n 'Enter your full name'\n )}\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary\"\n />\n </div>\n </div>\n </div>\n\n {/* Farm Details */}\n <div>\n <h4 className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.governmentSchemes.schemeDetails.form.farm.title', 'Farm Details')}\n </h4>\n <div className=\"mt-2 grid gap-3 sm:grid-cols-2\">\n <div>\n <label htmlFor=\"scheme-farm-name\" className=\"block text-xs font-medium text-text-secondary\">\n {t('healthybowl.governmentSchemes.schemeDetails.form.fields.farmName.label', 'Farm Name *')}\n </label>\n <input\n id=\"scheme-farm-name\"\n type=\"text\"\n value={applicationForm.farmName}\n onChange={(e) => setApplicationForm({ ...applicationForm, farmName: e.target.value })}\n placeholder={t(\n 'healthybowl.governmentSchemes.schemeDetails.form.fields.farmName.placeholder',\n 'Your farm name'\n )}\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary\"\n />\n </div>\n <div>\n <label className=\"block text-xs font-medium text-text-secondary\">\n {t('healthybowl.governmentSchemes.schemeDetails.form.fields.farmSize.label', 'Farm Size (acres)')}\n </label>\n <input\n type=\"text\"\n value={applicationForm.farmSize}\n onChange={(e) => setApplicationForm({ ...applicationForm, farmSize: e.target.value })}\n placeholder={t(\n 'healthybowl.governmentSchemes.schemeDetails.form.fields.farmSize.placeholder',\n 'e.g., 50'\n )}\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary\"\n />\n </div>\n <div className=\"sm:col-span-2\">\n <label className=\"block text-xs font-medium text-text-secondary\">\n {t('healthybowl.governmentSchemes.schemeDetails.form.fields.farmLocation.label', 'Farm Location')}\n </label>\n <input\n type=\"text\"\n value={applicationForm.farmLocation}\n onChange={(e) => setApplicationForm({ ...applicationForm, farmLocation: e.target.value })}\n placeholder={t(\n 'healthybowl.governmentSchemes.schemeDetails.form.fields.farmLocation.placeholder',\n 'County, State'\n )}\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary\"\n />\n </div>\n </div>\n </div>\n\n {/* Documents Checklist */}\n <div>\n <h4 className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.governmentSchemes.schemeDetails.form.documents.title', 'Documents Checklist')}\n </h4>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {t(\n 'healthybowl.governmentSchemes.schemeDetails.form.documents.helper',\n 'Confirm you have the following documents ready for upload'\n )}\n </p>\n <div className=\"mt-2 space-y-2\">\n {scheme.requiredDocuments.map((document, index) => {\n const inputId = `scheme-document-${index}`;\n return (\n <label\n key={document}\n htmlFor={inputId}\n className=\"flex items-center gap-3 rounded-md border border-border-subtle p-3 transition-colors hover:bg-bg-sunken/50\"\n >\n <input\n id={inputId}\n type=\"checkbox\"\n checked={readyDocuments.has(document)}\n onChange={(event) => {\n setReadyDocuments((current) => {\n const next = new Set(current);\n if (event.target.checked) next.add(document);\n else next.delete(document);\n return next;\n });\n }}\n className=\"h-4 w-4 rounded border-border-subtle\"\n />\n <div className=\"flex items-center gap-2\">\n <Upload className=\"h-3.5 w-3.5 text-text-secondary\" />\n <span className=\"text-sm text-text-primary\">{document}</span>\n </div>\n </label>\n );\n })}\n </div>\n </div>\n\n {/* Declaration */}\n <div className=\"rounded-md border border-border-subtle bg-bg-sunken/50 p-4\">\n <label htmlFor=\"scheme-declaration\" className=\"flex items-start gap-3\">\n <input\n id=\"scheme-declaration\"\n type=\"checkbox\"\n checked={applicationForm.declaration}\n onChange={(e) => setApplicationForm({ ...applicationForm, declaration: e.target.checked })}\n className=\"mt-0.5 h-4 w-4 rounded border-border-subtle\"\n />\n <span className=\"text-xs text-text-secondary\">\n {t(\n 'healthybowl.governmentSchemes.schemeDetails.form.declaration.text',\n 'I declare that the information provided is true and accurate. I understand that providing false information may result in disqualification and legal action.'\n )}\n </span>\n </label>\n </div>\n </div>\n </Modal>\n\n <ToastContainer toasts={toasts} onDismiss={dismiss} />\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AA6BA,IAAM,KAAiB,MAAc;CACnC,QAAQ,GAAR;EACE,KAAK,QACH,OAAO;EACT,KAAK,gBACH,OAAO;EACT,KAAK;EACL,KAAK,WACH,OAAO;EACT,SACE,OAAO;CACX;AACF,GAEM,KAAmB,MAAc;CACrC,QAAQ,GAAR;EACE,KAAK,WACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK,SACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,SACE,OAAO;CACX;AACF,GAOa,UAA0B;CACrC,IAAM,EAAE,sBAAmB,WAAQ,aAAU,eAAY,EAAmB,GAEtE,EAAE,8BAA2B,GAAe,GAE5C,EAAE,gBAAa,GAAgC,GAG/C,EAAE,mBAAgB,GAAqB,CAAQ,GAC/C,IAAW,GAAY,GACvB,EAAE,iBAAc,GAAY,GAC5B,EAAE,WAAQ,UAAO,gBAAY,EAAS,GACtC,EAAE,SAAM,GAAQ,GAEhB,KAAwB,QACtB;EACJ;GACE,UAAU,EACR,uEACA,oDACF;GACA,QAAQ,EACN,qEACA,sJACF;EACF;EACA;GACE,UAAU,EACR,sEACA,qCACF;GACA,QAAQ,EACN,oEACA,2MACF;EACF;EACA;GACE,UAAU,EACR,iFACA,qDACF;GACA,QAAQ,EACN,+EACA,uKACF;EACF;EACA;GACE,UAAU,EACR,yEACA,qCACF;GACA,QAAQ,EACN,uEACA,2MACF;EACF;CACF,GACA,CAAC,CAAC,CACJ,GACM,CAAC,GAAa,MAAkB,EAA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,kBAAC,QAAD;YAAM,WAAU;sBAA6B;WAAe,CAAA,CACzD;YACA;YAtBA,CAsBA;QAEX,CAAC;OACE,CAAA;MACF,EAAA,CAAA;MAGL,kBAAC,OAAD;OAAK,WAAU;iBACb,kBAAC,SAAD;QAAO,SAAQ;QAAqB,WAAU;kBAA9C,CACE,kBAAC,SAAD;SACE,IAAG;SACH,MAAK;SACL,SAAS,EAAgB;SACzB,WAAW,MAAM,EAAmB;UAAE,GAAG;UAAiB,aAAa,EAAE,OAAO;SAAQ,CAAC;SACzF,WAAU;QACX,CAAA,GACD,kBAAC,QAAD;SAAM,WAAU;mBACb,EACC,qEACA,8JACF;QACI,CAAA,CACD;;MACJ,CAAA;KACF;;GACA,CAAA;GAEP,kBAAC,GAAD;IAAwB;IAAQ,WAAW;GAAU,CAAA;EAC3C;;AAEhB"}
1
+ {"version":3,"file":"SchemeDetailsPage.js","names":[],"sources":["../../../../src/healthybowl/pages/government-schemes/SchemeDetailsPage.tsx"],"sourcesContent":["import { useState, useMemo } from 'react';\nimport { useParams, useNavigate } from 'react-router';\nimport {\n Landmark,\n Circle,\n CheckCircle2,\n XCircle,\n HelpCircle,\n ArrowLeft,\n CalendarDays,\n DollarSign,\n Clock,\n ChevronDown,\n ChevronUp,\n Upload,\n AlertCircle,\n} from 'lucide-react';\nimport { PageLayout, StatusBadge, Breadcrumbs, EmptyState, ErrorState, PageLoader, Modal } from '../../components';\nimport { ToastContainer } from '../../components/Toast';\nimport { GlassCard, Button } from '@burdenoff/fe-libs/ui';\nimport { useToast } from '../../hooks/useToast';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport { useHealthyBowlData } from '../../hooks/useHealthyBowlData';\nimport { useSchemeEligibility } from '../../hooks/useSchemeEligibility';\nimport { useOfflineSync } from '../../offline/OfflineSyncProvider';\nimport { formatCurrency, formatDate, cn, todayLocalDate } from '../../utils/helpers';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { useSaveToFiles } from '@burdenoff/fe-libs/storage';\nimport {\n canSubmitSchemeApplication,\n documentForSlot,\n missingRequiredSchemeDocuments,\n removeSchemeDocument,\n SCHEME_DOCUMENT_SLOT_SPECS,\n setSchemeDocument,\n type SchemeDocumentSlot,\n type UploadedSchemeDocument,\n} from './schemeDocumentSlots';\nimport { getEffectiveSchemeStatus, isAcceptingSchemeApplications } from './schemeDiscoveryFilters';\n\nconst statusVariant = (s: string) => {\n switch (s) {\n case 'open':\n return 'success' as const;\n case 'closing_soon':\n return 'warning' as const;\n case 'closed':\n case 'expired':\n return 'error' as const;\n default:\n return 'default' as const;\n }\n};\n\nconst categoryVariant = (c: string) => {\n switch (c) {\n case 'subsidy':\n return 'success' as const;\n case 'credit':\n return 'info' as const;\n case 'insurance':\n return 'warning' as const;\n case 'training':\n return 'default' as const;\n case 'grant':\n return 'success' as const;\n case 'equipment':\n return 'muted' as const;\n default:\n return 'muted' as const;\n }\n};\n\ninterface FaqItem {\n question: string;\n answer: string;\n}\n\nexport const SchemeDetailsPage = () => {\n const { governmentSchemes, errors, loadings, refetch } = useHealthyBowlData();\n // The write is owned by the offline outbox, not Apollo (BOFF-6179).\n const { queueSchemeApplication } = useOfflineSync();\n // BOFF-6111 — real uploads replace the four \"confirm you have this\" checkboxes. The file goes to\n // wspace-files-svc while the farmer is still filling in the form, so a queued application carries\n // a real reference: the outbox replays a mutation, not a file transfer.\n const { save: saveToFiles } = useSaveToFiles();\n const [documents, setDocuments] = useState<UploadedSchemeDocument[]>([]);\n const [uploadingSlot, setUploadingSlot] = useState<SchemeDocumentSlot | null>(null);\n\n const { schemeId } = useParams<{ schemeId: string }>();\n // BOFF-6110 — the met/unmet verdict from this workspace's own farm data. Advisory: the panel\n // degrades to the scheme's published criteria if the check fails or the scheme has no rules.\n const { eligibility } = useSchemeEligibility(schemeId);\n const navigate = useNavigate();\n const { buildPath } = useBasePath();\n const { toasts, toast, dismiss } = useToast();\n const { t } = useI18n();\n\n const schemeFaqs: FaqItem[] = useMemo(\n () => [\n {\n question: t(\n 'healthybowl.governmentSchemes.schemeDetails.faq.reviewTime.question',\n 'How long does the application review process take?'\n ),\n answer: t(\n 'healthybowl.governmentSchemes.schemeDetails.faq.reviewTime.answer',\n 'Typically, applications are reviewed within 2-4 weeks of submission. You will receive status updates via email and on the Application Tracking page.'\n ),\n },\n {\n question: t(\n 'healthybowl.governmentSchemes.schemeDetails.faq.documents.question',\n 'What documents do I need to submit?'\n ),\n answer: t(\n 'healthybowl.governmentSchemes.schemeDetails.faq.documents.answer',\n 'Required documents include farm ownership or lease proof, valid ID, bank account details, organic certification (if applicable), and any scheme-specific documents mentioned in the eligibility criteria.'\n ),\n },\n {\n question: t(\n 'healthybowl.governmentSchemes.schemeDetails.faq.pendingCertification.question',\n 'Can I apply if my organic certification is pending?'\n ),\n answer: t(\n 'healthybowl.governmentSchemes.schemeDetails.faq.pendingCertification.answer',\n 'For schemes requiring organic certification, you may apply during the transition period. Provide your transition plan and any in-process certification documentation.'\n ),\n },\n {\n question: t(\n 'healthybowl.governmentSchemes.schemeDetails.faq.disbursement.question',\n 'How will the benefits be disbursed?'\n ),\n answer: t(\n 'healthybowl.governmentSchemes.schemeDetails.faq.disbursement.answer',\n 'Approved benefits are transferred directly to your registered bank account. The disbursement typically occurs within 30 days of approval. You will receive a notification when the transfer is initiated.'\n ),\n },\n ],\n [t]\n );\n const [expandedFaq, setExpandedFaq] = useState<number | null>(null);\n const [showApplyModal, setShowApplyModal] = useState(false);\n const [submitting, setSubmitting] = useState(false);\n const [applicationForm, setApplicationForm] = useState({\n applicantName: '',\n farmName: '',\n farmSize: '',\n farmLocation: '',\n declaration: false,\n });\n\n const scheme = governmentSchemes.find((s) => s.id === schemeId);\n\n const relatedSchemes = useMemo(() => {\n if (!scheme) return [];\n return governmentSchemes.filter((s) => s.id !== scheme.id && s.category === scheme.category);\n }, [governmentSchemes, scheme]);\n\n if (!scheme) {\n return (\n <PageLayout\n title={t('healthybowl.governmentSchemes.schemeDetails.notFound.title', 'Scheme Not Found')}\n description={t(\n 'healthybowl.governmentSchemes.schemeDetails.notFound.description',\n 'The requested scheme could not be found'\n )}\n >\n {loadings.government ? (\n <PageLoader />\n ) : errors.government ? (\n <ErrorState onRetry={refetch} />\n ) : (\n <EmptyState\n icon={<AlertCircle className=\"h-12 w-12\" />}\n title={t('healthybowl.governmentSchemes.schemeDetails.notFound.emptyState.title', 'Scheme Not Found')}\n description={t(\n 'healthybowl.governmentSchemes.schemeDetails.notFound.emptyState.description',\n 'The government scheme you are looking for does not exist or may have been removed.'\n )}\n action={\n <Button onClick={() => navigate(buildPath('government-schemes/discover'))}>\n {t('healthybowl.governmentSchemes.schemeDetails.notFound.browseSchemes', 'Browse Schemes')}\n </Button>\n }\n />\n )}\n </PageLayout>\n );\n }\n\n // BOFF-6110 — the criteria the scheme publishes. Still shown verbatim and in full: the\n // scheme's own wording is the authority, and the structured check below only says which of\n // them this farm's data demonstrably satisfies.\n const eligibilityRequirements = scheme.eligibility ?? [];\n\n const getDaysRemaining = () => {\n if (!scheme.applicationDeadline) return null;\n const deadlineTime = new Date(`${scheme.applicationDeadline.slice(0, 10)}T12:00:00`).getTime();\n const todayTime = new Date(`${todayLocalDate()}T12:00:00`).getTime();\n return Math.max(0, Math.round((deadlineTime - todayTime) / (1000 * 60 * 60 * 24)));\n };\n\n const daysRemaining = getDaysRemaining();\n const effectiveStatus = getEffectiveSchemeStatus(scheme, todayLocalDate());\n const canApply = isAcceptingSchemeApplications(scheme, todayLocalDate());\n\n const openApplication = () => {\n if (!canApply) {\n const expired = effectiveStatus === 'expired';\n toast({\n title: expired\n ? t('healthybowl.governmentSchemes.schemeDetails.toast.schemeExpired.title', 'Scheme Expired')\n : t('healthybowl.governmentSchemes.schemeDetails.toast.schemeClosed.title', 'Scheme Closed'),\n description: expired\n ? t(\n 'healthybowl.governmentSchemes.schemeDetails.toast.schemeExpired.message',\n 'The application deadline for this scheme has passed.'\n )\n : t(\n 'healthybowl.governmentSchemes.schemeDetails.toast.schemeClosed.message',\n 'This scheme is no longer accepting applications.'\n ),\n variant: 'error',\n });\n return;\n }\n setShowApplyModal(true);\n };\n\n const handleUploadDocument = async (slot: SchemeDocumentSlot, file: File) => {\n setUploadingSlot(slot);\n try {\n const saved = await saveToFiles({\n source: {\n kind: 'blob',\n filename: file.name,\n mimeType: file.type || 'application/octet-stream',\n getBlob: async () => ({ blob: file, filename: file.name, mimeType: file.type || undefined }),\n },\n folderPath: '/HealthyBowl/SchemeApplication',\n });\n setDocuments((prev) =>\n setSchemeDocument(prev, {\n slot,\n fileId: saved.id,\n fileName: file.name,\n uploadedAt: new Date().toISOString(),\n })\n );\n } catch (err) {\n toast({\n title: t('healthybowl.governmentSchemes.schemeDetails.toast.uploadFailed.title', 'Upload failed'),\n description: err instanceof Error ? err.message : String(err),\n variant: 'error',\n });\n } finally {\n setUploadingSlot(null);\n }\n };\n\n const handleSubmitApplication = async () => {\n if (!canApply) {\n setShowApplyModal(false);\n openApplication();\n return;\n }\n if (submitting) return; // guard against a fast double-click firing before the button disables\n if (!applicationForm.applicantName.trim() || !applicationForm.farmName.trim()) {\n toast({\n title: t('healthybowl.governmentSchemes.schemeDetails.toast.requiredFields.title', 'Required Fields Missing'),\n description: t(\n 'healthybowl.governmentSchemes.schemeDetails.toast.requiredFields.message',\n 'Please fill in all required fields.'\n ),\n variant: 'error',\n });\n return;\n }\n if (!applicationForm.declaration) {\n toast({\n title: t('healthybowl.governmentSchemes.schemeDetails.toast.declarationRequired.title', 'Declaration Required'),\n description: t(\n 'healthybowl.governmentSchemes.schemeDetails.toast.declarationRequired.message',\n 'Please accept the declaration to proceed.'\n ),\n variant: 'error',\n });\n return;\n }\n // BOFF-6111 — the documents themselves, not a claim that they exist. Checked before queuing so\n // the outbox never holds an application the server would refuse.\n if (!canSubmitSchemeApplication(documents)) {\n const missing = missingRequiredSchemeDocuments(documents)\n .map((spec) => t(spec.labelKey, spec.labelFallback))\n .join(', ');\n toast({\n title: t('healthybowl.governmentSchemes.schemeDetails.toast.documentsRequired.title', 'Documents required'),\n description: t(\n 'healthybowl.governmentSchemes.schemeDetails.toast.documentsRequired.message',\n 'Upload these before submitting: {{missing}}.',\n { missing }\n ),\n variant: 'error',\n });\n return;\n }\n setSubmitting(true);\n try {\n const farmMeta = [applicationForm.farmSize.trim(), applicationForm.farmLocation.trim()]\n .filter(Boolean)\n .join(', ');\n // Every submit goes through the offline outbox (BOFF-6179), online or not.\n // One path is what makes the server's idempotency key meaningful: a retry\n // after a dropped connection returns the original application rather than\n // lodging a second one. `schemeName` and `status` are deliberately not\n // sent — the resolver ignores both, and a client-invented status would\n // claim an authority the client does not have.\n const outcome = await queueSchemeApplication(\n {\n schemeId: scheme.id,\n applicantName: applicationForm.applicantName.trim(),\n farmName: applicationForm.farmName.trim(),\n declarationAccepted: true,\n // Documents are structured evidence; the note remains only human-facing application context.\n notes: `Applicant: ${applicationForm.applicantName.trim()}; Farm: ${applicationForm.farmName.trim()}${\n farmMeta ? ` (${farmMeta})` : ''\n }`,\n documents: documents.map((doc) => ({\n slot: doc.slot,\n fileId: doc.fileId,\n fileName: doc.fileName,\n uploadedAt: doc.uploadedAt,\n })),\n },\n scheme.title\n );\n\n if (outcome.status === 'FAILED') {\n // The server declined. Say so and keep the form open so the farmer can\n // correct it — closing the modal here would hide the reason.\n toast({\n title: t('healthybowl.governmentSchemes.schemeDetails.toast.submitFailed.title', 'Submission failed'),\n description: outcome.message,\n variant: 'error',\n });\n return;\n }\n\n if (outcome.status === 'SYNCED') {\n toast({\n title: t('healthybowl.governmentSchemes.schemeDetails.toast.submitted.title', 'Application Submitted'),\n description: t(\n 'healthybowl.governmentSchemes.schemeDetails.toast.submitted.message',\n 'Your application for {{schemeTitle}} has been submitted successfully.',\n { schemeTitle: scheme.title }\n ),\n variant: 'success',\n });\n // The outbox writes straight to the gateway, bypassing the Apollo cache\n // that feeds this page — without this the new application is invisible\n // until a reload.\n void refetch();\n } else {\n toast({\n title: t('healthybowl.governmentSchemes.schemeDetails.toast.queued.title', 'Saved — will submit when online'),\n description: t(\n 'healthybowl.governmentSchemes.schemeDetails.toast.queued.message',\n 'Your application for {{schemeTitle}} is saved on this device and will be submitted automatically when you have a connection. You can see it under Pending Sync.',\n { schemeTitle: scheme.title }\n ),\n variant: 'info',\n });\n }\n\n setShowApplyModal(false);\n setApplicationForm({\n applicantName: '',\n farmName: '',\n farmSize: '',\n farmLocation: '',\n declaration: false,\n });\n // Uploaded evidence and readiness state belong only to this submitted application.\n setDocuments([]);\n } catch (err) {\n // Don't surface raw resolver/DB error text to users — log it, show a generic message.\n console.error('Scheme application submission failed', err);\n toast({\n title: t('healthybowl.governmentSchemes.schemeDetails.toast.submitFailed.title', 'Submission failed'),\n description: t(\n 'healthybowl.governmentSchemes.schemeDetails.toast.submitFailed.message',\n 'Something went wrong while submitting your application. Please try again or contact support.'\n ),\n variant: 'error',\n });\n } finally {\n setSubmitting(false);\n }\n };\n\n return (\n <PageLayout\n title={scheme.title}\n description={scheme.department}\n actions={\n <Button\n variant=\"ghost\"\n size=\"sm\"\n onClick={() => navigate(-1)}\n className=\"gap-1 text-text-secondary hover:text-text-primary\"\n >\n <ArrowLeft className=\"h-4 w-4\" /> {t('healthybowl.common.back', 'Back')}\n </Button>\n }\n purpose=\"Everything you need to decide on one government scheme — what it offers, who qualifies, what documents you'll need, and how to apply. Read it through, then apply right here if it fits your farm.\"\n nextSteps={[\n {\n id: 'apply',\n label: t('healthybowl.governmentSchemes.schemeDetails.nextSteps.apply.label', 'Apply for this scheme'),\n description: t(\n 'healthybowl.governmentSchemes.schemeDetails.nextSteps.apply.desc',\n 'Start your application once you’ve checked the eligibility.'\n ),\n onClick: openApplication,\n },\n {\n id: 'track',\n label: t('healthybowl.governmentSchemes.schemeDetails.nextSteps.track.label', 'Track your applications'),\n description: t(\n 'healthybowl.governmentSchemes.schemeDetails.nextSteps.track.desc',\n 'Follow the status of schemes you’ve already applied to.'\n ),\n href: buildPath('government-schemes/applications'),\n },\n {\n id: 'discover',\n label: t('healthybowl.governmentSchemes.schemeDetails.nextSteps.discover.label', 'Find more schemes'),\n description: t(\n 'healthybowl.governmentSchemes.schemeDetails.nextSteps.discover.desc',\n 'Browse other programs your farm may qualify for.'\n ),\n href: buildPath('government-schemes/discover'),\n },\n ]}\n nextStepsKey=\"healthybowl-scheme-detail\"\n >\n {/* Breadcrumbs */}\n <Breadcrumbs\n items={[\n {\n label: t('healthybowl.governmentSchemes.schemeDetails.breadcrumbs.governmentSchemes', 'Government Schemes'),\n href: buildPath('government-schemes'),\n },\n {\n label: t('healthybowl.governmentSchemes.schemeDetails.breadcrumbs.schemeDiscovery', 'Scheme Discovery'),\n href: buildPath('government-schemes/discover'),\n },\n { label: scheme.title },\n ]}\n />\n\n {/* Scheme Header Card */}\n <GlassCard treatment=\"glass\" glow className=\"border-border-seam p-6\">\n <div className=\"flex items-start justify-between\">\n <div className=\"flex items-center gap-3\">\n <div className=\"rounded-md bg-bg-sunken p-2\">\n <Landmark className=\"h-6 w-6 text-text-secondary\" />\n </div>\n <div>\n <h2 className=\"text-lg font-semibold text-text-primary\">{scheme.title}</h2>\n <p className=\"text-sm text-text-secondary\">{scheme.department}</p>\n <div className=\"mt-2 flex items-center gap-2\">\n <StatusBadge label={effectiveStatus.replace(/_/g, ' ')} variant={statusVariant(effectiveStatus)} />\n <StatusBadge label={scheme.category} variant={categoryVariant(scheme.category)} />\n </div>\n </div>\n </div>\n </div>\n\n {/* Key Metrics */}\n <div className=\"mt-5 grid gap-3 sm:grid-cols-3\">\n {scheme.maxAmount && (\n <div className=\"rounded-md bg-bg-sunken p-4\">\n <div className=\"flex items-center gap-2\">\n <DollarSign className=\"h-4 w-4 text-text-secondary\" />\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.governmentSchemes.schemeDetails.metrics.maxAmount.label', 'Maximum Amount')}\n </p>\n </div>\n <p className=\"mt-1 text-xl font-bold text-text-primary\">\n {formatCurrency(scheme.maxAmount, scheme.currency)}\n </p>\n </div>\n )}\n {scheme.applicationDeadline && (\n <div className=\"rounded-md bg-bg-sunken p-4\">\n <div className=\"flex items-center gap-2\">\n <CalendarDays className=\"h-4 w-4 text-text-secondary\" />\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.governmentSchemes.schemeDetails.metrics.deadline.label', 'Application Deadline')}\n </p>\n </div>\n <p className=\"mt-1 text-xl font-bold text-text-primary\">{formatDate(scheme.applicationDeadline)}</p>\n </div>\n )}\n {daysRemaining != null && (\n <div className={cn('rounded-md p-4', daysRemaining <= 30 ? 'bg-bg-sunken' : 'bg-bg-surface')}>\n <div className=\"flex items-center gap-2\">\n <Clock className=\"h-4 w-4 text-text-secondary\" />\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.governmentSchemes.schemeDetails.metrics.daysRemaining.label', 'Days Remaining')}\n </p>\n </div>\n <p className=\"mt-1 text-xl font-bold text-text-primary\">\n {daysRemaining === 1\n ? t('healthybowl.governmentSchemes.schemeDetails.metrics.daysRemaining.valueOne', '{{count}} day', {\n count: daysRemaining,\n })\n : t(\n 'healthybowl.governmentSchemes.schemeDetails.metrics.daysRemaining.valueOther',\n '{{count}} days',\n { count: daysRemaining }\n )}\n </p>\n </div>\n )}\n </div>\n </GlassCard>\n\n {/* Description */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {t('healthybowl.governmentSchemes.schemeDetails.sections.description.title', 'Description')}\n </h3>\n <p className=\"mt-2 text-sm leading-relaxed text-text-secondary\">{scheme.description}</p>\n </div>\n\n {/* Benefits */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {t('healthybowl.governmentSchemes.schemeDetails.sections.benefits.title', 'Benefits')}\n </h3>\n <p className=\"mt-2 text-sm leading-relaxed text-text-secondary\">{scheme.benefits}</p>\n </div>\n\n {/* Eligibility Requirements */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {t(\n 'healthybowl.governmentSchemes.schemeDetails.sections.eligibility.requirementsTitle',\n 'Eligibility Requirements'\n )}\n </h3>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t(\n 'healthybowl.governmentSchemes.schemeDetails.sections.eligibility.requirementsHelper',\n 'Review each requirement and confirm you qualify before applying.'\n )}\n </p>\n {/* BOFF-6110 — the verdict from the farm's own data, when the scheme carries structured\n criteria. Absent or still loading, the published requirements stand alone exactly as\n before. */}\n {eligibility && eligibility.criteria.length > 0 && (\n <div\n className={`mt-4 rounded-md border p-3 ${\n eligibility.outcome === 'ELIGIBLE'\n ? 'border-success/40 bg-success/10'\n : eligibility.outcome === 'NOT_ELIGIBLE'\n ? 'border-status-error-bg/40 bg-status-error-bg/10'\n : 'border-border-subtle bg-bg-sunken/50'\n }`}\n >\n <p className=\"text-sm font-medium text-text-primary\">{eligibility.summary}</p>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {t(\n 'healthybowl.governmentSchemes.schemeDetails.sections.eligibility.checkedAgainstFarm',\n 'Checked against your farm records. Always confirm against the scheme’s own wording before applying.'\n )}\n </p>\n </div>\n )}\n\n <div className=\"mt-4 space-y-3\">\n {eligibility && eligibility.criteria.length > 0\n ? eligibility.criteria.map((criterion) => (\n <div\n key={criterion.id}\n className=\"flex items-start gap-3 rounded-md border border-border-subtle bg-bg-sunken/50 p-3\"\n >\n {/* The verdict is carried by icon shape and colour, so it needs a text label\n too — without one every row reads identically to a screen reader, which\n would strip the whole feature of meaning for those users. */}\n {criterion.verdict === 'MET' ? (\n <CheckCircle2\n role=\"img\"\n aria-label={t('healthybowl.governmentSchemes.schemeDetails.eligibility.verdict.met', 'Met')}\n className=\"mt-0.5 h-4 w-4 shrink-0 text-success\"\n />\n ) : criterion.verdict === 'UNMET' ? (\n <XCircle\n role=\"img\"\n aria-label={t('healthybowl.governmentSchemes.schemeDetails.eligibility.verdict.unmet', 'Not met')}\n className=\"mt-0.5 h-4 w-4 shrink-0 text-status-error-bg\"\n />\n ) : (\n <HelpCircle\n role=\"img\"\n aria-label={t(\n 'healthybowl.governmentSchemes.schemeDetails.eligibility.verdict.unknown',\n 'Needs checking'\n )}\n className=\"mt-0.5 h-4 w-4 shrink-0 text-text-secondary\"\n />\n )}\n <div className=\"min-w-0\">\n <span className=\"text-sm text-text-primary\">{criterion.label}</span>\n {/* The reason is what keeps an UNKNOWN honest — it says WHY we cannot tell,\n rather than leaving a farmer to read it as a refusal. Omitted when empty so\n it cannot render as a stray gap. */}\n {criterion.reason ? (\n <span className=\"mt-0.5 block text-xs text-text-secondary\">{criterion.reason}</span>\n ) : null}\n </div>\n </div>\n ))\n : eligibilityRequirements.map((label) => (\n <div\n key={label}\n className=\"flex items-center gap-3 rounded-md border border-border-subtle bg-bg-sunken/50 p-3\"\n >\n <Circle className=\"h-4 w-4 shrink-0 text-text-secondary\" />\n <span className=\"text-sm text-text-primary\">{label}</span>\n </div>\n ))}\n </div>\n </div>\n\n {/* Canonical scheme-owned document requirements */}\n <section\n data-testid=\"scheme-required-documents\"\n className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\"\n aria-labelledby=\"scheme-required-documents\"\n >\n <h3 id=\"scheme-required-documents\" className=\"text-sm font-semibold text-text-primary\">\n {t('healthybowl.governmentSchemes.schemeDetails.sections.documents.title', 'Required Documents')}\n </h3>\n {scheme.requiredDocuments.length === 0 ? (\n <p className=\"mt-2 text-sm text-text-secondary\">\n {t(\n 'healthybowl.governmentSchemes.schemeDetails.sections.documents.none',\n 'The scheme provider has not listed any required documents.'\n )}\n </p>\n ) : (\n <ul className=\"mt-3 space-y-2\">\n {scheme.requiredDocuments.map((document) => (\n <li key={document} className=\"flex items-start gap-2 text-sm text-text-secondary\">\n <CheckCircle2 className=\"mt-0.5 h-4 w-4 shrink-0 text-success\" />\n <span>{document}</span>\n </li>\n ))}\n </ul>\n )}\n </section>\n\n {!canApply ? (\n <div\n role=\"status\"\n data-testid=\"scheme-application-blocked\"\n className=\"rounded-md border border-border-subtle bg-bg-sunken p-4\"\n >\n <p className=\"text-sm font-medium text-text-primary\">\n {effectiveStatus === 'expired'\n ? t('healthybowl.governmentSchemes.schemeDetails.expired.title', 'Application deadline has passed')\n : t('healthybowl.governmentSchemes.schemeDetails.closed.title', 'Applications are closed')}\n </p>\n <p className=\"mt-1 text-xs text-text-secondary\">\n {effectiveStatus === 'expired'\n ? t(\n 'healthybowl.governmentSchemes.schemeDetails.expired.description',\n 'This scheme has expired. You can still review its requirements and benefits.'\n )\n : t(\n 'healthybowl.governmentSchemes.schemeDetails.closed.description',\n 'This scheme is no longer accepting applications. You can still review its requirements and benefits.'\n )}\n </p>\n </div>\n ) : null}\n\n {/* Apply Button */}\n <div className=\"flex gap-3\">\n <Button data-testid=\"scheme-apply-button\" onClick={openApplication}>\n {t('healthybowl.governmentSchemes.schemeDetails.actions.apply', 'Apply for This Scheme')}\n </Button>\n <Button variant=\"outline\" onClick={() => navigate(buildPath('government-schemes/discover'))}>\n {t('healthybowl.governmentSchemes.schemeDetails.actions.backToSchemes', 'Back to Schemes')}\n </Button>\n </div>\n\n {/* FAQ Accordion */}\n <div className=\"rounded-lg border border-border-subtle bg-bg-surface p-6\">\n <h3 className=\"text-sm font-semibold text-text-primary\">\n {t('healthybowl.governmentSchemes.schemeDetails.faq.title', 'Frequently Asked Questions')}\n </h3>\n <div className=\"mt-4 space-y-2\">\n {schemeFaqs.map((faq, i) => (\n <div key={i} className=\"rounded-md border border-border-subtle\">\n <Button\n variant=\"ghost\"\n onClick={() => setExpandedFaq(expandedFaq === i ? null : i)}\n className=\"h-auto w-full justify-between whitespace-normal px-4 py-3 text-start font-medium text-text-primary\"\n >\n {faq.question}\n {expandedFaq === i ? (\n <ChevronUp className=\"h-4 w-4 shrink-0 text-text-secondary\" />\n ) : (\n <ChevronDown className=\"h-4 w-4 shrink-0 text-text-secondary\" />\n )}\n </Button>\n {expandedFaq === i && (\n <div className=\"border-t border-border-subtle px-4 py-3 text-sm leading-relaxed text-text-secondary\">\n {faq.answer}\n </div>\n )}\n </div>\n ))}\n </div>\n </div>\n\n {/* Related Schemes */}\n {relatedSchemes.length > 0 && (\n <div>\n <h3 className=\"mb-3 text-sm font-semibold text-text-primary\">\n {t('healthybowl.governmentSchemes.schemeDetails.related.title', 'Related Schemes ({{category}})', {\n category: scheme.category,\n })}\n </h3>\n <div className=\"grid gap-4 sm:grid-cols-2\">\n {relatedSchemes.map((related) => (\n <button\n key={related.id}\n type=\"button\"\n onClick={() => navigate(buildPath(`government-schemes/schemes/${related.id}`))}\n className=\"flex items-start gap-3 rounded-lg border border-border-subtle bg-bg-surface p-4 text-start transition-colors hover:bg-bg-sunken/50\"\n >\n <Landmark className=\"mt-0.5 h-5 w-5 shrink-0 text-text-secondary\" />\n <div className=\"flex-1\">\n <p className=\"text-sm font-medium text-text-primary\">{related.title}</p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">{related.department}</p>\n <div className=\"mt-2 flex items-center gap-2\">\n <StatusBadge\n label={getEffectiveSchemeStatus(related, todayLocalDate()).replace(/_/g, ' ')}\n variant={statusVariant(getEffectiveSchemeStatus(related, todayLocalDate()))}\n />\n {related.maxAmount && (\n <span className=\"text-xs text-text-secondary\">\n {t('healthybowl.governmentSchemes.schemeDetails.related.upTo', 'Up to {{amount}}', {\n amount: formatCurrency(related.maxAmount, related.currency),\n })}\n </span>\n )}\n </div>\n </div>\n </button>\n ))}\n </div>\n </div>\n )}\n\n {/* Application Modal */}\n <Modal\n open={showApplyModal && canApply}\n onClose={() => {\n if (!submitting) setShowApplyModal(false);\n }}\n title={t('healthybowl.governmentSchemes.schemeDetails.modal.title', 'Apply for Scheme')}\n description={scheme.title}\n size=\"lg\"\n footer={\n <>\n <Button variant=\"outline\" onClick={() => setShowApplyModal(false)} disabled={submitting}>\n {t('healthybowl.common.cancel', 'Cancel')}\n </Button>\n <Button onClick={handleSubmitApplication} disabled={submitting}>\n {submitting\n ? t('healthybowl.governmentSchemes.schemeDetails.modal.submitting', 'Submitting...')\n : t('healthybowl.governmentSchemes.schemeDetails.modal.submit', 'Submit Application')}\n </Button>\n </>\n }\n >\n <div className=\"space-y-4\">\n {/* Applicant Details */}\n <div>\n <h4 className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.governmentSchemes.schemeDetails.form.applicant.title', 'Applicant Details')}\n </h4>\n <div className=\"mt-2 space-y-3\">\n <div>\n <label htmlFor=\"scheme-applicant-name\" className=\"block text-xs font-medium text-text-secondary\">\n {t('healthybowl.governmentSchemes.schemeDetails.form.fields.fullName.label', 'Full Name *')}\n </label>\n <input\n id=\"scheme-applicant-name\"\n type=\"text\"\n value={applicationForm.applicantName}\n onChange={(e) => setApplicationForm({ ...applicationForm, applicantName: e.target.value })}\n placeholder={t(\n 'healthybowl.governmentSchemes.schemeDetails.form.fields.fullName.placeholder',\n 'Enter your full name'\n )}\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary\"\n />\n </div>\n </div>\n </div>\n\n {/* Farm Details */}\n <div>\n <h4 className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.governmentSchemes.schemeDetails.form.farm.title', 'Farm Details')}\n </h4>\n <div className=\"mt-2 grid gap-3 sm:grid-cols-2\">\n <div>\n <label htmlFor=\"scheme-farm-name\" className=\"block text-xs font-medium text-text-secondary\">\n {t('healthybowl.governmentSchemes.schemeDetails.form.fields.farmName.label', 'Farm Name *')}\n </label>\n <input\n id=\"scheme-farm-name\"\n type=\"text\"\n value={applicationForm.farmName}\n onChange={(e) => setApplicationForm({ ...applicationForm, farmName: e.target.value })}\n placeholder={t(\n 'healthybowl.governmentSchemes.schemeDetails.form.fields.farmName.placeholder',\n 'Your farm name'\n )}\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary\"\n />\n </div>\n <div>\n <label className=\"block text-xs font-medium text-text-secondary\">\n {t('healthybowl.governmentSchemes.schemeDetails.form.fields.farmSize.label', 'Farm Size (acres)')}\n </label>\n <input\n type=\"text\"\n value={applicationForm.farmSize}\n onChange={(e) => setApplicationForm({ ...applicationForm, farmSize: e.target.value })}\n placeholder={t(\n 'healthybowl.governmentSchemes.schemeDetails.form.fields.farmSize.placeholder',\n 'e.g., 50'\n )}\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary\"\n />\n </div>\n <div className=\"sm:col-span-2\">\n <label className=\"block text-xs font-medium text-text-secondary\">\n {t('healthybowl.governmentSchemes.schemeDetails.form.fields.farmLocation.label', 'Farm Location')}\n </label>\n <input\n type=\"text\"\n value={applicationForm.farmLocation}\n onChange={(e) => setApplicationForm({ ...applicationForm, farmLocation: e.target.value })}\n placeholder={t(\n 'healthybowl.governmentSchemes.schemeDetails.form.fields.farmLocation.placeholder',\n 'County, State'\n )}\n className=\"mt-1 w-full rounded-md border border-border-subtle bg-bg-surface px-3 py-2 text-sm text-text-primary placeholder:text-text-secondary\"\n />\n </div>\n </div>\n </div>\n\n {/* Supporting documents (BOFF-6111). These used to be four checkboxes under \"Confirm you\n have the following documents ready for upload\" — nothing was ever uploaded, and the\n affirmation was appended to the application's free text. */}\n <div>\n <h4 className=\"text-sm font-medium text-text-primary\">\n {t('healthybowl.governmentSchemes.schemeDetails.form.documents.title', 'Supporting documents')}\n </h4>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {t(\n 'healthybowl.governmentSchemes.schemeDetails.form.documents.helper',\n 'Upload each document. They are attached to your application, so the department does not have to ask for them separately.'\n )}\n </p>\n <div className=\"mt-2 space-y-2\">\n {SCHEME_DOCUMENT_SLOT_SPECS.map((spec) => {\n const attached = documentForSlot(documents, spec.slot);\n const busy = uploadingSlot === spec.slot;\n return (\n <div\n key={spec.slot}\n className=\"flex flex-wrap items-center justify-between gap-3 rounded-md border border-border-subtle p-3\"\n >\n <div className=\"flex items-center gap-2\">\n {attached ? (\n <CheckCircle2 className=\"h-4 w-4 text-status-success-text\" />\n ) : (\n <Upload className=\"h-3.5 w-3.5 text-text-secondary\" />\n )}\n <div>\n <span className=\"text-sm text-text-primary\">{t(spec.labelKey, spec.labelFallback)}</span>\n {spec.required ? (\n <span className=\"ms-1 text-xs text-status-error-text\" aria-hidden=\"true\">\n *\n </span>\n ) : (\n <span className=\"ms-2 text-xs text-text-secondary\">\n {t('healthybowl.governmentSchemes.schemeDetails.form.documents.optional', 'optional')}\n </span>\n )}\n {attached ? (\n <div className=\"text-xs text-text-secondary\">\n {attached.fileName ??\n t('healthybowl.governmentSchemes.schemeDetails.form.documents.uploaded', 'Uploaded')}\n </div>\n ) : null}\n </div>\n </div>\n <div className=\"flex items-center gap-2\">\n <label className=\"cursor-pointer text-xs font-medium text-action-primary-bg hover:underline\">\n {busy\n ? t('healthybowl.governmentSchemes.schemeDetails.form.documents.uploading', 'Uploading…')\n : attached\n ? t('healthybowl.governmentSchemes.schemeDetails.form.documents.replace', 'Replace')\n : t('healthybowl.governmentSchemes.schemeDetails.form.documents.upload', 'Upload')}\n <input\n type=\"file\"\n className=\"sr-only\"\n disabled={busy}\n aria-label={t(spec.labelKey, spec.labelFallback)}\n onChange={(e) => {\n const file = e.target.files?.[0];\n // Reset the input so choosing the SAME file again still fires a change.\n e.target.value = '';\n if (file) void handleUploadDocument(spec.slot, file);\n }}\n />\n </label>\n {attached ? (\n <button\n type=\"button\"\n onClick={() => setDocuments((prev) => removeSchemeDocument(prev, spec.slot))}\n className=\"text-xs text-text-secondary hover:text-status-error-text\"\n >\n {t('common.remove', 'Remove')}\n </button>\n ) : null}\n </div>\n </div>\n );\n })}\n </div>\n </div>\n\n {/* Declaration */}\n <div className=\"rounded-md border border-border-subtle bg-bg-sunken/50 p-4\">\n <label htmlFor=\"scheme-declaration\" className=\"flex items-start gap-3\">\n <input\n id=\"scheme-declaration\"\n type=\"checkbox\"\n checked={applicationForm.declaration}\n onChange={(e) => setApplicationForm({ ...applicationForm, declaration: e.target.checked })}\n className=\"mt-0.5 h-4 w-4 rounded border-border-subtle\"\n />\n <span className=\"text-xs text-text-secondary\">\n {t(\n 'healthybowl.governmentSchemes.schemeDetails.form.declaration.text',\n 'I declare that the information provided is true and accurate. I understand that providing false information may result in disqualification and legal action.'\n )}\n </span>\n </label>\n </div>\n </div>\n </Modal>\n\n <ToastContainer toasts={toasts} onDismiss={dismiss} />\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAwCA,IAAM,KAAiB,MAAc;CACnC,QAAQ,GAAR;EACE,KAAK,QACH,OAAO;EACT,KAAK,gBACH,OAAO;EACT,KAAK;EACL,KAAK,WACH,OAAO;EACT,SACE,OAAO;CACX;AACF,GAEM,KAAmB,MAAc;CACrC,QAAQ,GAAR;EACE,KAAK,WACH,OAAO;EACT,KAAK,UACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,KAAK,SACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,SACE,OAAO;CACX;AACF,GAOa,UAA0B;CACrC,IAAM,EAAE,sBAAmB,WAAQ,aAAU,eAAY,EAAmB,GAEtE,EAAE,+BAA2B,GAAe,GAI5C,EAAE,MAAM,OAAgB,EAAe,GACvC,CAAC,GAAW,KAAgB,EAAmC,CAAC,CAAC,GACjE,CAAC,IAAe,KAAoB,EAAoC,IAAI,GAE5E,EAAE,gBAAa,EAAgC,GAG/C,EAAE,mBAAgB,GAAqB,CAAQ,GAC/C,IAAW,EAAY,GACvB,EAAE,iBAAc,GAAY,GAC5B,EAAE,YAAQ,UAAO,gBAAY,GAAS,GACtC,EAAE,SAAM,GAAQ,GAEhB,KAAwB,QACtB;EACJ;GACE,UAAU,EACR,uEACA,oDACF;GACA,QAAQ,EACN,qEACA,sJACF;EACF;EACA;GACE,UAAU,EACR,sEACA,qCACF;GACA,QAAQ,EACN,oEACA,2MACF;EACF;EACA;GACE,UAAU,EACR,iFACA,qDACF;GACA,QAAQ,EACN,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AAsE,SAAS,IACjF,EAAE,qEAAqE,QAAQ,GACrF,kBAAC,SAAD;aACE,MAAK;aACL,WAAU;aACV,UAAU;aACV,cAAY,EAAE,EAAK,UAAU,EAAK,aAAa;aAC/C,WAAW,MAAM;cACf,IAAM,IAAO,EAAE,OAAO,QAAQ;cAG9B,AADA,EAAE,OAAO,QAAQ,IACb,KAAM,GAA0B,EAAK,MAAM,CAAI;aACrD;YACD,CAAA,CACI;eACN,IACC,kBAAC,UAAD;YACE,MAAK;YACL,eAAe,GAAc,MAAS,GAAqB,GAAM,EAAK,IAAI,CAAC;YAC3E,WAAU;sBAET,EAAE,iBAAiB,QAAQ;WACtB,CAAA,IACN,IACD;YACF;YA1DE,EAAK,IA0DP;QAET,CAAC;OACE,CAAA;MACF,EAAA,CAAA;MAGL,kBAAC,OAAD;OAAK,WAAU;iBACb,kBAAC,SAAD;QAAO,SAAQ;QAAqB,WAAU;kBAA9C,CACE,kBAAC,SAAD;SACE,IAAG;SACH,MAAK;SACL,SAAS,EAAgB;SACzB,WAAW,MAAM,EAAmB;UAAE,GAAG;UAAiB,aAAa,EAAE,OAAO;SAAQ,CAAC;SACzF,WAAU;QACX,CAAA,GACD,kBAAC,QAAD;SAAM,WAAU;mBACb,EACC,qEACA,8JACF;QACI,CAAA,CACD;;MACJ,CAAA;KACF;;GACA,CAAA;GAEP,kBAAC,GAAD;IAAwB;IAAQ,WAAW;GAAU,CAAA;EAC3C;;AAEhB"}
@@ -0,0 +1,49 @@
1
+ //#region src/healthybowl/pages/government-schemes/schemeApplicationTransitions.ts
2
+ var e = {
3
+ submitted: ["under_review", "rejected"],
4
+ under_review: ["approved", "rejected"],
5
+ approved: ["disbursed"],
6
+ rejected: [],
7
+ disbursed: []
8
+ }, t = {
9
+ submitted: {
10
+ labelKey: "healthybowl.governmentSchemes.tracking.action.submitted",
11
+ labelFallback: "Mark submitted",
12
+ destructive: !1
13
+ },
14
+ under_review: {
15
+ labelKey: "healthybowl.governmentSchemes.tracking.action.underReview",
16
+ labelFallback: "Move to under review",
17
+ destructive: !1
18
+ },
19
+ approved: {
20
+ labelKey: "healthybowl.governmentSchemes.tracking.action.approved",
21
+ labelFallback: "Approve",
22
+ destructive: !1
23
+ },
24
+ rejected: {
25
+ labelKey: "healthybowl.governmentSchemes.tracking.action.rejected",
26
+ labelFallback: "Reject",
27
+ destructive: !0
28
+ },
29
+ disbursed: {
30
+ labelKey: "healthybowl.governmentSchemes.tracking.action.disbursed",
31
+ labelFallback: "Mark disbursed",
32
+ destructive: !1
33
+ }
34
+ };
35
+ function n(n) {
36
+ let r = e[n];
37
+ return r ? r.map((e) => ({
38
+ status: e,
39
+ ...t[e]
40
+ })) : [];
41
+ }
42
+ function r(t) {
43
+ let n = e[t];
44
+ return n !== void 0 && n.length === 0;
45
+ }
46
+ //#endregion
47
+ export { r as isTerminalSchemeApplicationStatus, n as transitionActionsFor };
48
+
49
+ //# sourceMappingURL=schemeApplicationTransitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemeApplicationTransitions.js","names":[],"sources":["../../../../src/healthybowl/pages/government-schemes/schemeApplicationTransitions.ts"],"sourcesContent":["/**\n * Government scheme-application transitions (BOFF-6037) — pure, so it is unit-testable.\n *\n * Mirrors `SCHEME_APPLICATION_TRANSITIONS` in wspace-healthybowl-svc's\n * `HealthyBowlDomainProvider`. The server is the authority — it refuses an illegal edge with\n * `BAD_USER_INPUT` — and this exists so the page offers only the buttons that will work, rather\n * than showing four and letting three of them fail.\n *\n * Statuses arrive from the API **lower-cased** (`toLowerEnum`), which is what the tracking page\n * already renders, so this map is keyed the same way.\n *\n * @module healthybowl\n */\n\nexport type SchemeApplicationStatus = 'submitted' | 'under_review' | 'approved' | 'rejected' | 'disbursed';\n\n/**\n * Legal next states, by current state.\n *\n * No `submitted → disbursed` skip: money must not move without a recorded approval. `submitted →\n * rejected` is direct, because an ineligible applicant is refused on sight and forcing a review\n * cycle would be theatre. Terminal states offer nothing, and there are no self-edges — so a\n * double-clicked button cannot produce a duplicate audit row.\n */\nexport const SCHEME_APPLICATION_TRANSITIONS: Readonly<\n Record<SchemeApplicationStatus, readonly SchemeApplicationStatus[]>\n> = {\n submitted: ['under_review', 'rejected'],\n under_review: ['approved', 'rejected'],\n approved: ['disbursed'],\n rejected: [],\n disbursed: [],\n};\n\nexport interface TransitionAction {\n status: SchemeApplicationStatus;\n labelKey: string;\n labelFallback: string;\n /** A refusal is a heavier act than an advance, so it is styled apart. */\n destructive: boolean;\n}\n\nconst ACTION_COPY: Readonly<Record<SchemeApplicationStatus, Omit<TransitionAction, 'status'>>> = {\n submitted: {\n labelKey: 'healthybowl.governmentSchemes.tracking.action.submitted',\n labelFallback: 'Mark submitted',\n destructive: false,\n },\n under_review: {\n labelKey: 'healthybowl.governmentSchemes.tracking.action.underReview',\n labelFallback: 'Move to under review',\n destructive: false,\n },\n approved: {\n labelKey: 'healthybowl.governmentSchemes.tracking.action.approved',\n labelFallback: 'Approve',\n destructive: false,\n },\n rejected: {\n labelKey: 'healthybowl.governmentSchemes.tracking.action.rejected',\n labelFallback: 'Reject',\n destructive: true,\n },\n disbursed: {\n labelKey: 'healthybowl.governmentSchemes.tracking.action.disbursed',\n labelFallback: 'Mark disbursed',\n destructive: false,\n },\n};\n\n/**\n * The actions offered for an application in this state.\n *\n * An unrecognised status yields none rather than guessing: a state this client does not know about\n * is a state it has no business moving.\n */\nexport function transitionActionsFor(status: string): TransitionAction[] {\n const next = SCHEME_APPLICATION_TRANSITIONS[status as SchemeApplicationStatus];\n if (!next) return [];\n return next.map((target) => ({ status: target, ...ACTION_COPY[target] }));\n}\n\n/** True when the application has reached a state nothing can move it out of. */\nexport function isTerminalSchemeApplicationStatus(status: string): boolean {\n const next = SCHEME_APPLICATION_TRANSITIONS[status as SchemeApplicationStatus];\n return next !== undefined && next.length === 0;\n}\n"],"mappings":";AAwBA,IAAa,IAET;CACF,WAAW,CAAC,gBAAgB,UAAU;CACtC,cAAc,CAAC,YAAY,UAAU;CACrC,UAAU,CAAC,WAAW;CACtB,UAAU,CAAC;CACX,WAAW,CAAC;AACd,GAUM,IAA2F;CAC/F,WAAW;EACT,UAAU;EACV,eAAe;EACf,aAAa;CACf;CACA,cAAc;EACZ,UAAU;EACV,eAAe;EACf,aAAa;CACf;CACA,UAAU;EACR,UAAU;EACV,eAAe;EACf,aAAa;CACf;CACA,UAAU;EACR,UAAU;EACV,eAAe;EACf,aAAa;CACf;CACA,WAAW;EACT,UAAU;EACV,eAAe;EACf,aAAa;CACf;AACF;AAQA,SAAgB,EAAqB,GAAoC;CACvE,IAAM,IAAO,EAA+B;CAE5C,OADK,IACE,EAAK,KAAK,OAAY;EAAE,QAAQ;EAAQ,GAAG,EAAY;CAAQ,EAAE,IADtD,CAAC;AAErB;AAGA,SAAgB,EAAkC,GAAyB;CACzE,IAAM,IAAO,EAA+B;CAC5C,OAAO,MAAS,KAAA,KAAa,EAAK,WAAW;AAC/C"}
@@ -0,0 +1,48 @@
1
+ //#region src/healthybowl/pages/government-schemes/schemeDocumentSlots.ts
2
+ var e = [
3
+ {
4
+ slot: "FARM_OWNERSHIP",
5
+ required: !0,
6
+ labelKey: "healthybowl.governmentSchemes.schemeDetails.form.documents.ownershipProof",
7
+ labelFallback: "Farm Ownership / Lease Proof"
8
+ },
9
+ {
10
+ slot: "GOVERNMENT_ID",
11
+ required: !0,
12
+ labelKey: "healthybowl.governmentSchemes.schemeDetails.form.documents.idDocument",
13
+ labelFallback: "Government-issued ID"
14
+ },
15
+ {
16
+ slot: "BANK_DETAILS",
17
+ required: !0,
18
+ labelKey: "healthybowl.governmentSchemes.schemeDetails.form.documents.bankDetails",
19
+ labelFallback: "Bank Account Details"
20
+ },
21
+ {
22
+ slot: "ORGANIC_CERTIFICATE",
23
+ required: !1,
24
+ labelKey: "healthybowl.governmentSchemes.schemeDetails.form.documents.certification",
25
+ labelFallback: "Organic Certification (if applicable)"
26
+ }
27
+ ];
28
+ function t(t) {
29
+ let n = new Set(t.map((e) => e.slot));
30
+ return e.filter((e) => e.required && !n.has(e.slot));
31
+ }
32
+ function n(e) {
33
+ return t(e).length === 0;
34
+ }
35
+ function r(t, n) {
36
+ let r = new Map(t.map((e) => [e.slot, e]));
37
+ return r.set(n.slot, n), e.map((e) => r.get(e.slot)).filter((e) => e !== void 0);
38
+ }
39
+ function i(e, t) {
40
+ return e.filter((e) => e.slot !== t);
41
+ }
42
+ function a(e, t) {
43
+ return e.find((e) => e.slot === t) ?? null;
44
+ }
45
+ //#endregion
46
+ export { e as SCHEME_DOCUMENT_SLOT_SPECS, n as canSubmitSchemeApplication, a as documentForSlot, t as missingRequiredSchemeDocuments, i as removeSchemeDocument, r as setSchemeDocument };
47
+
48
+ //# sourceMappingURL=schemeDocumentSlots.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schemeDocumentSlots.js","names":[],"sources":["../../../../src/healthybowl/pages/government-schemes/schemeDocumentSlots.ts"],"sourcesContent":["/**\n * Scheme-application document slots (BOFF-6111) — pure, so it is unit-testable.\n *\n * The application form used to show four checkboxes under \"Confirm you have the following documents\n * ready for upload\", join them into an English sentence, and append that to the application's free\n * text. Nothing was uploaded. These are the four slots that replace them, plus the rules about\n * which are required and when the form may be submitted.\n *\n * Mirrors `SCHEME_DOCUMENT_SLOTS` / `REQUIRED_SCHEME_DOCUMENT_SLOTS` in wspace-healthybowl-svc's\n * `government/scheme-documents.ts`. The server is the authority; this exists so the farmer is told\n * what is missing before a round trip, and so the outbox never queues an application the server\n * will refuse.\n *\n * @module healthybowl\n */\n\nexport type SchemeDocumentSlot = 'FARM_OWNERSHIP' | 'GOVERNMENT_ID' | 'BANK_DETAILS' | 'ORGANIC_CERTIFICATE';\n\nexport interface SchemeDocumentSlotSpec {\n slot: SchemeDocumentSlot;\n required: boolean;\n labelKey: string;\n labelFallback: string;\n}\n\n/** Declaration order is display order, and the order the server returns documents in. */\nexport const SCHEME_DOCUMENT_SLOT_SPECS: readonly SchemeDocumentSlotSpec[] = [\n {\n slot: 'FARM_OWNERSHIP',\n required: true,\n labelKey: 'healthybowl.governmentSchemes.schemeDetails.form.documents.ownershipProof',\n labelFallback: 'Farm Ownership / Lease Proof',\n },\n {\n slot: 'GOVERNMENT_ID',\n required: true,\n labelKey: 'healthybowl.governmentSchemes.schemeDetails.form.documents.idDocument',\n labelFallback: 'Government-issued ID',\n },\n {\n slot: 'BANK_DETAILS',\n required: true,\n labelKey: 'healthybowl.governmentSchemes.schemeDetails.form.documents.bankDetails',\n labelFallback: 'Bank Account Details',\n },\n {\n slot: 'ORGANIC_CERTIFICATE',\n required: false,\n labelKey: 'healthybowl.governmentSchemes.schemeDetails.form.documents.certification',\n labelFallback: 'Organic Certification (if applicable)',\n },\n];\n\n/** One uploaded document held in form state. */\nexport interface UploadedSchemeDocument {\n slot: SchemeDocumentSlot;\n fileId: string;\n fileName: string | null;\n uploadedAt: string;\n}\n\n/** The required slots that still have no upload. */\nexport function missingRequiredSchemeDocuments(documents: readonly UploadedSchemeDocument[]): SchemeDocumentSlotSpec[] {\n const present = new Set(documents.map((doc) => doc.slot));\n return SCHEME_DOCUMENT_SLOT_SPECS.filter((spec) => spec.required && !present.has(spec.slot));\n}\n\n/** True when every required document has been uploaded. */\nexport function canSubmitSchemeApplication(documents: readonly UploadedSchemeDocument[]): boolean {\n return missingRequiredSchemeDocuments(documents).length === 0;\n}\n\n/**\n * Replace or add the document in a slot.\n *\n * Last-write-wins per slot, matching the server, so re-uploading corrects a mistake rather than\n * attaching two files to one requirement. Order follows the slot specs, not upload order, so the\n * list reads the same way the form asks for it.\n */\nexport function setSchemeDocument(\n documents: readonly UploadedSchemeDocument[],\n next: UploadedSchemeDocument\n): UploadedSchemeDocument[] {\n const bySlot = new Map(documents.map((doc) => [doc.slot, doc]));\n bySlot.set(next.slot, next);\n return SCHEME_DOCUMENT_SLOT_SPECS.map((spec) => bySlot.get(spec.slot)).filter(\n (doc): doc is UploadedSchemeDocument => doc !== undefined\n );\n}\n\n/** Remove whatever is attached to a slot. */\nexport function removeSchemeDocument(\n documents: readonly UploadedSchemeDocument[],\n slot: SchemeDocumentSlot\n): UploadedSchemeDocument[] {\n return documents.filter((doc) => doc.slot !== slot);\n}\n\n/** The document attached to a slot, if any. */\nexport function documentForSlot(\n documents: readonly UploadedSchemeDocument[],\n slot: SchemeDocumentSlot\n): UploadedSchemeDocument | null {\n return documents.find((doc) => doc.slot === slot) ?? null;\n}\n"],"mappings":";AA0BA,IAAa,IAAgE;CAC3E;EACE,MAAM;EACN,UAAU;EACV,UAAU;EACV,eAAe;CACjB;CACA;EACE,MAAM;EACN,UAAU;EACV,UAAU;EACV,eAAe;CACjB;CACA;EACE,MAAM;EACN,UAAU;EACV,UAAU;EACV,eAAe;CACjB;CACA;EACE,MAAM;EACN,UAAU;EACV,UAAU;EACV,eAAe;CACjB;AACF;AAWA,SAAgB,EAA+B,GAAwE;CACrH,IAAM,IAAU,IAAI,IAAI,EAAU,KAAK,MAAQ,EAAI,IAAI,CAAC;CACxD,OAAO,EAA2B,QAAQ,MAAS,EAAK,YAAY,CAAC,EAAQ,IAAI,EAAK,IAAI,CAAC;AAC7F;AAGA,SAAgB,EAA2B,GAAuD;CAChG,OAAO,EAA+B,CAAS,EAAE,WAAW;AAC9D;AASA,SAAgB,EACd,GACA,GAC0B;CAC1B,IAAM,IAAS,IAAI,IAAI,EAAU,KAAK,MAAQ,CAAC,EAAI,MAAM,CAAG,CAAC,CAAC;CAE9D,OADA,EAAO,IAAI,EAAK,MAAM,CAAI,GACnB,EAA2B,KAAK,MAAS,EAAO,IAAI,EAAK,IAAI,CAAC,EAAE,QACpE,MAAuC,MAAQ,KAAA,CAClD;AACF;AAGA,SAAgB,EACd,GACA,GAC0B;CAC1B,OAAO,EAAU,QAAQ,MAAQ,EAAI,SAAS,CAAI;AACpD;AAGA,SAAgB,EACd,GACA,GAC+B;CAC/B,OAAO,EAAU,MAAM,MAAQ,EAAI,SAAS,CAAI,KAAK;AACvD"}
@@ -0,0 +1,54 @@
1
+ import { useHealthyBowl as e } from "../../context/HealthyBowlContext.js";
2
+ import { useHealthyBowlData as t } from "../../hooks/useHealthyBowlData.js";
3
+ import { useCallback as n, useState as r } from "react";
4
+ import { gql as i } from "@apollo/client";
5
+ import { useMutation as a } from "@apollo/client/react";
6
+ //#region src/healthybowl/pages/government-schemes/useSchemeApplicationTransition.ts
7
+ var o = i`
8
+ mutation UpdateHealthyBowlSchemeApplicationStatus($input: UpdateHealthyBowlSchemeApplicationStatusInput!) {
9
+ updateHealthyBowlSchemeApplicationStatus(input: $input) {
10
+ id
11
+ status
12
+ }
13
+ }
14
+ `;
15
+ function s(e, t) {
16
+ if (typeof e == "object" && e) {
17
+ let t = e;
18
+ if (Array.isArray(t.errors) && t.errors.length > 0) {
19
+ let e = t.errors[0], n = e?.extensions?.userMessage;
20
+ if (typeof n == "string" && n.length > 0) return n;
21
+ if (typeof e?.message == "string" && e.message.length > 0) return e.message;
22
+ }
23
+ if (typeof t.message == "string" && t.message.length > 0) return t.message;
24
+ }
25
+ return t;
26
+ }
27
+ function c() {
28
+ let { workspaceId: i } = e(), { refetch: c } = t(), [l] = a(o), [u, d] = r(null);
29
+ return {
30
+ transition: n(async (e, t, n) => {
31
+ d(e);
32
+ try {
33
+ await l({ variables: { input: {
34
+ id: e,
35
+ status: t,
36
+ context: { workspaceId: i }
37
+ } } }), await c(), n?.onSuccess?.();
38
+ } catch (e) {
39
+ n?.onError?.(s(e, "The application could not be updated."));
40
+ } finally {
41
+ d(null);
42
+ }
43
+ }, [
44
+ l,
45
+ i,
46
+ c
47
+ ]),
48
+ pendingId: u
49
+ };
50
+ }
51
+ //#endregion
52
+ export { c as useSchemeApplicationTransition };
53
+
54
+ //# sourceMappingURL=useSchemeApplicationTransition.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useSchemeApplicationTransition.js","names":[],"sources":["../../../../src/healthybowl/pages/government-schemes/useSchemeApplicationTransition.ts"],"sourcesContent":["/**\n * Move a government scheme application along its lifecycle (BOFF-6037).\n *\n * Declared as an inline `gql` document rather than an entry under `src/operations/`: the mutation is\n * newer than the committed `graphql/wspace.graphql` snapshot that codegen validates against, and\n * this is the escape hatch the repo uses for exactly that case (~44 of 52 hooks do the same).\n *\n * @module healthybowl\n */\nimport { useCallback, useState } from 'react';\nimport { gql } from '@apollo/client';\nimport { useMutation } from '@apollo/client/react';\nimport { useHealthyBowl } from '../../context/HealthyBowlContext';\nimport { useHealthyBowlData } from '../../hooks/useHealthyBowlData';\nimport type { SchemeApplicationStatus } from './schemeApplicationTransitions';\n\nconst UPDATE_SCHEME_APPLICATION_STATUS = gql`\n mutation UpdateHealthyBowlSchemeApplicationStatus($input: UpdateHealthyBowlSchemeApplicationStatusInput!) {\n updateHealthyBowlSchemeApplicationStatus(input: $input) {\n id\n status\n }\n }\n`;\n\ninterface TransitionCallbacks {\n onSuccess?: () => void;\n onError?: (message: string) => void;\n}\n\n/**\n * Read the operator-facing message off a rejected mutation.\n *\n * Apollo Client v4 rejects with `CombinedGraphQLErrors`, which has no v3 `graphQLErrors` property,\n * and the server puts the readable text in `extensions.userMessage` — which for this mutation is\n * the sentence naming which transitions ARE allowed. `err.message` alone would render Apollo's\n * aggregate wording and throw that away.\n */\nfunction readErrorMessage(err: unknown, fallback: string): string {\n if (err !== null && typeof err === 'object') {\n const shaped = err as { errors?: unknown; message?: unknown };\n if (Array.isArray(shaped.errors) && shaped.errors.length > 0) {\n const first = shaped.errors[0] as { message?: unknown; extensions?: { userMessage?: unknown } | null };\n const userMessage = first?.extensions?.userMessage;\n if (typeof userMessage === 'string' && userMessage.length > 0) return userMessage;\n if (typeof first?.message === 'string' && first.message.length > 0) return first.message;\n }\n if (typeof shaped.message === 'string' && shaped.message.length > 0) return shaped.message;\n }\n return fallback;\n}\n\nexport function useSchemeApplicationTransition(): {\n transition: (id: string, status: SchemeApplicationStatus, callbacks?: TransitionCallbacks) => Promise<void>;\n pendingId: string | null;\n} {\n const { workspaceId } = useHealthyBowl();\n const { refetch } = useHealthyBowlData();\n const [mutate] = useMutation(UPDATE_SCHEME_APPLICATION_STATUS);\n const [pendingId, setPendingId] = useState<string | null>(null);\n\n const transition = useCallback(\n async (id: string, status: SchemeApplicationStatus, callbacks?: TransitionCallbacks) => {\n setPendingId(id);\n try {\n await mutate({ variables: { input: { id, status, context: { workspaceId } } } });\n // fe-libs clears its read cache on a successful mutation, so the list is refetched\n // explicitly rather than trusted to update itself.\n await refetch();\n callbacks?.onSuccess?.();\n } catch (err) {\n callbacks?.onError?.(readErrorMessage(err, 'The application could not be updated.'));\n } finally {\n setPendingId(null);\n }\n },\n [mutate, workspaceId, refetch]\n );\n\n return { transition, pendingId };\n}\n"],"mappings":";;;;;;AAgBA,IAAM,IAAmC,CAAG;;;;;;;;AAsB5C,SAAS,EAAiB,GAAc,GAA0B;CAChE,IAAoB,OAAO,KAAQ,YAA/B,GAAyC;EAC3C,IAAM,IAAS;EACf,IAAI,MAAM,QAAQ,EAAO,MAAM,KAAK,EAAO,OAAO,SAAS,GAAG;GAC5D,IAAM,IAAQ,EAAO,OAAO,IACtB,IAAc,GAAO,YAAY;GACvC,IAAI,OAAO,KAAgB,YAAY,EAAY,SAAS,GAAG,OAAO;GACtE,IAAI,OAAO,GAAO,WAAY,YAAY,EAAM,QAAQ,SAAS,GAAG,OAAO,EAAM;EACnF;EACA,IAAI,OAAO,EAAO,WAAY,YAAY,EAAO,QAAQ,SAAS,GAAG,OAAO,EAAO;CACrF;CACA,OAAO;AACT;AAEA,SAAgB,IAGd;CACA,IAAM,EAAE,mBAAgB,EAAe,GACjC,EAAE,eAAY,EAAmB,GACjC,CAAC,KAAU,EAAY,CAAgC,GACvD,CAAC,GAAW,KAAgB,EAAwB,IAAI;CAoB9D,OAAO;EAAE,YAlBU,EACjB,OAAO,GAAY,GAAiC,MAAoC;GACtF,EAAa,CAAE;GACf,IAAI;IAKF,AAJA,MAAM,EAAO,EAAE,WAAW,EAAE,OAAO;KAAE;KAAI;KAAQ,SAAS,EAAE,eAAY;IAAE,EAAE,EAAE,CAAC,GAG/E,MAAM,EAAQ,GACd,GAAW,YAAY;GACzB,SAAS,GAAK;IACZ,GAAW,UAAU,EAAiB,GAAK,uCAAuC,CAAC;GACrF,UAAU;IACR,EAAa,IAAI;GACnB;EACF,GACA;GAAC;GAAQ;GAAa;EAAO,CAGtB;EAAY;CAAU;AACjC"}