@burdenoff/microfe-healthybowl 2026.902.5 → 2026.902.6

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.
@@ -1,25 +1,30 @@
1
- import { cn as e, formatCurrency as t, formatDate as n } from "../../utils/helpers.js";
2
- import { PageLayout as r } from "../../components/PageLayout.js";
3
- import { useBasePath as i } from "../../hooks/useBasePath.js";
4
- import { StatCard as a } from "../../components/StatCard.js";
5
- import { StatusBadge as o } from "../../components/StatusBadge.js";
6
- import { EmptyState as s } from "../../components/EmptyState.js";
7
- import { ErrorState as c } from "../../components/ErrorState.js";
8
- import { FilterBar as l } from "../../components/FilterBar.js";
9
- import { ToastContainer as u } from "../../components/Toast.js";
10
- import { PageLoader as d } from "../../components/PageLoader.js";
11
- import { useToast as f } from "../../hooks/useToast.js";
1
+ import { useHealthyBowl as e } from "../../context/HealthyBowlContext.js";
2
+ import { cn as t, formatCurrency as n, formatDate as r } from "../../utils/helpers.js";
3
+ import { PageLayout as i } from "../../components/PageLayout.js";
4
+ import { useBasePath as a } from "../../hooks/useBasePath.js";
5
+ import { StatCard as o } from "../../components/StatCard.js";
6
+ import { StatusBadge as s } from "../../components/StatusBadge.js";
7
+ import { EmptyState as c } from "../../components/EmptyState.js";
8
+ import { ErrorState as l } from "../../components/ErrorState.js";
9
+ import { FilterBar as u } from "../../components/FilterBar.js";
10
+ import { ToastContainer as d } from "../../components/Toast.js";
11
+ import { useConfirm as f } from "../../components/ConfirmDialog.js";
12
+ import { PageLoader as p } from "../../components/PageLoader.js";
13
+ import { useToast as m } from "../../hooks/useToast.js";
12
14
  import "../../components/index.js";
13
- import { useHealthyBowlData as ee } from "../../hooks/useHealthyBowlData.js";
14
- import { useOfflineSync as p } from "../../offline/OfflineSyncProvider.js";
15
- import { useMemo as m, useState as h } from "react";
16
- import { useI18n as g } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
17
- import { CheckCircle as _, ChevronDown as v, ChevronUp as y, Clock as b, CloudOff as x, FileText as S, Landmark as C, Plus as w, XCircle as T } from "lucide-react";
18
- import { useNavigate as E } from "react-router";
19
- import { jsx as D, jsxs as O } from "react/jsx-runtime";
20
- import { Button as k } from "@burdenoff/fe-libs/ui";
15
+ import { useHealthyBowlData as h } from "../../hooks/useHealthyBowlData.js";
16
+ import { useOfflineSync as g } from "../../offline/OfflineSyncProvider.js";
17
+ import { useCanManageGovernmentSchemes as ee } from "./useCanManageGovernmentSchemes.js";
18
+ import { useSchemeApplicationTransition as te } from "./useSchemeApplicationTransition.js";
19
+ import { isTerminalSchemeApplicationStatus as _, transitionActionsFor as v } from "./schemeApplicationTransitions.js";
20
+ import { useMemo as ne, useState as y } from "react";
21
+ import { useI18n as b } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
22
+ import { CheckCircle as x, ChevronDown as S, ChevronUp as C, Clock as re, CloudOff as ie, FileText as ae, Landmark as w, Plus as T, XCircle as E } from "lucide-react";
23
+ import { useNavigate as D } from "react-router";
24
+ import { jsx as O, jsxs as k } from "react/jsx-runtime";
25
+ import { Button as A } from "@burdenoff/fe-libs/ui";
21
26
  //#region src/healthybowl/pages/government-schemes/ApplicationTrackingPage.tsx
22
- var A = (e) => {
27
+ var j = (e) => {
23
28
  switch (e) {
24
29
  case "approved":
25
30
  case "disbursed": return "success";
@@ -28,264 +33,299 @@ var A = (e) => {
28
33
  case "rejected": return "error";
29
34
  default: return "default";
30
35
  }
31
- }, j = [
36
+ }, M = [
32
37
  "submitted",
33
38
  "under_review",
34
39
  "approved",
35
40
  "disbursed"
36
- ], M = (e) => {
41
+ ], N = (e) => {
37
42
  if (e === "rejected") return 1;
38
- let t = j.indexOf(e);
43
+ let t = M.indexOf(e);
39
44
  return t >= 0 ? t : 0;
40
45
  };
41
- function N(e, n) {
42
- return n ? t(e, n) : new Intl.NumberFormat(void 0, { maximumFractionDigits: 2 }).format(e);
46
+ function P(e, t) {
47
+ return t ? n(e, t) : new Intl.NumberFormat(void 0, { maximumFractionDigits: 2 }).format(e);
43
48
  }
44
- var P = () => {
45
- let { t } = g(), { schemeApplications: P, governmentSchemes: F, errors: I, loadings: L, refetch: R } = ee(), { pendingMutations: z } = p(), B = z.filter((e) => e.status !== "SYNCED"), te = [
49
+ var F = () => {
50
+ let { t: n } = b(), { schemeApplications: F, governmentSchemes: I, errors: L, loadings: R, refetch: z } = h(), { pendingMutations: B } = g(), V = B.filter((e) => e.status !== "SYNCED"), H = [
46
51
  {
47
52
  value: "all",
48
- label: t("healthybowl.common.all", "All")
53
+ label: n("healthybowl.common.all", "All")
49
54
  },
50
55
  {
51
56
  value: "submitted",
52
- label: t("healthybowl.governmentSchemes.applicationTracking.filters.submitted", "Submitted")
57
+ label: n("healthybowl.governmentSchemes.applicationTracking.filters.submitted", "Submitted")
53
58
  },
54
59
  {
55
60
  value: "under_review",
56
- label: t("healthybowl.governmentSchemes.applicationTracking.filters.underReview", "Under Review")
61
+ label: n("healthybowl.governmentSchemes.applicationTracking.filters.underReview", "Under Review")
57
62
  },
58
63
  {
59
64
  value: "approved",
60
- label: t("healthybowl.governmentSchemes.applicationTracking.filters.approved", "Approved")
65
+ label: n("healthybowl.governmentSchemes.applicationTracking.filters.approved", "Approved")
61
66
  },
62
67
  {
63
68
  value: "rejected",
64
- label: t("healthybowl.governmentSchemes.applicationTracking.filters.rejected", "Rejected")
69
+ label: n("healthybowl.governmentSchemes.applicationTracking.filters.rejected", "Rejected")
65
70
  },
66
71
  {
67
72
  value: "disbursed",
68
- label: t("healthybowl.governmentSchemes.applicationTracking.filters.disbursed", "Disbursed")
73
+ label: n("healthybowl.governmentSchemes.applicationTracking.filters.disbursed", "Disbursed")
69
74
  }
70
- ], V = E(), { buildPath: H } = i(), { toasts: U, dismiss: W } = f(), [G, K] = h("all"), [q, J] = h(""), [Y, X] = h(null), Z = m(() => new Map(F.map((e) => [e.id, e.currency])), [F]), Q = P.length, ne = P.filter((e) => e.status === "approved" || e.status === "disbursed").length, re = P.filter((e) => e.status === "under_review").length, ie = P.filter((e) => e.status === "rejected").length, $ = P.filter((e) => {
71
- let t = G === "all" || e.status === G, n = q === "" || (e.schemeName ?? "").toLowerCase().includes(q.toLowerCase());
75
+ ], U = D(), { buildPath: W } = a(), { toast: G, toasts: K, dismiss: q } = m(), { workspaceId: J } = e(), { canManage: Y } = ee(J), { transition: oe, pendingId: X } = te(), se = f(), ce = async (e, t) => {
76
+ _(t.status) && !await se({
77
+ title: n("healthybowl.governmentSchemes.tracking.confirm.title", "This cannot be undone"),
78
+ message: n("healthybowl.governmentSchemes.tracking.confirm.message", "Moving this application to {{status}} is final — nothing can move it out of that state afterwards. The applicant is notified straight away.", { status: n(t.labelKey, t.labelFallback).toLowerCase() }),
79
+ okButtonTitle: n(t.labelKey, t.labelFallback),
80
+ destructive: t.destructive
81
+ }) || await oe(e.id, t.status, {
82
+ onSuccess: () => G({
83
+ title: n("healthybowl.governmentSchemes.tracking.toast.moved", "Application updated"),
84
+ variant: "success"
85
+ }),
86
+ onError: (e) => G({
87
+ title: n("healthybowl.governmentSchemes.tracking.toast.moveFailed", "Could not update the application"),
88
+ description: e,
89
+ variant: "error"
90
+ })
91
+ });
92
+ }, [Z, le] = y("all"), [Q, ue] = y(""), [de, fe] = y(null), pe = ne(() => new Map(I.map((e) => [e.id, e.currency])), [I]), me = F.length, he = F.filter((e) => e.status === "approved" || e.status === "disbursed").length, ge = F.filter((e) => e.status === "under_review").length, _e = F.filter((e) => e.status === "rejected").length, $ = F.filter((e) => {
93
+ let t = Z === "all" || e.status === Z, n = Q === "" || (e.schemeName ?? "").toLowerCase().includes(Q.toLowerCase());
72
94
  return t && n;
73
95
  });
74
- return /* @__PURE__ */ O(r, {
75
- title: t("healthybowl.governmentSchemes.applicationTracking.title", "Application Tracking"),
76
- description: t("healthybowl.governmentSchemes.applicationTracking.description", "Track your scheme applications"),
96
+ return /* @__PURE__ */ k(i, {
97
+ title: n("healthybowl.governmentSchemes.applicationTracking.title", "Application Tracking"),
98
+ description: n("healthybowl.governmentSchemes.applicationTracking.description", "Track your scheme applications"),
77
99
  purpose: "Follow every scheme application from submitted to approved. See what's pending, what needs more documents, and what's been granted — so nothing stalls and you can chase up anything that's stuck.",
78
100
  children: [
79
- /* @__PURE__ */ O("div", {
101
+ /* @__PURE__ */ k("div", {
80
102
  className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4",
81
103
  children: [
82
- /* @__PURE__ */ D(a, {
104
+ /* @__PURE__ */ O(o, {
83
105
  hero: !0,
84
- label: t("healthybowl.governmentSchemes.applicationTracking.stats.total.label", "Total Applications"),
85
- value: Q,
86
- icon: /* @__PURE__ */ D(S, { className: "h-4 w-4" })
106
+ label: n("healthybowl.governmentSchemes.applicationTracking.stats.total.label", "Total Applications"),
107
+ value: me,
108
+ icon: /* @__PURE__ */ O(ae, { className: "h-4 w-4" })
87
109
  }),
88
- /* @__PURE__ */ D(a, {
89
- label: t("healthybowl.governmentSchemes.applicationTracking.stats.approved.label", "Approved"),
90
- value: ne,
91
- icon: /* @__PURE__ */ D(_, { className: "h-4 w-4" })
110
+ /* @__PURE__ */ O(o, {
111
+ label: n("healthybowl.governmentSchemes.applicationTracking.stats.approved.label", "Approved"),
112
+ value: he,
113
+ icon: /* @__PURE__ */ O(x, { className: "h-4 w-4" })
92
114
  }),
93
- /* @__PURE__ */ D(a, {
94
- label: t("healthybowl.governmentSchemes.applicationTracking.stats.underReview.label", "Under Review"),
95
- value: re,
96
- icon: /* @__PURE__ */ D(b, { className: "h-4 w-4" })
115
+ /* @__PURE__ */ O(o, {
116
+ label: n("healthybowl.governmentSchemes.applicationTracking.stats.underReview.label", "Under Review"),
117
+ value: ge,
118
+ icon: /* @__PURE__ */ O(re, { className: "h-4 w-4" })
97
119
  }),
98
- /* @__PURE__ */ D(a, {
99
- label: t("healthybowl.governmentSchemes.applicationTracking.stats.rejected.label", "Rejected"),
100
- value: ie,
101
- icon: /* @__PURE__ */ D(T, { className: "h-4 w-4" })
120
+ /* @__PURE__ */ O(o, {
121
+ label: n("healthybowl.governmentSchemes.applicationTracking.stats.rejected.label", "Rejected"),
122
+ value: _e,
123
+ icon: /* @__PURE__ */ O(E, { className: "h-4 w-4" })
102
124
  })
103
125
  ]
104
126
  }),
105
- /* @__PURE__ */ D(l, {
106
- searchValue: q,
107
- onSearchChange: J,
108
- searchPlaceholder: t("healthybowl.governmentSchemes.applicationTracking.searchPlaceholder", "Search by scheme name..."),
109
- filters: /* @__PURE__ */ D("div", {
127
+ /* @__PURE__ */ O(u, {
128
+ searchValue: Q,
129
+ onSearchChange: ue,
130
+ searchPlaceholder: n("healthybowl.governmentSchemes.applicationTracking.searchPlaceholder", "Search by scheme name..."),
131
+ filters: /* @__PURE__ */ O("div", {
110
132
  className: "flex flex-wrap items-center gap-1.5",
111
- children: te.map((t) => /* @__PURE__ */ D("button", {
133
+ children: H.map((e) => /* @__PURE__ */ O("button", {
112
134
  type: "button",
113
- onClick: () => K(t.value),
114
- className: e("rounded-full px-3 py-1 text-xs font-medium transition-colors", G === t.value ? "bg-action-primary-bg text-action-primary-text" : "bg-bg-sunken text-text-secondary hover:bg-bg-sunken/80"),
115
- children: t.label
116
- }, t.value))
135
+ onClick: () => le(e.value),
136
+ className: t("rounded-full px-3 py-1 text-xs font-medium transition-colors", Z === e.value ? "bg-action-primary-bg text-action-primary-text" : "bg-bg-sunken text-text-secondary hover:bg-bg-sunken/80"),
137
+ children: e.label
138
+ }, e.value))
117
139
  }),
118
- actions: /* @__PURE__ */ O(k, {
140
+ actions: /* @__PURE__ */ k(A, {
119
141
  variant: "default",
120
142
  size: "sm",
121
- onClick: () => V(H("government-schemes/discover")),
143
+ onClick: () => U(W("government-schemes/discover")),
122
144
  children: [
123
- /* @__PURE__ */ D(w, { className: "h-3.5 w-3.5" }),
145
+ /* @__PURE__ */ O(T, { className: "h-3.5 w-3.5" }),
124
146
  " ",
125
- t("healthybowl.governmentSchemes.applicationTracking.actions.newApplication", "New Application")
147
+ n("healthybowl.governmentSchemes.applicationTracking.actions.newApplication", "New Application")
126
148
  ]
127
149
  })
128
150
  }),
129
- B.length > 0 && /* @__PURE__ */ D("div", {
151
+ V.length > 0 && /* @__PURE__ */ O("div", {
130
152
  className: "space-y-3",
131
- children: B.map((t) => {
132
- let n = t.status === "FAILED";
133
- return /* @__PURE__ */ O("div", {
134
- className: e("flex items-center gap-3 rounded-lg border border-dashed p-4", n ? "border-status-error-border bg-status-error-bgSubtle" : "border-border-subtle bg-bg-sunken"),
153
+ children: V.map((e) => {
154
+ let n = e.status === "FAILED";
155
+ return /* @__PURE__ */ k("div", {
156
+ className: t("flex items-center gap-3 rounded-lg border border-dashed p-4", n ? "border-status-error-border bg-status-error-bgSubtle" : "border-border-subtle bg-bg-sunken"),
135
157
  children: [
136
- /* @__PURE__ */ D("div", {
158
+ /* @__PURE__ */ O("div", {
137
159
  className: "rounded-md bg-bg-surface p-2",
138
- children: n ? /* @__PURE__ */ D(T, { className: "h-5 w-5 text-status-error-text" }) : /* @__PURE__ */ D(x, { className: "h-5 w-5 text-text-secondary" })
160
+ children: n ? /* @__PURE__ */ O(E, { className: "h-5 w-5 text-status-error-text" }) : /* @__PURE__ */ O(ie, { className: "h-5 w-5 text-text-secondary" })
139
161
  }),
140
- /* @__PURE__ */ O("div", {
162
+ /* @__PURE__ */ k("div", {
141
163
  className: "min-w-0 flex-1",
142
- children: [/* @__PURE__ */ D("p", {
164
+ children: [/* @__PURE__ */ O("p", {
143
165
  className: "truncate text-sm font-semibold text-text-primary",
144
- children: t.label
145
- }), /* @__PURE__ */ D("p", {
166
+ children: e.label
167
+ }), /* @__PURE__ */ O("p", {
146
168
  className: "mt-0.5 text-xs text-text-secondary",
147
- children: n ? t.message ?? "This application was refused and has not been submitted." : "Saved on this device — it will be submitted automatically when you have a connection."
169
+ children: n ? e.message ?? "This application was refused and has not been submitted." : "Saved on this device — it will be submitted automatically when you have a connection."
148
170
  })]
149
171
  }),
150
- /* @__PURE__ */ D("span", {
151
- className: e("shrink-0 rounded-full px-2.5 py-0.5 text-xs font-semibold", n ? "bg-status-error-bgSubtle text-status-error-text" : "bg-status-warning-bgSubtle text-status-warning-text"),
172
+ /* @__PURE__ */ O("span", {
173
+ className: t("shrink-0 rounded-full px-2.5 py-0.5 text-xs font-semibold", n ? "bg-status-error-bgSubtle text-status-error-text" : "bg-status-warning-bgSubtle text-status-warning-text"),
152
174
  children: n ? "Not submitted" : "Queued"
153
175
  })
154
176
  ]
155
- }, t.clientId);
177
+ }, e.clientId);
156
178
  })
157
179
  }),
158
- $.length === 0 ? L.government ? /* @__PURE__ */ D(d, {}) : I.government ? /* @__PURE__ */ D(c, { onRetry: R }) : /* @__PURE__ */ D(s, {
180
+ $.length === 0 ? R.government ? /* @__PURE__ */ O(p, {}) : L.government ? /* @__PURE__ */ O(l, { onRetry: z }) : /* @__PURE__ */ O(c, {
159
181
  illustration: "empty-files",
160
- title: t("healthybowl.governmentSchemes.applicationTracking.emptyState.title", "No Applications Found"),
161
- description: G === "all" ? t("healthybowl.governmentSchemes.applicationTracking.emptyState.message", "You have not submitted any applications yet.") : t("healthybowl.governmentSchemes.applicationTracking.emptyState.filteredMessage", "No applications match the selected filter."),
162
- action: /* @__PURE__ */ D(k, {
182
+ title: n("healthybowl.governmentSchemes.applicationTracking.emptyState.title", "No Applications Found"),
183
+ description: Z === "all" ? n("healthybowl.governmentSchemes.applicationTracking.emptyState.message", "You have not submitted any applications yet.") : n("healthybowl.governmentSchemes.applicationTracking.emptyState.filteredMessage", "No applications match the selected filter."),
184
+ action: /* @__PURE__ */ O(A, {
163
185
  variant: "default",
164
- onClick: () => V(H("government-schemes/discover")),
165
- children: t("healthybowl.governmentSchemes.applicationTracking.actions.browseSchemes", "Browse Schemes")
186
+ onClick: () => U(W("government-schemes/discover")),
187
+ children: n("healthybowl.governmentSchemes.applicationTracking.actions.browseSchemes", "Browse Schemes")
166
188
  })
167
- }) : /* @__PURE__ */ D("div", {
189
+ }) : /* @__PURE__ */ O("div", {
168
190
  className: "space-y-4",
169
- children: $.map((r) => {
170
- let i = Y === r.id, a = r.status === "rejected", s = M(r.status), c = Z.get(r.schemeId);
171
- return /* @__PURE__ */ O("div", {
191
+ children: $.map((e) => {
192
+ let i = de === e.id, a = Y ? v(e.status) : [], o = e.status === "rejected", c = N(e.status), l = pe.get(e.schemeId);
193
+ return /* @__PURE__ */ k("div", {
172
194
  className: "rounded-lg border border-border-subtle bg-bg-surface",
173
- children: [/* @__PURE__ */ O("button", {
195
+ children: [/* @__PURE__ */ k("button", {
174
196
  type: "button",
175
- onClick: () => X(i ? null : r.id),
197
+ onClick: () => fe(i ? null : e.id),
176
198
  className: "flex w-full items-center justify-between p-5 text-start",
177
- children: [/* @__PURE__ */ O("div", {
199
+ children: [/* @__PURE__ */ k("div", {
178
200
  className: "flex items-center gap-3",
179
- children: [/* @__PURE__ */ D("div", {
201
+ children: [/* @__PURE__ */ O("div", {
180
202
  className: "rounded-md bg-bg-sunken p-2",
181
- children: /* @__PURE__ */ D(C, { className: "h-5 w-5 text-text-secondary" })
182
- }), /* @__PURE__ */ O("div", { children: [/* @__PURE__ */ D("p", {
203
+ children: /* @__PURE__ */ O(w, { className: "h-5 w-5 text-text-secondary" })
204
+ }), /* @__PURE__ */ k("div", { children: [/* @__PURE__ */ O("p", {
183
205
  className: "text-sm font-semibold text-text-primary",
184
- children: r.schemeName
185
- }), /* @__PURE__ */ D("p", {
206
+ children: e.schemeName
207
+ }), /* @__PURE__ */ O("p", {
186
208
  className: "mt-0.5 text-xs text-text-secondary",
187
- children: t("healthybowl.governmentSchemes.applicationTracking.card.applied", "Applied: {{date}}", { date: n(r.appliedDate) })
209
+ children: n("healthybowl.governmentSchemes.applicationTracking.card.applied", "Applied: {{date}}", { date: r(e.appliedDate) })
188
210
  })] })]
189
- }), /* @__PURE__ */ O("div", {
211
+ }), /* @__PURE__ */ k("div", {
190
212
  className: "flex items-center gap-3",
191
213
  children: [
192
- r.amount != null && /* @__PURE__ */ D("span", {
214
+ e.amount != null && /* @__PURE__ */ O("span", {
193
215
  className: "text-sm font-medium text-text-primary",
194
- children: N(r.amount, c)
216
+ children: P(e.amount, l)
195
217
  }),
196
- /* @__PURE__ */ D(o, {
197
- label: (r.status ?? "unknown").replace(/_/g, " "),
198
- variant: A(r.status ?? "unknown")
218
+ /* @__PURE__ */ O(s, {
219
+ label: (e.status ?? "unknown").replace(/_/g, " "),
220
+ variant: j(e.status ?? "unknown")
199
221
  }),
200
- D(i ? y : v, { className: "h-4 w-4 text-text-secondary" })
222
+ O(i ? C : S, { className: "h-4 w-4 text-text-secondary" })
201
223
  ]
202
224
  })]
203
- }), i && /* @__PURE__ */ O("div", {
225
+ }), i && /* @__PURE__ */ k("div", {
204
226
  className: "border-t border-border-subtle px-5 pb-5 pt-4",
205
- children: [/* @__PURE__ */ O("div", {
206
- className: "mb-4",
207
- children: [/* @__PURE__ */ D("p", {
208
- className: "mb-3 text-xs font-medium text-text-primary",
209
- children: t("healthybowl.governmentSchemes.applicationTracking.progress.heading", "Application Progress")
210
- }), /* @__PURE__ */ D("div", {
211
- className: "flex items-center",
212
- children: j.map((t, n) => {
213
- let r = !a && n <= s, i = !a && n === s, o = a && n === 1;
214
- return /* @__PURE__ */ O("div", {
215
- className: "flex flex-1 items-center",
216
- children: [/* @__PURE__ */ O("div", {
217
- className: "flex flex-col items-center",
218
- children: [/* @__PURE__ */ D("div", {
219
- className: e("flex h-8 w-8 items-center justify-center rounded-full border-2", o ? "border-status-error-border bg-status-error-bg/10" : r ? "border-primary bg-action-primary-bg" : "border-border-subtle bg-bg-surface"),
220
- children: o ? /* @__PURE__ */ D(T, { className: "h-4 w-4 text-status-error-text" }) : r ? /* @__PURE__ */ D(_, { className: "h-4 w-4 text-action-primary-text" }) : /* @__PURE__ */ D("span", {
221
- className: "text-xs text-text-secondary",
222
- children: n + 1
223
- })
224
- }), /* @__PURE__ */ D("span", {
225
- className: e("mt-1 text-[10px] capitalize", i || o ? "font-semibold text-text-primary" : "text-text-secondary"),
226
- children: t.replace(/_/g, " ")
227
- })]
228
- }), n < j.length - 1 && /* @__PURE__ */ D("div", { className: e("mx-1 h-0.5 flex-1", !a && n < s ? "bg-action-primary-bg" : "bg-border") })]
229
- }, t);
230
- })
231
- })]
232
- }), /* @__PURE__ */ O("div", {
233
- className: "grid gap-3 sm:grid-cols-2",
234
- children: [
235
- /* @__PURE__ */ O("div", {
236
- className: "rounded-md bg-bg-sunken p-3",
237
- children: [/* @__PURE__ */ D("p", {
238
- className: "text-xs text-text-secondary",
239
- children: t("healthybowl.governmentSchemes.applicationTracking.details.scheme.label", "Scheme")
240
- }), /* @__PURE__ */ D("p", {
241
- className: "text-sm font-medium text-text-primary",
242
- children: r.schemeName
243
- })]
244
- }),
245
- /* @__PURE__ */ O("div", {
246
- className: "rounded-md bg-bg-sunken p-3",
247
- children: [/* @__PURE__ */ D("p", {
248
- className: "text-xs text-text-secondary",
249
- children: t("healthybowl.governmentSchemes.applicationTracking.details.appliedDate.label", "Applied Date")
250
- }), /* @__PURE__ */ D("p", {
251
- className: "text-sm font-medium text-text-primary",
252
- children: n(r.appliedDate)
253
- })]
254
- }),
255
- r.amount != null && /* @__PURE__ */ O("div", {
256
- className: "rounded-md bg-bg-sunken p-3",
257
- children: [/* @__PURE__ */ D("p", {
258
- className: "text-xs text-text-secondary",
259
- children: t("healthybowl.governmentSchemes.applicationTracking.details.amount.label", "Amount")
260
- }), /* @__PURE__ */ D("p", {
261
- className: "text-sm font-medium text-text-primary",
262
- children: N(r.amount, c)
263
- })]
264
- }),
265
- r.remarks && /* @__PURE__ */ O("div", {
266
- className: "rounded-md bg-bg-sunken p-3 sm:col-span-2",
267
- children: [/* @__PURE__ */ D("p", {
268
- className: "text-xs text-text-secondary",
269
- children: t("healthybowl.governmentSchemes.applicationTracking.details.remarks.label", "Remarks")
270
- }), /* @__PURE__ */ D("p", {
271
- className: "text-sm text-text-primary",
272
- children: r.remarks
273
- })]
274
- })
275
- ]
276
- })]
227
+ children: [
228
+ /* @__PURE__ */ k("div", {
229
+ className: "mb-4",
230
+ children: [/* @__PURE__ */ O("p", {
231
+ className: "mb-3 text-xs font-medium text-text-primary",
232
+ children: n("healthybowl.governmentSchemes.applicationTracking.progress.heading", "Application Progress")
233
+ }), /* @__PURE__ */ O("div", {
234
+ className: "flex items-center",
235
+ children: M.map((e, n) => {
236
+ let r = !o && n <= c, i = !o && n === c, a = o && n === 1;
237
+ return /* @__PURE__ */ k("div", {
238
+ className: "flex flex-1 items-center",
239
+ children: [/* @__PURE__ */ k("div", {
240
+ className: "flex flex-col items-center",
241
+ children: [/* @__PURE__ */ O("div", {
242
+ className: t("flex h-8 w-8 items-center justify-center rounded-full border-2", a ? "border-status-error-border bg-status-error-bg/10" : r ? "border-primary bg-action-primary-bg" : "border-border-subtle bg-bg-surface"),
243
+ children: a ? /* @__PURE__ */ O(E, { className: "h-4 w-4 text-status-error-text" }) : r ? /* @__PURE__ */ O(x, { className: "h-4 w-4 text-action-primary-text" }) : /* @__PURE__ */ O("span", {
244
+ className: "text-xs text-text-secondary",
245
+ children: n + 1
246
+ })
247
+ }), /* @__PURE__ */ O("span", {
248
+ className: t("mt-1 text-[10px] capitalize", i || a ? "font-semibold text-text-primary" : "text-text-secondary"),
249
+ children: e.replace(/_/g, " ")
250
+ })]
251
+ }), n < M.length - 1 && /* @__PURE__ */ O("div", { className: t("mx-1 h-0.5 flex-1", !o && n < c ? "bg-action-primary-bg" : "bg-border") })]
252
+ }, e);
253
+ })
254
+ })]
255
+ }),
256
+ /* @__PURE__ */ k("div", {
257
+ className: "grid gap-3 sm:grid-cols-2",
258
+ children: [
259
+ /* @__PURE__ */ k("div", {
260
+ className: "rounded-md bg-bg-sunken p-3",
261
+ children: [/* @__PURE__ */ O("p", {
262
+ className: "text-xs text-text-secondary",
263
+ children: n("healthybowl.governmentSchemes.applicationTracking.details.scheme.label", "Scheme")
264
+ }), /* @__PURE__ */ O("p", {
265
+ className: "text-sm font-medium text-text-primary",
266
+ children: e.schemeName
267
+ })]
268
+ }),
269
+ /* @__PURE__ */ k("div", {
270
+ className: "rounded-md bg-bg-sunken p-3",
271
+ children: [/* @__PURE__ */ O("p", {
272
+ className: "text-xs text-text-secondary",
273
+ children: n("healthybowl.governmentSchemes.applicationTracking.details.appliedDate.label", "Applied Date")
274
+ }), /* @__PURE__ */ O("p", {
275
+ className: "text-sm font-medium text-text-primary",
276
+ children: r(e.appliedDate)
277
+ })]
278
+ }),
279
+ e.amount != null && /* @__PURE__ */ k("div", {
280
+ className: "rounded-md bg-bg-sunken p-3",
281
+ children: [/* @__PURE__ */ O("p", {
282
+ className: "text-xs text-text-secondary",
283
+ children: n("healthybowl.governmentSchemes.applicationTracking.details.amount.label", "Amount")
284
+ }), /* @__PURE__ */ O("p", {
285
+ className: "text-sm font-medium text-text-primary",
286
+ children: P(e.amount, l)
287
+ })]
288
+ }),
289
+ e.remarks && /* @__PURE__ */ k("div", {
290
+ className: "rounded-md bg-bg-sunken p-3 sm:col-span-2",
291
+ children: [/* @__PURE__ */ O("p", {
292
+ className: "text-xs text-text-secondary",
293
+ children: n("healthybowl.governmentSchemes.applicationTracking.details.remarks.label", "Remarks")
294
+ }), /* @__PURE__ */ O("p", {
295
+ className: "text-sm text-text-primary",
296
+ children: e.remarks
297
+ })]
298
+ })
299
+ ]
300
+ }),
301
+ Y && a.length > 0 ? /* @__PURE__ */ k("div", {
302
+ className: "mt-3 flex flex-wrap items-center gap-2 border-t border-border-subtle pt-3",
303
+ children: [/* @__PURE__ */ O("span", {
304
+ className: "text-xs text-text-secondary",
305
+ children: n("healthybowl.governmentSchemes.tracking.moveTo", "Move this application to:")
306
+ }), a.map((t) => /* @__PURE__ */ O(A, {
307
+ size: "sm",
308
+ variant: t.destructive ? "outline" : "default",
309
+ disabled: X !== null,
310
+ onClick: () => {
311
+ ce(e, t);
312
+ },
313
+ children: X === e.id ? n("common.saving", "Saving…") : n(t.labelKey, t.labelFallback)
314
+ }, t.status))]
315
+ }) : null
316
+ ]
277
317
  })]
278
- }, r.id);
318
+ }, e.id);
279
319
  })
280
320
  }),
281
- /* @__PURE__ */ D(u, {
282
- toasts: U,
283
- onDismiss: W
321
+ /* @__PURE__ */ O(d, {
322
+ toasts: K,
323
+ onDismiss: q
284
324
  })
285
325
  ]
286
326
  });
287
327
  };
288
328
  //#endregion
289
- export { P as ApplicationTrackingPage };
329
+ export { F as ApplicationTrackingPage };
290
330
 
291
331
  //# sourceMappingURL=ApplicationTrackingPage.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ApplicationTrackingPage.js","names":[],"sources":["../../../../src/healthybowl/pages/government-schemes/ApplicationTrackingPage.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { useNavigate } from 'react-router';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { FileText, CheckCircle, Clock, XCircle, ChevronDown, ChevronUp, Plus, Landmark, CloudOff } from 'lucide-react';\nimport { PageLayout, StatCard, StatusBadge, FilterBar, EmptyState, ErrorState, PageLoader } from '../../components';\nimport { ToastContainer } from '../../components/Toast';\nimport { useToast } from '../../hooks/useToast';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport { useHealthyBowlData } from '../../hooks/useHealthyBowlData';\nimport { useOfflineSync } from '../../offline/OfflineSyncProvider';\nimport { formatDate, formatCurrency, cn } from '../../utils/helpers';\nimport type { SchemeApplication } from '../../types';\n\ntype StatusFilter = 'all' | SchemeApplication['status'];\n\nconst statusVariant = (s: string) => {\n switch (s) {\n case 'approved':\n case 'disbursed':\n return 'success' as const;\n case 'under_review':\n return 'warning' as const;\n case 'submitted':\n return 'info' as const;\n case 'rejected':\n return 'error' as const;\n default:\n return 'default' as const;\n }\n};\n\nconst statusSteps = ['submitted', 'under_review', 'approved', 'disbursed'] as const;\n\nconst getStepIndex = (status: string): number => {\n if (status === 'rejected') return 1;\n const idx = statusSteps.indexOf(status as (typeof statusSteps)[number]);\n return idx >= 0 ? idx : 0;\n};\n\nfunction formatApplicationAmount(amount: number, currency: string | undefined): string {\n return currency\n ? formatCurrency(amount, currency)\n : new Intl.NumberFormat(undefined, { maximumFractionDigits: 2 }).format(amount);\n}\n\nexport const ApplicationTrackingPage = () => {\n const { t } = useI18n();\n const { schemeApplications, governmentSchemes, errors, loadings, refetch } = useHealthyBowlData();\n const { pendingMutations } = useOfflineSync();\n // Only what has NOT reached the server. A SYNCED row is already in\n // `schemeApplications` below — showing both would look like two applications.\n const queuedApplications = pendingMutations.filter((m) => m.status !== 'SYNCED');\n\n const statusFilters: { value: StatusFilter; label: string }[] = [\n { value: 'all', label: t('healthybowl.common.all', 'All') },\n {\n value: 'submitted',\n label: t('healthybowl.governmentSchemes.applicationTracking.filters.submitted', 'Submitted'),\n },\n {\n value: 'under_review',\n label: t('healthybowl.governmentSchemes.applicationTracking.filters.underReview', 'Under Review'),\n },\n { value: 'approved', label: t('healthybowl.governmentSchemes.applicationTracking.filters.approved', 'Approved') },\n { value: 'rejected', label: t('healthybowl.governmentSchemes.applicationTracking.filters.rejected', 'Rejected') },\n {\n value: 'disbursed',\n label: t('healthybowl.governmentSchemes.applicationTracking.filters.disbursed', 'Disbursed'),\n },\n ];\n\n const navigate = useNavigate();\n const { buildPath } = useBasePath();\n const { toasts, dismiss } = useToast();\n const [statusFilter, setStatusFilter] = useState<StatusFilter>('all');\n const [search, setSearch] = useState('');\n const [expandedId, setExpandedId] = useState<string | null>(null);\n const schemeCurrencyById = useMemo(\n () => new Map(governmentSchemes.map((scheme) => [scheme.id, scheme.currency])),\n [governmentSchemes]\n );\n\n const totalApps = schemeApplications.length;\n const approvedCount = schemeApplications.filter((a) => a.status === 'approved' || a.status === 'disbursed').length;\n const underReviewCount = schemeApplications.filter((a) => a.status === 'under_review').length;\n const rejectedCount = schemeApplications.filter((a) => a.status === 'rejected').length;\n\n const filtered = schemeApplications.filter((a) => {\n const matchesStatus = statusFilter === 'all' || a.status === statusFilter;\n const matchesSearch = search === '' || (a.schemeName ?? '').toLowerCase().includes(search.toLowerCase());\n return matchesStatus && matchesSearch;\n });\n\n return (\n <PageLayout\n title={t('healthybowl.governmentSchemes.applicationTracking.title', 'Application Tracking')}\n description={t('healthybowl.governmentSchemes.applicationTracking.description', 'Track your scheme applications')}\n purpose=\"Follow every scheme application from submitted to approved. See what's pending, what needs more documents, and what's been granted — so nothing stalls and you can chase up anything that's stuck.\"\n >\n {/* Stats */}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <StatCard\n hero\n label={t('healthybowl.governmentSchemes.applicationTracking.stats.total.label', 'Total Applications')}\n value={totalApps}\n icon={<FileText className=\"h-4 w-4\" />}\n />\n <StatCard\n label={t('healthybowl.governmentSchemes.applicationTracking.stats.approved.label', 'Approved')}\n value={approvedCount}\n icon={<CheckCircle className=\"h-4 w-4\" />}\n />\n <StatCard\n label={t('healthybowl.governmentSchemes.applicationTracking.stats.underReview.label', 'Under Review')}\n value={underReviewCount}\n icon={<Clock className=\"h-4 w-4\" />}\n />\n <StatCard\n label={t('healthybowl.governmentSchemes.applicationTracking.stats.rejected.label', 'Rejected')}\n value={rejectedCount}\n icon={<XCircle className=\"h-4 w-4\" />}\n />\n </div>\n\n {/* Filters */}\n <FilterBar\n searchValue={search}\n onSearchChange={setSearch}\n searchPlaceholder={t(\n 'healthybowl.governmentSchemes.applicationTracking.searchPlaceholder',\n 'Search by scheme name...'\n )}\n filters={\n <div className=\"flex flex-wrap items-center gap-1.5\">\n {statusFilters.map((sf) => (\n <button\n key={sf.value}\n type=\"button\"\n onClick={() => setStatusFilter(sf.value)}\n className={cn(\n 'rounded-full px-3 py-1 text-xs font-medium transition-colors',\n statusFilter === sf.value\n ? 'bg-action-primary-bg text-action-primary-text'\n : 'bg-bg-sunken text-text-secondary hover:bg-bg-sunken/80'\n )}\n >\n {sf.label}\n </button>\n ))}\n </div>\n }\n actions={\n <Button variant=\"default\" size=\"sm\" onClick={() => navigate(buildPath('government-schemes/discover'))}>\n <Plus className=\"h-3.5 w-3.5\" />{' '}\n {t('healthybowl.governmentSchemes.applicationTracking.actions.newApplication', 'New Application')}\n </Button>\n }\n />\n\n {/* Queued offline, not yet on the server (BOFF-6179). Rendered ABOVE the\n server list and outside the empty-state branch: a farmer who applied\n with no signal has no server rows at all, and \"You have not submitted\n any applications yet\" would read as though the application was lost. */}\n {queuedApplications.length > 0 && (\n <div className=\"space-y-3\">\n {queuedApplications.map((mutation) => {\n const failed = mutation.status === 'FAILED';\n return (\n <div\n key={mutation.clientId}\n className={cn(\n 'flex items-center gap-3 rounded-lg border border-dashed p-4',\n failed ? 'border-status-error-border bg-status-error-bgSubtle' : 'border-border-subtle bg-bg-sunken'\n )}\n >\n <div className=\"rounded-md bg-bg-surface p-2\">\n {failed ? (\n <XCircle className=\"h-5 w-5 text-status-error-text\" />\n ) : (\n <CloudOff className=\"h-5 w-5 text-text-secondary\" />\n )}\n </div>\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-sm font-semibold text-text-primary\">{mutation.label}</p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {failed\n ? (mutation.message ?? 'This application was refused and has not been submitted.')\n : 'Saved on this device — it will be submitted automatically when you have a connection.'}\n </p>\n </div>\n <span\n className={cn(\n 'shrink-0 rounded-full px-2.5 py-0.5 text-xs font-semibold',\n failed\n ? 'bg-status-error-bgSubtle text-status-error-text'\n : 'bg-status-warning-bgSubtle text-status-warning-text'\n )}\n >\n {failed ? 'Not submitted' : 'Queued'}\n </span>\n </div>\n );\n })}\n </div>\n )}\n\n {/* Application Cards */}\n {filtered.length === 0 ? (\n loadings.government ? (\n <PageLoader />\n ) : errors.government ? (\n <ErrorState onRetry={refetch} />\n ) : (\n <EmptyState\n illustration=\"empty-files\"\n title={t('healthybowl.governmentSchemes.applicationTracking.emptyState.title', 'No Applications Found')}\n description={\n statusFilter !== 'all'\n ? t(\n 'healthybowl.governmentSchemes.applicationTracking.emptyState.filteredMessage',\n 'No applications match the selected filter.'\n )\n : t(\n 'healthybowl.governmentSchemes.applicationTracking.emptyState.message',\n 'You have not submitted any applications yet.'\n )\n }\n action={\n <Button variant=\"default\" onClick={() => navigate(buildPath('government-schemes/discover'))}>\n {t('healthybowl.governmentSchemes.applicationTracking.actions.browseSchemes', 'Browse Schemes')}\n </Button>\n }\n />\n )\n ) : (\n <div className=\"space-y-4\">\n {filtered.map((app) => {\n const isExpanded = expandedId === app.id;\n const isRejected = app.status === 'rejected';\n const currentStep = getStepIndex(app.status);\n const schemeCurrency = schemeCurrencyById.get(app.schemeId);\n\n return (\n <div key={app.id} className=\"rounded-lg border border-border-subtle bg-bg-surface\">\n {/* Card Header */}\n <button\n type=\"button\"\n onClick={() => setExpandedId(isExpanded ? null : app.id)}\n className=\"flex w-full items-center justify-between p-5 text-start\"\n >\n <div className=\"flex items-center gap-3\">\n <div className=\"rounded-md bg-bg-sunken p-2\">\n <Landmark className=\"h-5 w-5 text-text-secondary\" />\n </div>\n <div>\n <p className=\"text-sm font-semibold text-text-primary\">{app.schemeName}</p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {t('healthybowl.governmentSchemes.applicationTracking.card.applied', 'Applied: {{date}}', {\n date: formatDate(app.appliedDate),\n })}\n </p>\n </div>\n </div>\n <div className=\"flex items-center gap-3\">\n {app.amount != null && (\n <span className=\"text-sm font-medium text-text-primary\">\n {formatApplicationAmount(app.amount, schemeCurrency)}\n </span>\n )}\n <StatusBadge\n label={(app.status ?? 'unknown').replace(/_/g, ' ')}\n variant={statusVariant(app.status ?? 'unknown')}\n />\n {isExpanded ? (\n <ChevronUp className=\"h-4 w-4 text-text-secondary\" />\n ) : (\n <ChevronDown className=\"h-4 w-4 text-text-secondary\" />\n )}\n </div>\n </button>\n\n {/* Expanded Details */}\n {isExpanded && (\n <div className=\"border-t border-border-subtle px-5 pb-5 pt-4\">\n {/* Progress Tracker */}\n <div className=\"mb-4\">\n <p className=\"mb-3 text-xs font-medium text-text-primary\">\n {t(\n 'healthybowl.governmentSchemes.applicationTracking.progress.heading',\n 'Application Progress'\n )}\n </p>\n <div className=\"flex items-center\">\n {statusSteps.map((step, i) => {\n const isCompleted = !isRejected && i <= currentStep;\n const isCurrent = !isRejected && i === currentStep;\n const isRejectedStep = isRejected && i === 1;\n\n return (\n <div key={step} className=\"flex flex-1 items-center\">\n <div className=\"flex flex-col items-center\">\n <div\n className={cn(\n 'flex h-8 w-8 items-center justify-center rounded-full border-2',\n isRejectedStep\n ? 'border-status-error-border bg-status-error-bg/10'\n : isCompleted\n ? 'border-primary bg-action-primary-bg'\n : 'border-border-subtle bg-bg-surface'\n )}\n >\n {isRejectedStep ? (\n <XCircle className=\"h-4 w-4 text-status-error-text\" />\n ) : isCompleted ? (\n <CheckCircle className=\"h-4 w-4 text-action-primary-text\" />\n ) : (\n <span className=\"text-xs text-text-secondary\">{i + 1}</span>\n )}\n </div>\n <span\n className={cn(\n 'mt-1 text-[10px] capitalize',\n isCurrent || isRejectedStep\n ? 'font-semibold text-text-primary'\n : 'text-text-secondary'\n )}\n >\n {step.replace(/_/g, ' ')}\n </span>\n </div>\n {i < statusSteps.length - 1 && (\n <div\n className={cn(\n 'mx-1 h-0.5 flex-1',\n !isRejected && i < currentStep ? 'bg-action-primary-bg' : 'bg-border'\n )}\n />\n )}\n </div>\n );\n })}\n </div>\n </div>\n\n {/* Details */}\n <div className=\"grid gap-3 sm:grid-cols-2\">\n <div className=\"rounded-md bg-bg-sunken p-3\">\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.governmentSchemes.applicationTracking.details.scheme.label', 'Scheme')}\n </p>\n <p className=\"text-sm font-medium text-text-primary\">{app.schemeName}</p>\n </div>\n <div className=\"rounded-md bg-bg-sunken p-3\">\n <p className=\"text-xs text-text-secondary\">\n {t(\n 'healthybowl.governmentSchemes.applicationTracking.details.appliedDate.label',\n 'Applied Date'\n )}\n </p>\n <p className=\"text-sm font-medium text-text-primary\">{formatDate(app.appliedDate)}</p>\n </div>\n {app.amount != null && (\n <div className=\"rounded-md bg-bg-sunken p-3\">\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.governmentSchemes.applicationTracking.details.amount.label', 'Amount')}\n </p>\n <p className=\"text-sm font-medium text-text-primary\">\n {formatApplicationAmount(app.amount, schemeCurrency)}\n </p>\n </div>\n )}\n {app.remarks && (\n <div className=\"rounded-md bg-bg-sunken p-3 sm:col-span-2\">\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.governmentSchemes.applicationTracking.details.remarks.label', 'Remarks')}\n </p>\n <p className=\"text-sm text-text-primary\">{app.remarks}</p>\n </div>\n )}\n </div>\n </div>\n )}\n </div>\n );\n })}\n </div>\n )}\n\n <ToastContainer toasts={toasts} onDismiss={dismiss} />\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAgBA,IAAM,KAAiB,MAAc;CACnC,QAAQ,GAAR;EACE,KAAK;EACL,KAAK,aACH,OAAO;EACT,KAAK,gBACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,SACE,OAAO;CACX;AACF,GAEM,IAAc;CAAC;CAAa;CAAgB;CAAY;AAAW,GAEnE,KAAgB,MAA2B;CAC/C,IAAI,MAAW,YAAY,OAAO;CAClC,IAAM,IAAM,EAAY,QAAQ,CAAsC;CACtE,OAAO,KAAO,IAAI,IAAM;AAC1B;AAEA,SAAS,EAAwB,GAAgB,GAAsC;CACrF,OAAO,IACH,EAAe,GAAQ,CAAQ,IAC/B,IAAI,KAAK,aAAa,KAAA,GAAW,EAAE,uBAAuB,EAAE,CAAC,EAAE,OAAO,CAAM;AAClF;AAEA,IAAa,UAAgC;CAC3C,IAAM,EAAE,MAAM,EAAQ,GAChB,EAAE,uBAAoB,sBAAmB,WAAQ,aAAU,eAAY,GAAmB,GAC1F,EAAE,wBAAqB,EAAe,GAGtC,IAAqB,EAAiB,QAAQ,MAAM,EAAE,WAAW,QAAQ,GAEzE,KAA0D;EAC9D;GAAE,OAAO;GAAO,OAAO,EAAE,0BAA0B,KAAK;EAAE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A,CAAC,KAAc,IAAI,IAAc,yBAAyB,WAC5D,EACD,CAAA,CAEA;aAvCK,CAuCL;SAET,CAAC;QACE,CAAA,CACF;WAGL,kBAAC,OAAD;QAAK,WAAU;kBAAf;SACE,kBAAC,OAAD;UAAK,WAAU;oBAAf,CACE,kBAAC,KAAD;WAAG,WAAU;qBACV,EAAE,0EAA0E,QAAQ;UACpF,CAAA,GACH,kBAAC,KAAD;WAAG,WAAU;qBAAyC,EAAI;UAAc,CAAA,CACrE;;SACL,kBAAC,OAAD;UAAK,WAAU;oBAAf,CACE,kBAAC,KAAD;WAAG,WAAU;qBACV,EACC,+EACA,cACF;UACC,CAAA,GACH,kBAAC,KAAD;WAAG,WAAU;qBAAyC,EAAW,EAAI,WAAW;UAAK,CAAA,CAClF;;SACJ,EAAI,UAAU,QACb,kBAAC,OAAD;UAAK,WAAU;oBAAf,CACE,kBAAC,KAAD;WAAG,WAAU;qBACV,EAAE,0EAA0E,QAAQ;UACpF,CAAA,GACH,kBAAC,KAAD;WAAG,WAAU;qBACV,EAAwB,EAAI,QAAQ,CAAc;UAClD,CAAA,CACA;;SAEN,EAAI,WACH,kBAAC,OAAD;UAAK,WAAU;oBAAf,CACE,kBAAC,KAAD;WAAG,WAAU;qBACV,EAAE,2EAA2E,SAAS;UACtF,CAAA,GACH,kBAAC,KAAD;WAAG,WAAU;qBAA6B,EAAI;UAAW,CAAA,CACtD;;QAEJ;SACF;QAEJ;QA3IK,EAAI,EA2IT;IAET,CAAC;GACE,CAAA;GAGP,kBAAC,GAAD;IAAwB;IAAQ,WAAW;GAAU,CAAA;EAC3C;;AAEhB"}
1
+ {"version":3,"file":"ApplicationTrackingPage.js","names":[],"sources":["../../../../src/healthybowl/pages/government-schemes/ApplicationTrackingPage.tsx"],"sourcesContent":["import { useMemo, useState } from 'react';\nimport { useNavigate } from 'react-router';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\nimport { Button } from '@burdenoff/fe-libs/ui';\nimport { FileText, CheckCircle, Clock, XCircle, ChevronDown, ChevronUp, Plus, Landmark, CloudOff } from 'lucide-react';\nimport {\n PageLayout,\n StatCard,\n StatusBadge,\n FilterBar,\n EmptyState,\n ErrorState,\n PageLoader,\n useConfirm,\n} from '../../components';\nimport { ToastContainer } from '../../components/Toast';\nimport { useToast } from '../../hooks/useToast';\nimport { useBasePath } from '../../hooks/useBasePath';\nimport { useHealthyBowlData } from '../../hooks/useHealthyBowlData';\nimport { useHealthyBowl } from '../../context/HealthyBowlContext';\nimport { useCanManageGovernmentSchemes } from './useCanManageGovernmentSchemes';\nimport { useSchemeApplicationTransition } from './useSchemeApplicationTransition';\nimport {\n isTerminalSchemeApplicationStatus,\n transitionActionsFor,\n type TransitionAction,\n} from './schemeApplicationTransitions';\nimport { useOfflineSync } from '../../offline/OfflineSyncProvider';\nimport { formatDate, formatCurrency, cn } from '../../utils/helpers';\nimport type { SchemeApplication } from '../../types';\n\ntype StatusFilter = 'all' | SchemeApplication['status'];\n\nconst statusVariant = (s: string) => {\n switch (s) {\n case 'approved':\n case 'disbursed':\n return 'success' as const;\n case 'under_review':\n return 'warning' as const;\n case 'submitted':\n return 'info' as const;\n case 'rejected':\n return 'error' as const;\n default:\n return 'default' as const;\n }\n};\n\nconst statusSteps = ['submitted', 'under_review', 'approved', 'disbursed'] as const;\n\nconst getStepIndex = (status: string): number => {\n if (status === 'rejected') return 1;\n const idx = statusSteps.indexOf(status as (typeof statusSteps)[number]);\n return idx >= 0 ? idx : 0;\n};\n\nfunction formatApplicationAmount(amount: number, currency: string | undefined): string {\n return currency\n ? formatCurrency(amount, currency)\n : new Intl.NumberFormat(undefined, { maximumFractionDigits: 2 }).format(amount);\n}\n\nexport const ApplicationTrackingPage = () => {\n const { t } = useI18n();\n const { schemeApplications, governmentSchemes, errors, loadings, refetch } = useHealthyBowlData();\n const { pendingMutations } = useOfflineSync();\n // Only what has NOT reached the server. A SYNCED row is already in\n // `schemeApplications` below — showing both would look like two applications.\n const queuedApplications = pendingMutations.filter((m) => m.status !== 'SYNCED');\n\n const statusFilters: { value: StatusFilter; label: string }[] = [\n { value: 'all', label: t('healthybowl.common.all', 'All') },\n {\n value: 'submitted',\n label: t('healthybowl.governmentSchemes.applicationTracking.filters.submitted', 'Submitted'),\n },\n {\n value: 'under_review',\n label: t('healthybowl.governmentSchemes.applicationTracking.filters.underReview', 'Under Review'),\n },\n { value: 'approved', label: t('healthybowl.governmentSchemes.applicationTracking.filters.approved', 'Approved') },\n { value: 'rejected', label: t('healthybowl.governmentSchemes.applicationTracking.filters.rejected', 'Rejected') },\n {\n value: 'disbursed',\n label: t('healthybowl.governmentSchemes.applicationTracking.filters.disbursed', 'Disbursed'),\n },\n ];\n\n const navigate = useNavigate();\n const { buildPath } = useBasePath();\n const { toast, toasts, dismiss } = useToast();\n // BOFF-6037 — officer-side transitions. `useCanManageGovernmentSchemes` fails OPEN, so this is a\n // UX affordance, not the access control: the gateway's @rbac directive is what actually refuses.\n const { workspaceId } = useHealthyBowl();\n const { canManage } = useCanManageGovernmentSchemes(workspaceId);\n const { transition, pendingId } = useSchemeApplicationTransition();\n const confirm = useConfirm();\n\n /**\n * Run a transition, confirming first when it cannot be undone.\n *\n * REJECTED and DISBURSED are terminal in the edge map — nothing moves an application out of\n * either — so a misclick permanently ends the application with no undo path. The `outline`\n * styling distinguishes rejection visually, which is not the same as asking.\n */\n const handleTransition = async (app: SchemeApplication, action: TransitionAction) => {\n if (isTerminalSchemeApplicationStatus(action.status)) {\n const ok = await confirm({\n title: t('healthybowl.governmentSchemes.tracking.confirm.title', 'This cannot be undone'),\n message: t(\n 'healthybowl.governmentSchemes.tracking.confirm.message',\n 'Moving this application to {{status}} is final — nothing can move it out of that state afterwards. The applicant is notified straight away.',\n { status: t(action.labelKey, action.labelFallback).toLowerCase() }\n ),\n okButtonTitle: t(action.labelKey, action.labelFallback),\n destructive: action.destructive,\n });\n if (!ok) return;\n }\n await transition(app.id, action.status, {\n onSuccess: () =>\n toast({\n title: t('healthybowl.governmentSchemes.tracking.toast.moved', 'Application updated'),\n variant: 'success',\n }),\n onError: (message) =>\n toast({\n title: t('healthybowl.governmentSchemes.tracking.toast.moveFailed', 'Could not update the application'),\n description: message,\n variant: 'error',\n }),\n });\n };\n const [statusFilter, setStatusFilter] = useState<StatusFilter>('all');\n const [search, setSearch] = useState('');\n const [expandedId, setExpandedId] = useState<string | null>(null);\n const schemeCurrencyById = useMemo(\n () => new Map(governmentSchemes.map((scheme) => [scheme.id, scheme.currency])),\n [governmentSchemes]\n );\n\n const totalApps = schemeApplications.length;\n const approvedCount = schemeApplications.filter((a) => a.status === 'approved' || a.status === 'disbursed').length;\n const underReviewCount = schemeApplications.filter((a) => a.status === 'under_review').length;\n const rejectedCount = schemeApplications.filter((a) => a.status === 'rejected').length;\n\n const filtered = schemeApplications.filter((a) => {\n const matchesStatus = statusFilter === 'all' || a.status === statusFilter;\n const matchesSearch = search === '' || (a.schemeName ?? '').toLowerCase().includes(search.toLowerCase());\n return matchesStatus && matchesSearch;\n });\n\n return (\n <PageLayout\n title={t('healthybowl.governmentSchemes.applicationTracking.title', 'Application Tracking')}\n description={t('healthybowl.governmentSchemes.applicationTracking.description', 'Track your scheme applications')}\n purpose=\"Follow every scheme application from submitted to approved. See what's pending, what needs more documents, and what's been granted — so nothing stalls and you can chase up anything that's stuck.\"\n >\n {/* Stats */}\n <div className=\"grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4\">\n <StatCard\n hero\n label={t('healthybowl.governmentSchemes.applicationTracking.stats.total.label', 'Total Applications')}\n value={totalApps}\n icon={<FileText className=\"h-4 w-4\" />}\n />\n <StatCard\n label={t('healthybowl.governmentSchemes.applicationTracking.stats.approved.label', 'Approved')}\n value={approvedCount}\n icon={<CheckCircle className=\"h-4 w-4\" />}\n />\n <StatCard\n label={t('healthybowl.governmentSchemes.applicationTracking.stats.underReview.label', 'Under Review')}\n value={underReviewCount}\n icon={<Clock className=\"h-4 w-4\" />}\n />\n <StatCard\n label={t('healthybowl.governmentSchemes.applicationTracking.stats.rejected.label', 'Rejected')}\n value={rejectedCount}\n icon={<XCircle className=\"h-4 w-4\" />}\n />\n </div>\n\n {/* Filters */}\n <FilterBar\n searchValue={search}\n onSearchChange={setSearch}\n searchPlaceholder={t(\n 'healthybowl.governmentSchemes.applicationTracking.searchPlaceholder',\n 'Search by scheme name...'\n )}\n filters={\n <div className=\"flex flex-wrap items-center gap-1.5\">\n {statusFilters.map((sf) => (\n <button\n key={sf.value}\n type=\"button\"\n onClick={() => setStatusFilter(sf.value)}\n className={cn(\n 'rounded-full px-3 py-1 text-xs font-medium transition-colors',\n statusFilter === sf.value\n ? 'bg-action-primary-bg text-action-primary-text'\n : 'bg-bg-sunken text-text-secondary hover:bg-bg-sunken/80'\n )}\n >\n {sf.label}\n </button>\n ))}\n </div>\n }\n actions={\n <Button variant=\"default\" size=\"sm\" onClick={() => navigate(buildPath('government-schemes/discover'))}>\n <Plus className=\"h-3.5 w-3.5\" />{' '}\n {t('healthybowl.governmentSchemes.applicationTracking.actions.newApplication', 'New Application')}\n </Button>\n }\n />\n\n {/* Queued offline, not yet on the server (BOFF-6179). Rendered ABOVE the\n server list and outside the empty-state branch: a farmer who applied\n with no signal has no server rows at all, and \"You have not submitted\n any applications yet\" would read as though the application was lost. */}\n {queuedApplications.length > 0 && (\n <div className=\"space-y-3\">\n {queuedApplications.map((mutation) => {\n const failed = mutation.status === 'FAILED';\n return (\n <div\n key={mutation.clientId}\n className={cn(\n 'flex items-center gap-3 rounded-lg border border-dashed p-4',\n failed ? 'border-status-error-border bg-status-error-bgSubtle' : 'border-border-subtle bg-bg-sunken'\n )}\n >\n <div className=\"rounded-md bg-bg-surface p-2\">\n {failed ? (\n <XCircle className=\"h-5 w-5 text-status-error-text\" />\n ) : (\n <CloudOff className=\"h-5 w-5 text-text-secondary\" />\n )}\n </div>\n <div className=\"min-w-0 flex-1\">\n <p className=\"truncate text-sm font-semibold text-text-primary\">{mutation.label}</p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {failed\n ? (mutation.message ?? 'This application was refused and has not been submitted.')\n : 'Saved on this device — it will be submitted automatically when you have a connection.'}\n </p>\n </div>\n <span\n className={cn(\n 'shrink-0 rounded-full px-2.5 py-0.5 text-xs font-semibold',\n failed\n ? 'bg-status-error-bgSubtle text-status-error-text'\n : 'bg-status-warning-bgSubtle text-status-warning-text'\n )}\n >\n {failed ? 'Not submitted' : 'Queued'}\n </span>\n </div>\n );\n })}\n </div>\n )}\n\n {/* Application Cards */}\n {filtered.length === 0 ? (\n loadings.government ? (\n <PageLoader />\n ) : errors.government ? (\n <ErrorState onRetry={refetch} />\n ) : (\n <EmptyState\n illustration=\"empty-files\"\n title={t('healthybowl.governmentSchemes.applicationTracking.emptyState.title', 'No Applications Found')}\n description={\n statusFilter !== 'all'\n ? t(\n 'healthybowl.governmentSchemes.applicationTracking.emptyState.filteredMessage',\n 'No applications match the selected filter.'\n )\n : t(\n 'healthybowl.governmentSchemes.applicationTracking.emptyState.message',\n 'You have not submitted any applications yet.'\n )\n }\n action={\n <Button variant=\"default\" onClick={() => navigate(buildPath('government-schemes/discover'))}>\n {t('healthybowl.governmentSchemes.applicationTracking.actions.browseSchemes', 'Browse Schemes')}\n </Button>\n }\n />\n )\n ) : (\n <div className=\"space-y-4\">\n {filtered.map((app) => {\n const isExpanded = expandedId === app.id;\n // Computed once per card: the helper allocates a fresh array and fresh action objects\n // on every call, and it was being called twice per render.\n const transitionActions = canManage ? transitionActionsFor(app.status) : [];\n const isRejected = app.status === 'rejected';\n const currentStep = getStepIndex(app.status);\n const schemeCurrency = schemeCurrencyById.get(app.schemeId);\n\n return (\n <div key={app.id} className=\"rounded-lg border border-border-subtle bg-bg-surface\">\n {/* Card Header */}\n <button\n type=\"button\"\n onClick={() => setExpandedId(isExpanded ? null : app.id)}\n className=\"flex w-full items-center justify-between p-5 text-start\"\n >\n <div className=\"flex items-center gap-3\">\n <div className=\"rounded-md bg-bg-sunken p-2\">\n <Landmark className=\"h-5 w-5 text-text-secondary\" />\n </div>\n <div>\n <p className=\"text-sm font-semibold text-text-primary\">{app.schemeName}</p>\n <p className=\"mt-0.5 text-xs text-text-secondary\">\n {t('healthybowl.governmentSchemes.applicationTracking.card.applied', 'Applied: {{date}}', {\n date: formatDate(app.appliedDate),\n })}\n </p>\n </div>\n </div>\n <div className=\"flex items-center gap-3\">\n {app.amount != null && (\n <span className=\"text-sm font-medium text-text-primary\">\n {formatApplicationAmount(app.amount, schemeCurrency)}\n </span>\n )}\n <StatusBadge\n label={(app.status ?? 'unknown').replace(/_/g, ' ')}\n variant={statusVariant(app.status ?? 'unknown')}\n />\n {isExpanded ? (\n <ChevronUp className=\"h-4 w-4 text-text-secondary\" />\n ) : (\n <ChevronDown className=\"h-4 w-4 text-text-secondary\" />\n )}\n </div>\n </button>\n\n {/* Expanded Details */}\n {isExpanded && (\n <div className=\"border-t border-border-subtle px-5 pb-5 pt-4\">\n {/* Progress Tracker */}\n <div className=\"mb-4\">\n <p className=\"mb-3 text-xs font-medium text-text-primary\">\n {t(\n 'healthybowl.governmentSchemes.applicationTracking.progress.heading',\n 'Application Progress'\n )}\n </p>\n <div className=\"flex items-center\">\n {statusSteps.map((step, i) => {\n const isCompleted = !isRejected && i <= currentStep;\n const isCurrent = !isRejected && i === currentStep;\n const isRejectedStep = isRejected && i === 1;\n\n return (\n <div key={step} className=\"flex flex-1 items-center\">\n <div className=\"flex flex-col items-center\">\n <div\n className={cn(\n 'flex h-8 w-8 items-center justify-center rounded-full border-2',\n isRejectedStep\n ? 'border-status-error-border bg-status-error-bg/10'\n : isCompleted\n ? 'border-primary bg-action-primary-bg'\n : 'border-border-subtle bg-bg-surface'\n )}\n >\n {isRejectedStep ? (\n <XCircle className=\"h-4 w-4 text-status-error-text\" />\n ) : isCompleted ? (\n <CheckCircle className=\"h-4 w-4 text-action-primary-text\" />\n ) : (\n <span className=\"text-xs text-text-secondary\">{i + 1}</span>\n )}\n </div>\n <span\n className={cn(\n 'mt-1 text-[10px] capitalize',\n isCurrent || isRejectedStep\n ? 'font-semibold text-text-primary'\n : 'text-text-secondary'\n )}\n >\n {step.replace(/_/g, ' ')}\n </span>\n </div>\n {i < statusSteps.length - 1 && (\n <div\n className={cn(\n 'mx-1 h-0.5 flex-1',\n !isRejected && i < currentStep ? 'bg-action-primary-bg' : 'bg-border'\n )}\n />\n )}\n </div>\n );\n })}\n </div>\n </div>\n\n {/* Details */}\n <div className=\"grid gap-3 sm:grid-cols-2\">\n <div className=\"rounded-md bg-bg-sunken p-3\">\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.governmentSchemes.applicationTracking.details.scheme.label', 'Scheme')}\n </p>\n <p className=\"text-sm font-medium text-text-primary\">{app.schemeName}</p>\n </div>\n <div className=\"rounded-md bg-bg-sunken p-3\">\n <p className=\"text-xs text-text-secondary\">\n {t(\n 'healthybowl.governmentSchemes.applicationTracking.details.appliedDate.label',\n 'Applied Date'\n )}\n </p>\n <p className=\"text-sm font-medium text-text-primary\">{formatDate(app.appliedDate)}</p>\n </div>\n {app.amount != null && (\n <div className=\"rounded-md bg-bg-sunken p-3\">\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.governmentSchemes.applicationTracking.details.amount.label', 'Amount')}\n </p>\n <p className=\"text-sm font-medium text-text-primary\">\n {formatApplicationAmount(app.amount, schemeCurrency)}\n </p>\n </div>\n )}\n {app.remarks && (\n <div className=\"rounded-md bg-bg-sunken p-3 sm:col-span-2\">\n <p className=\"text-xs text-text-secondary\">\n {t('healthybowl.governmentSchemes.applicationTracking.details.remarks.label', 'Remarks')}\n </p>\n <p className=\"text-sm text-text-primary\">{app.remarks}</p>\n </div>\n )}\n </div>\n\n {/* Officer transitions (BOFF-6037). Only the edges the server will accept are\n offered — showing four buttons and letting three fail is worse than showing\n the two that work. A terminal application offers none. */}\n {canManage && transitionActions.length > 0 ? (\n <div className=\"mt-3 flex flex-wrap items-center gap-2 border-t border-border-subtle pt-3\">\n <span className=\"text-xs text-text-secondary\">\n {t('healthybowl.governmentSchemes.tracking.moveTo', 'Move this application to:')}\n </span>\n {transitionActions.map((action) => (\n <Button\n key={action.status}\n size=\"sm\"\n variant={action.destructive ? 'outline' : 'default'}\n disabled={pendingId !== null}\n onClick={() => {\n void handleTransition(app, action);\n }}\n >\n {pendingId === app.id\n ? t('common.saving', 'Saving…')\n : t(action.labelKey, action.labelFallback)}\n </Button>\n ))}\n </div>\n ) : null}\n </div>\n )}\n </div>\n );\n })}\n </div>\n )}\n\n <ToastContainer toasts={toasts} onDismiss={dismiss} />\n </PageLayout>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,IAAM,KAAiB,MAAc;CACnC,QAAQ,GAAR;EACE,KAAK;EACL,KAAK,aACH,OAAO;EACT,KAAK,gBACH,OAAO;EACT,KAAK,aACH,OAAO;EACT,KAAK,YACH,OAAO;EACT,SACE,OAAO;CACX;AACF,GAEM,IAAc;CAAC;CAAa;CAAgB;CAAY;AAAW,GAEnE,KAAgB,MAA2B;CAC/C,IAAI,MAAW,YAAY,OAAO;CAClC,IAAM,IAAM,EAAY,QAAQ,CAAsC;CACtE,OAAO,KAAO,IAAI,IAAM;AAC1B;AAEA,SAAS,EAAwB,GAAgB,GAAsC;CACrF,OAAO,IACH,EAAe,GAAQ,CAAQ,IAC/B,IAAI,KAAK,aAAa,KAAA,GAAW,EAAE,uBAAuB,EAAE,CAAC,EAAE,OAAO,CAAM;AAClF;AAEA,IAAa,UAAgC;CAC3C,IAAM,EAAE,SAAM,EAAQ,GAChB,EAAE,uBAAoB,sBAAmB,WAAQ,aAAU,eAAY,EAAmB,GAC1F,EAAE,wBAAqB,EAAe,GAGtC,IAAqB,EAAiB,QAAQ,MAAM,EAAE,WAAW,QAAQ,GAEzE,IAA0D;EAC9D;GAAE,OAAO;GAAO,OAAO,EAAE,0BAA0B,KAAK;EAAE;EAC1D;GACE,OAAO;GACP,OAAO,EAAE,uEAAuE,WAAW;EAC7F;EACA;GACE,OAAO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C,KAAD;YAAG,WAAU;sBACV,EAAwB,EAAI,QAAQ,CAAc;WAClD,CAAA,CACA;;UAEN,EAAI,WACH,kBAAC,OAAD;WAAK,WAAU;qBAAf,CACE,kBAAC,KAAD;YAAG,WAAU;sBACV,EAAE,2EAA2E,SAAS;WACtF,CAAA,GACH,kBAAC,KAAD;YAAG,WAAU;sBAA6B,EAAI;WAAW,CAAA,CACtD;;SAEJ;;QAKJ,KAAa,EAAkB,SAAS,IACvC,kBAAC,OAAD;SAAK,WAAU;mBAAf,CACE,kBAAC,QAAD;UAAM,WAAU;oBACb,EAAE,iDAAiD,2BAA2B;SAC3E,CAAA,GACL,EAAkB,KAAK,MACtB,kBAAC,GAAD;UAEE,MAAK;UACL,SAAS,EAAO,cAAc,YAAY;UAC1C,UAAU,MAAc;UACxB,eAAe;WACb,GAAsB,GAAK,CAAM;UACnC;oBAEC,MAAc,EAAI,KACf,EAAE,iBAAiB,SAAS,IAC5B,EAAE,EAAO,UAAU,EAAO,aAAa;SACrC,GAXD,EAAO,MAWN,CACT,CACE;aACH;OACD;QAEJ;QArKK,EAAI,EAqKT;IAET,CAAC;GACE,CAAA;GAGP,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,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"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burdenoff/microfe-healthybowl",
3
- "version": "2026.902.5",
3
+ "version": "2026.902.6",
4
4
  "description": "Burdenoff HealthyBowl Microfrontend - Comprehensive organic farming and agro-foods management platform",
5
5
  "type": "module",
6
6
  "files": [