@burdenoff/microfe-govcitizenhub 2026.828.1 → 2026.830.1
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.
- package/dist/govcitizenhub/GovCitizenHubRoot.d.ts.map +1 -1
- package/dist/govcitizenhub/GovCitizenHubRoot.js +69 -61
- package/dist/govcitizenhub/GovCitizenHubRoot.js.map +1 -1
- package/dist/govcitizenhub/components/StateViews.d.ts.map +1 -1
- package/dist/govcitizenhub/components/StateViews.js +36 -29
- package/dist/govcitizenhub/components/StateViews.js.map +1 -1
- package/dist/govcitizenhub/pages/DashboardPage.d.ts.map +1 -1
- package/dist/govcitizenhub/pages/DashboardPage.js +107 -102
- package/dist/govcitizenhub/pages/DashboardPage.js.map +1 -1
- package/dist/shared/hooks/useTr.d.ts +17 -0
- package/dist/shared/hooks/useTr.d.ts.map +1 -0
- package/dist/shared/hooks/useTr.js +14 -0
- package/dist/shared/hooks/useTr.js.map +1 -0
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GovCitizenHubRoot.d.ts","sourceRoot":"","sources":["../../src/govcitizenhub/GovCitizenHubRoot.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAA6B,KAAK,EAAE,EAAkB,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"GovCitizenHubRoot.d.ts","sourceRoot":"","sources":["../../src/govcitizenhub/GovCitizenHubRoot.tsx"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAA6B,KAAK,EAAE,EAAkB,MAAM,OAAO,CAAC;AAoB3E,OAAO,KAAK,EAAE,sBAAsB,EAAW,MAAM,SAAS,CAAC;AA4D/D,eAAO,MAAM,iBAAiB,EAAE,EAAE,CAAC,sBAAsB,CAqHxD,CAAC"}
|
|
@@ -1,17 +1,39 @@
|
|
|
1
1
|
import { joinPath as e } from "./utils/navigation.js";
|
|
2
2
|
import { GovCitizenHubProvider as t } from "./context/GovCitizenHubContext.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
3
|
+
import { useTr as n } from "../shared/hooks/useTr.js";
|
|
4
|
+
import { GovCitizenHubRoutes as r } from "./GovCitizenHubRoutes.js";
|
|
5
|
+
import { Component as i, useEffect as a } from "react";
|
|
6
|
+
import { QueryClient as o, QueryClientProvider as s } from "@tanstack/react-query";
|
|
7
|
+
import { FeatureFlagProvider as c } from "@burdenoff/fe-libs/shared/feature-flags";
|
|
8
|
+
import { BadgeCheck as l, Briefcase as u, Building2 as d, CreditCard as f, FileText as p, FolderOpen as m, Landmark as h, LayoutDashboard as g, MessageSquareWarning as _, ShieldQuestion as v } from "lucide-react";
|
|
9
|
+
import { jsx as y, jsxs as b } from "react/jsx-runtime";
|
|
9
10
|
//#region src/govcitizenhub/GovCitizenHubRoot.tsx
|
|
10
|
-
var
|
|
11
|
+
var x = new o({ defaultOptions: { queries: {
|
|
11
12
|
staleTime: 60 * 1e3,
|
|
12
13
|
retry: 1,
|
|
13
14
|
refetchOnWindowFocus: !1
|
|
14
|
-
} } }),
|
|
15
|
+
} } }), S = ({ message: e }) => {
|
|
16
|
+
let t = n();
|
|
17
|
+
return /* @__PURE__ */ b("div", {
|
|
18
|
+
className: "m-4 rounded-xl border border-border-seam bg-bg-surface p-6",
|
|
19
|
+
children: [
|
|
20
|
+
/* @__PURE__ */ y("h2", {
|
|
21
|
+
className: "text-lg font-semibold text-status-error-text",
|
|
22
|
+
children: t("govcitizenhub.errorTitle", "Something went wrong")
|
|
23
|
+
}),
|
|
24
|
+
/* @__PURE__ */ y("p", {
|
|
25
|
+
className: "mt-2 text-sm text-text-secondary",
|
|
26
|
+
children: e ?? t("govcitizenhub.errorFallback", "Unknown error")
|
|
27
|
+
}),
|
|
28
|
+
/* @__PURE__ */ y("button", {
|
|
29
|
+
type: "button",
|
|
30
|
+
onClick: () => window.location.reload(),
|
|
31
|
+
className: "mt-4 rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90",
|
|
32
|
+
children: t("common.reload", "Reload")
|
|
33
|
+
})
|
|
34
|
+
]
|
|
35
|
+
});
|
|
36
|
+
}, C = class extends i {
|
|
15
37
|
constructor(e) {
|
|
16
38
|
super(e), this.state = {
|
|
17
39
|
hasError: !1,
|
|
@@ -26,133 +48,119 @@ var b = new a({ defaultOptions: { queries: {
|
|
|
26
48
|
}
|
|
27
49
|
componentDidCatch(e, t) {}
|
|
28
50
|
render() {
|
|
29
|
-
return this.state.hasError ? /* @__PURE__ */ y(
|
|
30
|
-
className: "m-4 rounded-xl border border-border-seam bg-bg-surface p-6",
|
|
31
|
-
children: [
|
|
32
|
-
/* @__PURE__ */ v("h2", {
|
|
33
|
-
className: "text-lg font-semibold text-status-error-text",
|
|
34
|
-
children: "Something went wrong"
|
|
35
|
-
}),
|
|
36
|
-
/* @__PURE__ */ v("p", {
|
|
37
|
-
className: "mt-2 text-sm text-text-secondary",
|
|
38
|
-
children: this.state.message ?? "Unknown error"
|
|
39
|
-
}),
|
|
40
|
-
/* @__PURE__ */ v("button", {
|
|
41
|
-
type: "button",
|
|
42
|
-
onClick: () => window.location.reload(),
|
|
43
|
-
className: "mt-4 rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90",
|
|
44
|
-
children: "Reload"
|
|
45
|
-
})
|
|
46
|
-
]
|
|
47
|
-
}) : this.props.children;
|
|
51
|
+
return this.state.hasError ? /* @__PURE__ */ y(S, { message: this.state.message }) : this.props.children;
|
|
48
52
|
}
|
|
49
|
-
},
|
|
50
|
-
let { registerNavItems:
|
|
51
|
-
return
|
|
52
|
-
if (
|
|
53
|
+
}, w = (i) => {
|
|
54
|
+
let { registerNavItems: o, registerFooterItems: b, basePath: S = "/" } = i, w = n();
|
|
55
|
+
return a(() => {
|
|
56
|
+
if (o) return o([
|
|
53
57
|
{
|
|
54
58
|
id: "govcitizenhub-dashboard",
|
|
55
|
-
label: "Dashboard",
|
|
59
|
+
label: w("govcitizenhub.dashboard", "Dashboard"),
|
|
56
60
|
path: e(S, ""),
|
|
57
|
-
icon: /* @__PURE__ */
|
|
61
|
+
icon: /* @__PURE__ */ y(g, { size: 20 }),
|
|
58
62
|
order: 0,
|
|
59
63
|
group: "products"
|
|
60
64
|
},
|
|
61
65
|
{
|
|
62
66
|
id: "govcitizenhub-services",
|
|
63
|
-
label: "Services",
|
|
67
|
+
label: w("govcitizenhub.services", "Services"),
|
|
64
68
|
path: e(S, "services"),
|
|
65
|
-
icon: /* @__PURE__ */
|
|
69
|
+
icon: /* @__PURE__ */ y(u, { size: 20 }),
|
|
66
70
|
order: 1,
|
|
67
71
|
group: "products"
|
|
68
72
|
},
|
|
69
73
|
{
|
|
70
74
|
id: "govcitizenhub-applications",
|
|
71
|
-
label: "Applications",
|
|
75
|
+
label: w("govcitizenhub.applications", "Applications"),
|
|
72
76
|
path: e(S, "applications"),
|
|
73
|
-
icon: /* @__PURE__ */
|
|
77
|
+
icon: /* @__PURE__ */ y(p, { size: 20 }),
|
|
74
78
|
order: 2,
|
|
75
79
|
group: "products"
|
|
76
80
|
},
|
|
77
81
|
{
|
|
78
82
|
id: "govcitizenhub-agencies",
|
|
79
|
-
label: "Agencies",
|
|
83
|
+
label: w("govcitizenhub.agencies", "Agencies"),
|
|
80
84
|
path: e(S, "agencies"),
|
|
81
|
-
icon: /* @__PURE__ */
|
|
85
|
+
icon: /* @__PURE__ */ y(d, { size: 20 }),
|
|
82
86
|
order: 3,
|
|
83
87
|
group: "products"
|
|
84
88
|
},
|
|
85
89
|
{
|
|
86
90
|
id: "govcitizenhub-documents",
|
|
87
|
-
label: "Documents",
|
|
91
|
+
label: w("govcitizenhub.documents", "Documents"),
|
|
88
92
|
path: e(S, "documents"),
|
|
89
|
-
icon: /* @__PURE__ */
|
|
93
|
+
icon: /* @__PURE__ */ y(m, { size: 20 }),
|
|
90
94
|
order: 4,
|
|
91
95
|
group: "products"
|
|
92
96
|
},
|
|
93
97
|
{
|
|
94
98
|
id: "govcitizenhub-payments",
|
|
95
|
-
label: "Payments",
|
|
99
|
+
label: w("govcitizenhub.payments", "Payments"),
|
|
96
100
|
path: e(S, "payments"),
|
|
97
|
-
icon: /* @__PURE__ */
|
|
101
|
+
icon: /* @__PURE__ */ y(f, { size: 20 }),
|
|
98
102
|
order: 5,
|
|
99
103
|
group: "products"
|
|
100
104
|
},
|
|
101
105
|
{
|
|
102
106
|
id: "govcitizenhub-permits",
|
|
103
|
-
label: "Permits",
|
|
107
|
+
label: w("govcitizenhub.permits", "Permits"),
|
|
104
108
|
path: e(S, "permits"),
|
|
105
|
-
icon: /* @__PURE__ */
|
|
109
|
+
icon: /* @__PURE__ */ y(l, { size: 20 }),
|
|
106
110
|
order: 6,
|
|
107
111
|
group: "products"
|
|
108
112
|
},
|
|
109
113
|
{
|
|
110
114
|
id: "govcitizenhub-verify",
|
|
111
|
-
label: "Verify Permit",
|
|
115
|
+
label: w("govcitizenhub.verifyPermit", "Verify Permit"),
|
|
112
116
|
path: e(S, "permits/verify"),
|
|
113
|
-
icon: /* @__PURE__ */ v
|
|
117
|
+
icon: /* @__PURE__ */ y(v, { size: 20 }),
|
|
114
118
|
order: 7,
|
|
115
119
|
group: "products"
|
|
116
120
|
},
|
|
117
121
|
{
|
|
118
122
|
id: "govcitizenhub-grievances",
|
|
119
|
-
label: "Grievances",
|
|
123
|
+
label: w("govcitizenhub.grievances", "Grievances"),
|
|
120
124
|
path: e(S, "grievances"),
|
|
121
|
-
icon: /* @__PURE__ */
|
|
125
|
+
icon: /* @__PURE__ */ y(_, { size: 20 }),
|
|
122
126
|
order: 8,
|
|
123
127
|
group: "products"
|
|
124
128
|
},
|
|
125
129
|
{
|
|
126
130
|
id: "govcitizenhub-intelligence",
|
|
127
|
-
label: "Community Intelligence",
|
|
131
|
+
label: w("govcitizenhub.communityIntelligence", "Community Intelligence"),
|
|
128
132
|
path: e(S, "intelligence"),
|
|
129
|
-
icon: /* @__PURE__ */
|
|
133
|
+
icon: /* @__PURE__ */ y(h, { size: 20 }),
|
|
130
134
|
order: 9,
|
|
131
135
|
group: "products"
|
|
132
136
|
}
|
|
133
137
|
]);
|
|
134
|
-
}, [
|
|
135
|
-
|
|
138
|
+
}, [
|
|
139
|
+
o,
|
|
140
|
+
S,
|
|
141
|
+
w
|
|
142
|
+
]), a(() => {
|
|
143
|
+
if (b) return b([{
|
|
136
144
|
id: "govcitizenhub-status",
|
|
137
|
-
label: "GovCitizenHub Ready",
|
|
145
|
+
label: w("govcitizenhub.readyStatus", "GovCitizenHub Ready"),
|
|
138
146
|
type: "status",
|
|
139
147
|
section: "left",
|
|
140
148
|
order: 10
|
|
141
149
|
}]);
|
|
142
|
-
}, [
|
|
143
|
-
client:
|
|
144
|
-
children: /* @__PURE__ */
|
|
150
|
+
}, [b, w]), /* @__PURE__ */ y(s, {
|
|
151
|
+
client: x,
|
|
152
|
+
children: /* @__PURE__ */ y(c, {
|
|
145
153
|
workspaceId: null,
|
|
146
154
|
gateway: "global",
|
|
147
155
|
defaultEnabled: !0,
|
|
148
|
-
children: /* @__PURE__ */
|
|
149
|
-
...
|
|
150
|
-
children: /* @__PURE__ */
|
|
156
|
+
children: /* @__PURE__ */ y(C, { children: /* @__PURE__ */ y(t, {
|
|
157
|
+
...i,
|
|
158
|
+
children: /* @__PURE__ */ y(r, {})
|
|
151
159
|
}) })
|
|
152
160
|
})
|
|
153
161
|
});
|
|
154
162
|
};
|
|
155
163
|
//#endregion
|
|
156
|
-
export {
|
|
164
|
+
export { w as GovCitizenHubRoot };
|
|
157
165
|
|
|
158
166
|
//# sourceMappingURL=GovCitizenHubRoot.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"GovCitizenHubRoot.js","names":[],"sources":["../../src/govcitizenhub/GovCitizenHubRoot.tsx"],"sourcesContent":["/**\n * GovCitizenHub Root Component\n * @module govcitizenhub\n *\n * Host-contract entry point. Registers the product's sidebar nav (matching the\n * app-shell static NavRegistration block so the two are one source of truth) and\n * mounts the routed pages inside the shared QueryClient + FeatureFlag providers.\n */\n\nimport { Component, type ErrorInfo, type FC, type ReactNode } from 'react';\nimport { useEffect } from 'react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { FeatureFlagProvider } from '@burdenoff/fe-libs/shared/feature-flags';\nimport {\n LayoutDashboard,\n Briefcase,\n FileText,\n Building2,\n FolderOpen,\n CreditCard,\n BadgeCheck,\n ShieldQuestion,\n MessageSquareWarning,\n Landmark,\n} from 'lucide-react';\nimport { GovCitizenHubProvider } from './context/GovCitizenHubContext';\nimport { GovCitizenHubRoutes } from './GovCitizenHubRoutes';\nimport { joinPath } from './utils/navigation';\nimport type { GovCitizenHubRootProps, NavItem } from './types';\n\nconst queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 60 * 1000,\n retry: 1,\n refetchOnWindowFocus: false,\n },\n },\n});\n\ninterface ErrorBoundaryState {\n hasError: boolean;\n message: string | null;\n}\n\
|
|
1
|
+
{"version":3,"file":"GovCitizenHubRoot.js","names":[],"sources":["../../src/govcitizenhub/GovCitizenHubRoot.tsx"],"sourcesContent":["/**\n * GovCitizenHub Root Component\n * @module govcitizenhub\n *\n * Host-contract entry point. Registers the product's sidebar nav (matching the\n * app-shell static NavRegistration block so the two are one source of truth) and\n * mounts the routed pages inside the shared QueryClient + FeatureFlag providers.\n */\n\nimport { Component, type ErrorInfo, type FC, type ReactNode } from 'react';\nimport { useEffect } from 'react';\nimport { QueryClient, QueryClientProvider } from '@tanstack/react-query';\nimport { FeatureFlagProvider } from '@burdenoff/fe-libs/shared/feature-flags';\nimport {\n LayoutDashboard,\n Briefcase,\n FileText,\n Building2,\n FolderOpen,\n CreditCard,\n BadgeCheck,\n ShieldQuestion,\n MessageSquareWarning,\n Landmark,\n} from 'lucide-react';\nimport { GovCitizenHubProvider } from './context/GovCitizenHubContext';\nimport { GovCitizenHubRoutes } from './GovCitizenHubRoutes';\nimport { joinPath } from './utils/navigation';\nimport { useTr } from '../shared/hooks/useTr';\nimport type { GovCitizenHubRootProps, NavItem } from './types';\n\nconst queryClient = new QueryClient({\n defaultOptions: {\n queries: {\n staleTime: 60 * 1000,\n retry: 1,\n refetchOnWindowFocus: false,\n },\n },\n});\n\ninterface ErrorBoundaryState {\n hasError: boolean;\n message: string | null;\n}\n\nconst ErrorFallback: FC<{ message: string | null }> = ({ message }) => {\n const tr = useTr();\n return (\n <div className=\"m-4 rounded-xl border border-border-seam bg-bg-surface p-6\">\n <h2 className=\"text-lg font-semibold text-status-error-text\">\n {tr('govcitizenhub.errorTitle', 'Something went wrong')}\n </h2>\n <p className=\"mt-2 text-sm text-text-secondary\">\n {message ?? tr('govcitizenhub.errorFallback', 'Unknown error')}\n </p>\n <button\n type=\"button\"\n onClick={() => window.location.reload()}\n className=\"mt-4 rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90\"\n >\n {tr('common.reload', 'Reload')}\n </button>\n </div>\n );\n};\n\nclass GovErrorBoundary extends Component<{ children: ReactNode }, ErrorBoundaryState> {\n constructor(props: { children: ReactNode }) {\n super(props);\n this.state = { hasError: false, message: null };\n }\n\n static getDerivedStateFromError(error: Error): ErrorBoundaryState {\n return { hasError: true, message: error.message };\n }\n\n componentDidCatch(_error: Error, _info: ErrorInfo) {\n // Surfaced in the fallback; no external logger wired here.\n }\n\n render() {\n if (this.state.hasError) {\n return <ErrorFallback message={this.state.message} />;\n }\n return this.props.children;\n }\n}\n\nexport const GovCitizenHubRoot: FC<GovCitizenHubRootProps> = (props) => {\n const { registerNavItems, registerFooterItems, basePath = '/' } = props;\n const tr = useTr();\n\n useEffect(() => {\n if (!registerNavItems) return;\n\n const navItems: NavItem[] = [\n {\n id: 'govcitizenhub-dashboard',\n label: tr('govcitizenhub.dashboard', 'Dashboard'),\n path: joinPath(basePath, ''),\n icon: <LayoutDashboard size={20} />,\n order: 0,\n group: 'products',\n },\n {\n id: 'govcitizenhub-services',\n label: tr('govcitizenhub.services', 'Services'),\n path: joinPath(basePath, 'services'),\n icon: <Briefcase size={20} />,\n order: 1,\n group: 'products',\n },\n {\n id: 'govcitizenhub-applications',\n label: tr('govcitizenhub.applications', 'Applications'),\n path: joinPath(basePath, 'applications'),\n icon: <FileText size={20} />,\n order: 2,\n group: 'products',\n },\n {\n id: 'govcitizenhub-agencies',\n label: tr('govcitizenhub.agencies', 'Agencies'),\n path: joinPath(basePath, 'agencies'),\n icon: <Building2 size={20} />,\n order: 3,\n group: 'products',\n },\n {\n id: 'govcitizenhub-documents',\n label: tr('govcitizenhub.documents', 'Documents'),\n path: joinPath(basePath, 'documents'),\n icon: <FolderOpen size={20} />,\n order: 4,\n group: 'products',\n },\n {\n id: 'govcitizenhub-payments',\n label: tr('govcitizenhub.payments', 'Payments'),\n path: joinPath(basePath, 'payments'),\n icon: <CreditCard size={20} />,\n order: 5,\n group: 'products',\n },\n {\n id: 'govcitizenhub-permits',\n label: tr('govcitizenhub.permits', 'Permits'),\n path: joinPath(basePath, 'permits'),\n icon: <BadgeCheck size={20} />,\n order: 6,\n group: 'products',\n },\n {\n id: 'govcitizenhub-verify',\n label: tr('govcitizenhub.verifyPermit', 'Verify Permit'),\n path: joinPath(basePath, 'permits/verify'),\n icon: <ShieldQuestion size={20} />,\n order: 7,\n group: 'products',\n },\n {\n id: 'govcitizenhub-grievances',\n label: tr('govcitizenhub.grievances', 'Grievances'),\n path: joinPath(basePath, 'grievances'),\n icon: <MessageSquareWarning size={20} />,\n order: 8,\n group: 'products',\n },\n {\n id: 'govcitizenhub-intelligence',\n label: tr('govcitizenhub.communityIntelligence', 'Community Intelligence'),\n path: joinPath(basePath, 'intelligence'),\n icon: <Landmark size={20} />,\n order: 9,\n group: 'products',\n },\n ];\n\n return registerNavItems(navItems);\n }, [registerNavItems, basePath, tr]);\n\n useEffect(() => {\n if (!registerFooterItems) return;\n return registerFooterItems([\n {\n id: 'govcitizenhub-status',\n label: tr('govcitizenhub.readyStatus', 'GovCitizenHub Ready'),\n type: 'status',\n section: 'left',\n order: 10,\n },\n ]);\n }, [registerFooterItems, tr]);\n\n return (\n <QueryClientProvider client={queryClient}>\n <FeatureFlagProvider workspaceId={null} gateway=\"global\" defaultEnabled={true}>\n <GovErrorBoundary>\n <GovCitizenHubProvider {...props}>\n <GovCitizenHubRoutes />\n </GovCitizenHubProvider>\n </GovErrorBoundary>\n </FeatureFlagProvider>\n </QueryClientProvider>\n );\n};\n"],"mappings":";;;;;;;;;;AA+BA,IAAM,IAAc,IAAI,EAAY,EAClC,gBAAgB,EACd,SAAS;CACP,WAAW,KAAK;CAChB,OAAO;CACP,sBAAsB;AACxB,EACF,EACF,CAAC,GAOK,KAAiD,EAAE,iBAAc;CACrE,IAAM,IAAK,EAAM;CACjB,OACE,kBAAC,OAAD;EAAK,WAAU;YAAf;GACE,kBAAC,MAAD;IAAI,WAAU;cACX,EAAG,4BAA4B,sBAAsB;GACpD,CAAA;GACJ,kBAAC,KAAD;IAAG,WAAU;cACV,KAAW,EAAG,+BAA+B,eAAe;GAC5D,CAAA;GACH,kBAAC,UAAD;IACE,MAAK;IACL,eAAe,OAAO,SAAS,OAAO;IACtC,WAAU;cAET,EAAG,iBAAiB,QAAQ;GACvB,CAAA;EACL;;AAET,GAEM,IAAN,cAA+B,EAAuD;CACpF,YAAY,GAAgC;EAE1C,AADA,MAAM,CAAK,GACX,KAAK,QAAQ;GAAE,UAAU;GAAO,SAAS;EAAK;CAChD;CAEA,OAAO,yBAAyB,GAAkC;EAChE,OAAO;GAAE,UAAU;GAAM,SAAS,EAAM;EAAQ;CAClD;CAEA,kBAAkB,GAAe,GAAkB,CAEnD;CAEA,SAAS;EAIP,OAHI,KAAK,MAAM,WACN,kBAAC,GAAD,EAAe,SAAS,KAAK,MAAM,QAAU,CAAA,IAE/C,KAAK,MAAM;CACpB;AACF,GAEa,KAAiD,MAAU;CACtE,IAAM,EAAE,qBA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8BAA8B,eAAe;IACvD,MAAM,EAAS,GAAU,gBAAgB;IACzC,MAAM,kBAAC,GAAD,EAAgB,MAAM,GAAK,CAAA;IACjC,OAAO;IACP,OAAO;GACT;GACA;IACE,IAAI;IACJ,OAAO,EAAG,4BAA4B,YAAY;IAClD,MAAM,EAAS,GAAU,YAAY;IACrC,MAAM,kBAAC,GAAD,EAAsB,MAAM,GAAK,CAAA;IACvC,OAAO;IACP,OAAO;GACT;GACA;IACE,IAAI;IACJ,OAAO,EAAG,uCAAuC,wBAAwB;IACzE,MAAM,EAAS,GAAU,cAAc;IACvC,MAAM,kBAAC,GAAD,EAAU,MAAM,GAAK,CAAA;IAC3B,OAAO;IACP,OAAO;GACT;EAGsB,CAAQ;CAClC,GAAG;EAAC;EAAkB;EAAU;CAAE,CAAC,GAEnC,QAAgB;EACT,OACL,OAAO,EAAoB,CACzB;GACE,IAAI;GACJ,OAAO,EAAG,6BAA6B,qBAAqB;GAC5D,MAAM;GACN,SAAS;GACT,OAAO;EACT,CACF,CAAC;CACH,GAAG,CAAC,GAAqB,CAAE,CAAC,GAG1B,kBAAC,GAAD;EAAqB,QAAQ;YAC3B,kBAAC,GAAD;GAAqB,aAAa;GAAM,SAAQ;GAAS,gBAAgB;aACvE,kBAAC,GAAD,EAAA,UACE,kBAAC,GAAD;IAAuB,GAAI;cACzB,kBAAC,GAAD,CAAsB,CAAA;GACD,CAAA,EACP,CAAA;EACC,CAAA;CACF,CAAA;AAEzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateViews.d.ts","sourceRoot":"","sources":["../../../src/govcitizenhub/components/StateViews.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"StateViews.d.ts","sourceRoot":"","sources":["../../../src/govcitizenhub/components/StateViews.tsx"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAM3C,UAAU,gBAAgB;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,WAAW,EAAE,EAAE,CAAC,gBAAgB,CAQ5C,CAAC;AAEF,UAAU,cAAc;IACtB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,SAAS,EAAE,EAAE,CAAC,cAAc,CAgCxC,CAAC;AAEF,UAAU,YAAY;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,MAAM,CAAC,EAAE,SAAS,CAAC;IACnB,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,eAAO,MAAM,OAAO,EAAE,EAAE,CAAC,YAAY,CAWpC,CAAC"}
|
|
@@ -1,34 +1,41 @@
|
|
|
1
1
|
import { cn as e } from "../utils/cn.js";
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
2
|
+
import { useTr as t } from "../../shared/hooks/useTr.js";
|
|
3
|
+
import { AlertCircle as n } from "lucide-react";
|
|
4
|
+
import { jsx as r, jsxs as i } from "react/jsx-runtime";
|
|
5
|
+
import { Spinner as a } from "@burdenoff/fe-libs/ui";
|
|
5
6
|
//#region src/govcitizenhub/components/StateViews.tsx
|
|
6
|
-
var
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
className: "
|
|
10
|
-
children:
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
className: "
|
|
21
|
-
children:
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
7
|
+
var o = ({ label: n, className: o }) => {
|
|
8
|
+
let s = t();
|
|
9
|
+
return /* @__PURE__ */ i("div", {
|
|
10
|
+
className: e("flex min-h-[40vh] flex-col items-center justify-center gap-3", o),
|
|
11
|
+
children: [/* @__PURE__ */ r(a, { size: "lg" }), /* @__PURE__ */ r("p", {
|
|
12
|
+
className: "text-sm text-text-secondary",
|
|
13
|
+
children: n ?? s("common.loading", "Loading…")
|
|
14
|
+
})]
|
|
15
|
+
});
|
|
16
|
+
}, s = ({ title: a, message: o, onRetry: s, className: c }) => {
|
|
17
|
+
let l = t();
|
|
18
|
+
return /* @__PURE__ */ i("div", {
|
|
19
|
+
className: e("flex min-h-[40vh] flex-col items-center justify-center gap-4 text-center", c),
|
|
20
|
+
children: [
|
|
21
|
+
/* @__PURE__ */ r(n, { className: "h-10 w-10 text-status-error-text" }),
|
|
22
|
+
/* @__PURE__ */ i("div", { children: [/* @__PURE__ */ r("h2", {
|
|
23
|
+
className: "text-lg font-semibold text-text-primary",
|
|
24
|
+
children: a ?? l("govcitizenhub.errorTitle", "Something went wrong")
|
|
25
|
+
}), o && /* @__PURE__ */ r("p", {
|
|
26
|
+
className: "mt-1 max-w-md text-sm text-text-secondary",
|
|
27
|
+
children: o
|
|
28
|
+
})] }),
|
|
29
|
+
s && /* @__PURE__ */ r("button", {
|
|
30
|
+
type: "button",
|
|
31
|
+
onClick: s,
|
|
32
|
+
className: "rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90",
|
|
33
|
+
children: l("common.retry", "Retry")
|
|
34
|
+
})
|
|
35
|
+
]
|
|
36
|
+
});
|
|
37
|
+
};
|
|
31
38
|
//#endregion
|
|
32
|
-
export {
|
|
39
|
+
export { s as ErrorView, o as LoadingView };
|
|
33
40
|
|
|
34
41
|
//# sourceMappingURL=StateViews.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateViews.js","names":[],"sources":["../../../src/govcitizenhub/components/StateViews.tsx"],"sourcesContent":["/**\n * Shared loading / error / section state views\n * @module govcitizenhub/components\n */\n\nimport type { FC, ReactNode } from 'react';\nimport { AlertCircle } from 'lucide-react';\nimport { Spinner } from '@burdenoff/fe-libs/ui';\nimport { cn } from '../utils/cn';\n\ninterface LoadingViewProps {\n label?: string;\n className?: string;\n}\n\nexport const LoadingView: FC<LoadingViewProps> = ({ label
|
|
1
|
+
{"version":3,"file":"StateViews.js","names":[],"sources":["../../../src/govcitizenhub/components/StateViews.tsx"],"sourcesContent":["/**\n * Shared loading / error / section state views\n * @module govcitizenhub/components\n */\n\nimport type { FC, ReactNode } from 'react';\nimport { AlertCircle } from 'lucide-react';\nimport { Spinner } from '@burdenoff/fe-libs/ui';\nimport { cn } from '../utils/cn';\nimport { useTr } from '../../shared/hooks/useTr';\n\ninterface LoadingViewProps {\n label?: string;\n className?: string;\n}\n\nexport const LoadingView: FC<LoadingViewProps> = ({ label, className }) => {\n const tr = useTr();\n return (\n <div className={cn('flex min-h-[40vh] flex-col items-center justify-center gap-3', className)}>\n <Spinner size=\"lg\" />\n <p className=\"text-sm text-text-secondary\">{label ?? tr('common.loading', 'Loading…')}</p>\n </div>\n );\n};\n\ninterface ErrorViewProps {\n title?: string;\n message?: string;\n onRetry?: () => void;\n className?: string;\n}\n\nexport const ErrorView: FC<ErrorViewProps> = ({\n title,\n message,\n onRetry,\n className,\n}) => {\n const tr = useTr();\n return (\n <div\n className={cn(\n 'flex min-h-[40vh] flex-col items-center justify-center gap-4 text-center',\n className\n )}\n >\n <AlertCircle className=\"h-10 w-10 text-status-error-text\" />\n <div>\n <h2 className=\"text-lg font-semibold text-text-primary\">\n {title ?? tr('govcitizenhub.errorTitle', 'Something went wrong')}\n </h2>\n {message && <p className=\"mt-1 max-w-md text-sm text-text-secondary\">{message}</p>}\n </div>\n {onRetry && (\n <button\n type=\"button\"\n onClick={onRetry}\n className=\"rounded-lg bg-action-primary-bg px-4 py-2 text-sm font-medium text-action-primary-text hover:opacity-90\"\n >\n {tr('common.retry', 'Retry')}\n </button>\n )}\n </div>\n );\n};\n\ninterface SectionProps {\n title: string;\n description?: string;\n action?: ReactNode;\n children: ReactNode;\n className?: string;\n}\n\nexport const Section: FC<SectionProps> = ({ title, description, action, children, className }) => (\n <section className={cn('mt-8 first:mt-0', className)}>\n <div className=\"mb-3 flex items-end justify-between gap-3\">\n <div>\n <h2 className=\"text-base font-semibold text-text-primary\">{title}</h2>\n {description && <p className=\"mt-0.5 text-sm text-text-secondary\">{description}</p>}\n </div>\n {action && <div className=\"shrink-0\">{action}</div>}\n </div>\n {children}\n </section>\n);\n"],"mappings":";;;;;;AAgBA,IAAa,KAAqC,EAAE,UAAO,mBAAgB;CACzE,IAAM,IAAK,EAAM;CACjB,OACE,kBAAC,OAAD;EAAK,WAAW,EAAG,gEAAgE,CAAS;YAA5F,CACE,kBAAC,GAAD,EAAS,MAAK,KAAM,CAAA,GACpB,kBAAC,KAAD;GAAG,WAAU;aAA+B,KAAS,EAAG,kBAAkB,UAAU;EAAK,CAAA,CACtF;;AAET,GASa,KAAiC,EAC5C,UACA,YACA,YACA,mBACI;CACJ,IAAM,IAAK,EAAM;CACjB,OACE,kBAAC,OAAD;EACE,WAAW,EACT,4EACA,CACF;YAJF;GAME,kBAAC,GAAD,EAAa,WAAU,mCAAoC,CAAA;GAC3D,kBAAC,OAAD,EAAA,UAAA,CACE,kBAAC,MAAD;IAAI,WAAU;cACX,KAAS,EAAG,4BAA4B,sBAAsB;GAC7D,CAAA,GACH,KAAW,kBAAC,KAAD;IAAG,WAAU;cAA6C;GAAW,CAAA,CAC9E,EAAA,CAAA;GACJ,KACC,kBAAC,UAAD;IACE,MAAK;IACL,SAAS;IACT,WAAU;cAET,EAAG,gBAAgB,OAAO;GACrB,CAAA;EAEP;;AAET"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardPage.d.ts","sourceRoot":"","sources":["../../../src/govcitizenhub/pages/DashboardPage.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;
|
|
1
|
+
{"version":3,"file":"DashboardPage.d.ts","sourceRoot":"","sources":["../../../src/govcitizenhub/pages/DashboardPage.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAgHH,wBAAgB,aAAa,4CAgY5B"}
|
|
@@ -6,8 +6,9 @@ import { CHART_SERIES_COLORS as r, ChartLegend as i, GovAreaChart as a, GovDonut
|
|
|
6
6
|
import { formatCurrency as s, formatEnumLabel as c, formatNumber as l, formatRelativeTime as u } from "../utils/formatters.js";
|
|
7
7
|
import { StatusBadge as d } from "../components/StatusBadge.js";
|
|
8
8
|
import { EmptyState as f } from "../components/EmptyState.js";
|
|
9
|
-
import { useGovApplications as p, useGovApplicationsByService as m, useGovDashboardSummary as
|
|
9
|
+
import { useGovApplications as p, useGovApplicationsByService as m, useGovDashboardSummary as ee } from "../hooks/useGovApi.js";
|
|
10
10
|
import "../hooks/index.js";
|
|
11
|
+
import { useTr as h } from "../../shared/hooks/useTr.js";
|
|
11
12
|
import { useMemo as g, useState as _ } from "react";
|
|
12
13
|
import { BadgeCheck as v, Briefcase as y, Building2 as b, ChevronRight as x, CreditCard as S, FileText as C, MessageSquareWarning as w } from "lucide-react";
|
|
13
14
|
import { Fragment as T, jsx as E, jsxs as D } from "react/jsx-runtime";
|
|
@@ -22,14 +23,14 @@ var A = 1440 * 60 * 1e3, j = 30, M = "INR", N = 100, P = 5, F = [
|
|
|
22
23
|
"REJECTED",
|
|
23
24
|
"WITHDRAWN"
|
|
24
25
|
];
|
|
25
|
-
function I(e, t) {
|
|
26
|
+
function I(e, t, n) {
|
|
26
27
|
if (e.direction === "FLAT") return;
|
|
27
|
-
let
|
|
28
|
+
let r = e.direction === "UP";
|
|
28
29
|
return {
|
|
29
30
|
value: e.changePercent == null ? `${e.current} new` : `${Math.abs(e.changePercent).toFixed(1)}%`,
|
|
30
|
-
direction:
|
|
31
|
-
positive:
|
|
32
|
-
caption:
|
|
31
|
+
direction: r ? "up" : "down",
|
|
32
|
+
positive: r === t,
|
|
33
|
+
caption: n
|
|
33
34
|
};
|
|
34
35
|
}
|
|
35
36
|
function L(e, t) {
|
|
@@ -52,81 +53,81 @@ function L(e, t) {
|
|
|
52
53
|
}));
|
|
53
54
|
}
|
|
54
55
|
function R() {
|
|
55
|
-
let { navigateTo: A } = e(), [
|
|
56
|
+
let { navigateTo: A } = e(), j = h(), [R] = _(() => Date.now()), z = ee(), B = p({ pagination: { limit: N } }), V = m(), H = g(() => B.data?.items ?? [], [B.data]), U = g(() => L(H.map((e) => e.createdAt), R), [H, R]), W = g(() => (z.data?.applicationsByStatus ?? []).map((e) => {
|
|
56
57
|
let t = F.indexOf(e.status), n = t >= 0 ? t : 0;
|
|
57
58
|
return {
|
|
58
59
|
name: c(e.status),
|
|
59
60
|
value: e.count,
|
|
60
61
|
color: r[n % r.length]
|
|
61
62
|
};
|
|
62
|
-
}).filter((e) => e.value > 0), [
|
|
63
|
+
}).filter((e) => e.value > 0), [z.data]), G = g(() => W.reduce((e, t) => e + t.value, 0), [W]), K = g(() => [...H].sort((e, t) => new Date(t.createdAt).getTime() - new Date(e.createdAt).getTime()).slice(0, 6), [H]), q = g(() => (V.data ?? []).slice(0, P), [V.data]), J = g(() => q.reduce((e, t) => Math.max(e, t.count), 0), [q]), Y = z.isLoading, X = B.isLoading, Z = z.data?.applicationsTotal ?? 0, Q = z.data?.pendingPaymentsAmount ?? 0, $ = j("govcitizenhub.vsLast30Days", "vs last 30 days"), te = [
|
|
64
|
+
{
|
|
65
|
+
label: j("govcitizenhub.metricApplications", "Applications"),
|
|
66
|
+
value: l(Z),
|
|
67
|
+
sublabel: j("govcitizenhub.metricApplicationsSub", "filed to date"),
|
|
68
|
+
delta: z.data ? I(z.data.applicationsTotalTrend, !0, $) : void 0,
|
|
69
|
+
icon: /* @__PURE__ */ E(C, { className: "h-5 w-5" }),
|
|
70
|
+
path: "applications",
|
|
71
|
+
featured: !0
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
label: j("govcitizenhub.metricPendingPayments", "Pending payments"),
|
|
75
|
+
value: l(z.data?.pendingPayments ?? 0),
|
|
76
|
+
sublabel: Q > 0 ? j("govcitizenhub.metricPendingPaymentsDue", "{{amount}} due", { amount: s(Q, M) }) : j("govcitizenhub.metricPendingPaymentsSettled", "all settled"),
|
|
77
|
+
delta: z.data ? I(z.data.pendingPaymentsTrend, !1, $) : void 0,
|
|
78
|
+
icon: /* @__PURE__ */ E(S, { className: "h-5 w-5" }),
|
|
79
|
+
path: "payments",
|
|
80
|
+
accent: "warning"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
label: j("govcitizenhub.metricOpenGrievances", "Open grievances"),
|
|
84
|
+
value: l(z.data?.openGrievances ?? 0),
|
|
85
|
+
sublabel: j("govcitizenhub.metricOpenGrievancesSub", "awaiting acknowledgement"),
|
|
86
|
+
delta: z.data ? I(z.data.openGrievancesTrend, !1, $) : void 0,
|
|
87
|
+
icon: /* @__PURE__ */ E(w, { className: "h-5 w-5" }),
|
|
88
|
+
path: "grievances",
|
|
89
|
+
accent: "error"
|
|
90
|
+
},
|
|
91
|
+
{
|
|
92
|
+
label: j("govcitizenhub.metricActivePermits", "Active permits"),
|
|
93
|
+
value: l(z.data?.activePermits ?? 0),
|
|
94
|
+
sublabel: j("govcitizenhub.metricActivePermitsSub", "currently valid"),
|
|
95
|
+
delta: z.data ? I(z.data.activePermitsTrend, !0, $) : void 0,
|
|
96
|
+
icon: /* @__PURE__ */ E(v, { className: "h-5 w-5" }),
|
|
97
|
+
path: "permits",
|
|
98
|
+
accent: "success"
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
label: j("govcitizenhub.metricPublishedServices", "Published services"),
|
|
102
|
+
value: l(z.data?.publishedServices ?? 0),
|
|
103
|
+
sublabel: j("govcitizenhub.metricPublishedServicesSub", "available to citizens"),
|
|
104
|
+
delta: z.data ? I(z.data.publishedServicesTrend, !0, $) : void 0,
|
|
105
|
+
icon: /* @__PURE__ */ E(y, { className: "h-5 w-5" }),
|
|
106
|
+
path: "services"
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
label: j("govcitizenhub.metricActiveAgencies", "Active agencies"),
|
|
110
|
+
value: l(z.data?.activeAgencies ?? 0),
|
|
111
|
+
sublabel: j("govcitizenhub.metricActiveAgenciesSub", "delivering services"),
|
|
112
|
+
delta: z.data ? I(z.data.activeAgenciesTrend, !0, $) : void 0,
|
|
113
|
+
icon: /* @__PURE__ */ E(b, { className: "h-5 w-5" }),
|
|
114
|
+
path: "agencies"
|
|
115
|
+
}
|
|
116
|
+
];
|
|
63
117
|
return /* @__PURE__ */ D(t, {
|
|
64
|
-
title: "GovCitizenHub",
|
|
118
|
+
title: j("govcitizenhub.dashboardTitle", "GovCitizenHub"),
|
|
65
119
|
titleGradient: !0,
|
|
66
120
|
aurora: !0,
|
|
67
|
-
description: "Your live government service-delivery operations, at a glance.",
|
|
121
|
+
description: j("govcitizenhub.dashboardDescription", "Your live government service-delivery operations, at a glance."),
|
|
68
122
|
children: [
|
|
69
123
|
/* @__PURE__ */ E("div", {
|
|
70
124
|
className: "grid grid-cols-2 gap-4 sm:grid-cols-3 xl:grid-cols-6",
|
|
71
|
-
children:
|
|
72
|
-
{
|
|
73
|
-
label: "Applications",
|
|
74
|
-
value: l(X),
|
|
75
|
-
sublabel: "filed to date",
|
|
76
|
-
delta: R.data ? I(R.data.applicationsTotalTrend, !0) : void 0,
|
|
77
|
-
icon: /* @__PURE__ */ E(C, { className: "h-5 w-5" }),
|
|
78
|
-
path: "applications",
|
|
79
|
-
featured: !0
|
|
80
|
-
},
|
|
81
|
-
{
|
|
82
|
-
label: "Pending payments",
|
|
83
|
-
value: l(R.data?.pendingPayments ?? 0),
|
|
84
|
-
sublabel: Z > 0 ? `${s(Z, M)} due` : "all settled",
|
|
85
|
-
delta: R.data ? I(R.data.pendingPaymentsTrend, !1) : void 0,
|
|
86
|
-
icon: /* @__PURE__ */ E(S, { className: "h-5 w-5" }),
|
|
87
|
-
path: "payments",
|
|
88
|
-
accent: "warning"
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
label: "Open grievances",
|
|
92
|
-
value: l(R.data?.openGrievances ?? 0),
|
|
93
|
-
sublabel: "awaiting acknowledgement",
|
|
94
|
-
delta: R.data ? I(R.data.openGrievancesTrend, !1) : void 0,
|
|
95
|
-
icon: /* @__PURE__ */ E(w, { className: "h-5 w-5" }),
|
|
96
|
-
path: "grievances",
|
|
97
|
-
accent: "error"
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
label: "Active permits",
|
|
101
|
-
value: l(R.data?.activePermits ?? 0),
|
|
102
|
-
sublabel: "currently valid",
|
|
103
|
-
delta: R.data ? I(R.data.activePermitsTrend, !0) : void 0,
|
|
104
|
-
icon: /* @__PURE__ */ E(v, { className: "h-5 w-5" }),
|
|
105
|
-
path: "permits",
|
|
106
|
-
accent: "success"
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
label: "Published services",
|
|
110
|
-
value: l(R.data?.publishedServices ?? 0),
|
|
111
|
-
sublabel: "available to citizens",
|
|
112
|
-
delta: R.data ? I(R.data.publishedServicesTrend, !0) : void 0,
|
|
113
|
-
icon: /* @__PURE__ */ E(y, { className: "h-5 w-5" }),
|
|
114
|
-
path: "services"
|
|
115
|
-
},
|
|
116
|
-
{
|
|
117
|
-
label: "Active agencies",
|
|
118
|
-
value: l(R.data?.activeAgencies ?? 0),
|
|
119
|
-
sublabel: "delivering services",
|
|
120
|
-
delta: R.data ? I(R.data.activeAgenciesTrend, !0) : void 0,
|
|
121
|
-
icon: /* @__PURE__ */ E(b, { className: "h-5 w-5" }),
|
|
122
|
-
path: "agencies"
|
|
123
|
-
}
|
|
124
|
-
].map((e) => /* @__PURE__ */ E(n, {
|
|
125
|
+
children: te.map((e) => /* @__PURE__ */ E(n, {
|
|
125
126
|
icon: e.icon,
|
|
126
|
-
value:
|
|
127
|
+
value: Y ? "—" : e.value,
|
|
127
128
|
label: e.label,
|
|
128
129
|
sublabel: e.sublabel,
|
|
129
|
-
delta:
|
|
130
|
+
delta: Y ? void 0 : e.delta,
|
|
130
131
|
featured: e.featured,
|
|
131
132
|
accent: e.accent,
|
|
132
133
|
onClick: () => A(e.path)
|
|
@@ -141,19 +142,19 @@ function R() {
|
|
|
141
142
|
className: "flex items-start justify-between gap-4",
|
|
142
143
|
children: [/* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("h2", {
|
|
143
144
|
className: "text-lg font-semibold text-text-primary",
|
|
144
|
-
children: "Applications over time"
|
|
145
|
+
children: j("govcitizenhub.applicationsOverTime", "Applications over time")
|
|
145
146
|
}), /* @__PURE__ */ E("p", {
|
|
146
147
|
className: "mt-0.5 text-xs text-text-muted",
|
|
147
|
-
children: "Cumulative filings (recent sample, not a total)"
|
|
148
|
+
children: j("govcitizenhub.applicationsOverTimeHint", "Cumulative filings (recent sample, not a total)")
|
|
148
149
|
})] }), /* @__PURE__ */ E("span", {
|
|
149
150
|
className: "shrink-0 rounded-full border border-border-seam bg-bg-surface px-3 py-1 text-xs font-medium text-text-secondary",
|
|
150
|
-
children: "Last 30 days"
|
|
151
|
+
children: j("govcitizenhub.last30Days", "Last 30 days")
|
|
151
152
|
})]
|
|
152
153
|
}), /* @__PURE__ */ E("div", {
|
|
153
154
|
className: "mt-4",
|
|
154
|
-
children:
|
|
155
|
-
data:
|
|
156
|
-
emptyLabel: "
|
|
155
|
+
children: X ? /* @__PURE__ */ E(k, { className: "h-[260px] w-full rounded-card" }) : /* @__PURE__ */ E(a, {
|
|
156
|
+
data: U,
|
|
157
|
+
emptyLabel: j("govcitizenhub.noApplicationsRecentHint", "Citizen applications will appear here as they are filed.")
|
|
157
158
|
})
|
|
158
159
|
})]
|
|
159
160
|
}), /* @__PURE__ */ D(O, {
|
|
@@ -161,20 +162,20 @@ function R() {
|
|
|
161
162
|
className: "border-border-seam p-5 lg:col-span-2",
|
|
162
163
|
children: [/* @__PURE__ */ E("h2", {
|
|
163
164
|
className: "text-lg font-semibold text-text-primary",
|
|
164
|
-
children: "Applications by status"
|
|
165
|
+
children: j("govcitizenhub.applicationsByStatus", "Applications by status")
|
|
165
166
|
}), /* @__PURE__ */ E("div", {
|
|
166
167
|
className: "mt-3",
|
|
167
|
-
children:
|
|
168
|
-
title: "No applications yet",
|
|
169
|
-
description: "Filed applications will break down here by status."
|
|
168
|
+
children: Y ? /* @__PURE__ */ E(k, { className: "h-[240px] w-full rounded-card" }) : W.length === 0 ? /* @__PURE__ */ E(f, {
|
|
169
|
+
title: j("govcitizenhub.noApplicationsYet", "No applications yet"),
|
|
170
|
+
description: j("govcitizenhub.noApplicationsStatusHint", "Filed applications will break down here by status.")
|
|
170
171
|
}) : /* @__PURE__ */ D(T, { children: [/* @__PURE__ */ E(o, {
|
|
171
|
-
data:
|
|
172
|
-
centerValue: l(
|
|
173
|
-
centerLabel: "Total"
|
|
172
|
+
data: W,
|
|
173
|
+
centerValue: l(Z),
|
|
174
|
+
centerLabel: j("govcitizenhub.chartTotal", "Total")
|
|
174
175
|
}), /* @__PURE__ */ E(i, {
|
|
175
176
|
className: "mt-4",
|
|
176
|
-
items:
|
|
177
|
-
let t =
|
|
177
|
+
items: W.map((e) => {
|
|
178
|
+
let t = G || 1, n = Math.round(e.value / t * 100);
|
|
178
179
|
return {
|
|
179
180
|
label: e.name,
|
|
180
181
|
color: e.color,
|
|
@@ -190,22 +191,22 @@ function R() {
|
|
|
190
191
|
className: "mt-6 border-border-seam p-5",
|
|
191
192
|
children: [/* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("h2", {
|
|
192
193
|
className: "text-lg font-semibold text-text-primary",
|
|
193
|
-
children: "Applications by service"
|
|
194
|
+
children: j("govcitizenhub.applicationsByService", "Applications by service")
|
|
194
195
|
}), /* @__PURE__ */ E("p", {
|
|
195
196
|
className: "mt-0.5 text-xs text-text-muted",
|
|
196
|
-
children: "Corpus-wide volume, not limited to the recent sample above"
|
|
197
|
+
children: j("govcitizenhub.applicationsByServiceHint", "Corpus-wide volume, not limited to the recent sample above")
|
|
197
198
|
})] }), /* @__PURE__ */ E("div", {
|
|
198
199
|
className: "mt-4",
|
|
199
|
-
children:
|
|
200
|
+
children: V.isLoading ? /* @__PURE__ */ E("div", {
|
|
200
201
|
className: "space-y-3",
|
|
201
202
|
children: Array.from({ length: 3 }, (e, t) => /* @__PURE__ */ E(k, { className: "h-8 w-full rounded-card" }, t))
|
|
202
|
-
}) :
|
|
203
|
-
title: "No applications yet",
|
|
204
|
-
description: "Once citizens file applications, the busiest services will rank here."
|
|
203
|
+
}) : q.length === 0 ? /* @__PURE__ */ E(f, {
|
|
204
|
+
title: j("govcitizenhub.noApplicationsYet", "No applications yet"),
|
|
205
|
+
description: j("govcitizenhub.noApplicationsServiceHint", "Once citizens file applications, the busiest services will rank here.")
|
|
205
206
|
}) : /* @__PURE__ */ E("ul", {
|
|
206
207
|
className: "space-y-3",
|
|
207
|
-
children:
|
|
208
|
-
let t =
|
|
208
|
+
children: q.map((e) => {
|
|
209
|
+
let t = J > 0 ? Math.round(e.count / J * 100) : 0;
|
|
209
210
|
return /* @__PURE__ */ E("li", { children: /* @__PURE__ */ D("button", {
|
|
210
211
|
type: "button",
|
|
211
212
|
onClick: () => A(`services/${e.serviceId}`),
|
|
@@ -239,25 +240,29 @@ function R() {
|
|
|
239
240
|
className: "flex items-center justify-between gap-4",
|
|
240
241
|
children: [/* @__PURE__ */ D("div", { children: [/* @__PURE__ */ E("h2", {
|
|
241
242
|
className: "text-lg font-semibold text-text-primary",
|
|
242
|
-
children: "Recent applications"
|
|
243
|
+
children: j("govcitizenhub.recentApplications", "Recent applications")
|
|
243
244
|
}), /* @__PURE__ */ E("p", {
|
|
244
245
|
className: "mt-0.5 text-xs text-text-muted",
|
|
245
|
-
children: "Latest filings (recent sample)"
|
|
246
|
+
children: j("govcitizenhub.recentApplicationsHint", "Latest filings (recent sample)")
|
|
246
247
|
})] }), /* @__PURE__ */ D("button", {
|
|
247
248
|
type: "button",
|
|
248
249
|
onClick: () => A("applications"),
|
|
249
250
|
className: "inline-flex items-center gap-1 text-sm font-medium text-action-primary-text outline-none transition-opacity hover:opacity-80 focus-visible:ring-1 focus-visible:ring-[var(--color-focus-ring)]",
|
|
250
|
-
children: [
|
|
251
|
+
children: [
|
|
252
|
+
j("common.viewAll", "View all"),
|
|
253
|
+
" ",
|
|
254
|
+
/* @__PURE__ */ E(x, { className: "h-4 w-4" })
|
|
255
|
+
]
|
|
251
256
|
})]
|
|
252
257
|
}), /* @__PURE__ */ E("div", {
|
|
253
258
|
className: "mt-3",
|
|
254
|
-
children:
|
|
259
|
+
children: X ? /* @__PURE__ */ E("div", {
|
|
255
260
|
className: "space-y-3",
|
|
256
261
|
children: Array.from({ length: 4 }, (e, t) => /* @__PURE__ */ E(k, { className: "h-12 w-full rounded-card" }, t))
|
|
257
|
-
}) :
|
|
262
|
+
}) : K.length === 0 ? /* @__PURE__ */ E(f, {
|
|
258
263
|
illustration: "empty-data",
|
|
259
|
-
title: "No applications yet",
|
|
260
|
-
description: "Citizen applications will appear here as they are filed."
|
|
264
|
+
title: j("govcitizenhub.noApplicationsYet", "No applications yet"),
|
|
265
|
+
description: j("govcitizenhub.noApplicationsRecentHint", "Citizen applications will appear here as they are filed.")
|
|
261
266
|
}) : /* @__PURE__ */ E("div", {
|
|
262
267
|
className: "overflow-x-auto",
|
|
263
268
|
children: /* @__PURE__ */ D("table", {
|
|
@@ -268,30 +273,30 @@ function R() {
|
|
|
268
273
|
/* @__PURE__ */ E("th", {
|
|
269
274
|
scope: "col",
|
|
270
275
|
className: "py-2.5 pr-3 font-medium",
|
|
271
|
-
children: "Reference No."
|
|
276
|
+
children: j("govcitizenhub.referenceNo", "Reference No.")
|
|
272
277
|
}),
|
|
273
278
|
/* @__PURE__ */ E("th", {
|
|
274
279
|
scope: "col",
|
|
275
280
|
className: "px-3 py-2.5 font-medium",
|
|
276
|
-
children: "Status"
|
|
281
|
+
children: j("govcitizenhub.status", "Status")
|
|
277
282
|
}),
|
|
278
283
|
/* @__PURE__ */ E("th", {
|
|
279
284
|
scope: "col",
|
|
280
285
|
className: "px-3 py-2.5 font-medium",
|
|
281
|
-
children: "Priority"
|
|
286
|
+
children: j("govcitizenhub.priority", "Priority")
|
|
282
287
|
}),
|
|
283
288
|
/* @__PURE__ */ E("th", {
|
|
284
289
|
scope: "col",
|
|
285
290
|
className: "px-3 py-2.5 font-medium",
|
|
286
|
-
children: "Submitted on"
|
|
291
|
+
children: j("govcitizenhub.submittedOn", "Submitted on")
|
|
287
292
|
}),
|
|
288
293
|
/* @__PURE__ */ E("th", {
|
|
289
294
|
scope: "col",
|
|
290
295
|
className: "w-8",
|
|
291
|
-
"aria-label": "Open"
|
|
296
|
+
"aria-label": j("govcitizenhub.open", "Open")
|
|
292
297
|
})
|
|
293
298
|
]
|
|
294
|
-
}) }), /* @__PURE__ */ E("tbody", { children:
|
|
299
|
+
}) }), /* @__PURE__ */ E("tbody", { children: K.map((e) => /* @__PURE__ */ D("tr", {
|
|
295
300
|
tabIndex: 0,
|
|
296
301
|
role: "button",
|
|
297
302
|
"aria-label": `Open application ${e.reference}`,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DashboardPage.js","names":[],"sources":["../../../src/govcitizenhub/pages/DashboardPage.tsx"],"sourcesContent":["/**\n * DashboardPage — the GovCitizenHub operations control center.\n * @module govcitizenhub/pages\n *\n * The six metric tiles and the \"Applications by status\" donut read from\n * `govDashboardSummary` — svc-computed, full-corpus AUTHORITATIVE counts, never\n * a capped client-side window. The \"Recent applications\" area trend and the\n * recent-activity list are the ONLY surfaces sourced from a paged read of the\n * latest applications, and are labelled as a recent sample so they never imply\n * a total.\n */\n\nimport { useMemo, useState } from 'react';\nimport {\n FileText,\n CreditCard,\n MessageSquareWarning,\n BadgeCheck,\n Briefcase,\n Building2,\n ChevronRight,\n} from 'lucide-react';\nimport { GlassCard, Skeleton } from '@burdenoff/fe-libs/ui';\n\nimport { PageLayout } from '../components/PageLayout';\nimport { MetricsCard } from '../components/MetricsCard';\nimport {\n GovAreaChart,\n GovDonutChart,\n ChartLegend,\n CHART_SERIES_COLORS,\n type AreaPoint,\n} from '../components/GovCharts';\nimport { StatusBadge } from '../components/StatusBadge';\nimport { EmptyState } from '../components/EmptyState';\nimport type { MetricDelta } from '../components/MetricsCard';\nimport { useGovApplications, useGovDashboardSummary, useGovApplicationsByService } from '../hooks';\nimport { useGovCitizenHub } from '../context';\nimport {\n formatNumber,\n formatCurrency,\n formatRelativeTime,\n formatEnumLabel,\n} from '../utils/formatters';\nimport type { GovApplicationStatus, GovDashboardTrend } from '../types';\n\nconst DAY_MS = 24 * 60 * 60 * 1000;\nconst TREND_DAYS = 30;\n/** Default currency for the aggregate pending-payments amount (svc summary has no currency). */\nconst DEFAULT_CURRENCY = 'INR';\n/** Size of the recent-applications window used for the trend + activity list only. */\nconst RECENT_WINDOW = 100;\n/** How many services to show in the \"Applications by service\" breakdown. */\nconst TOP_SERVICES_COUNT = 5;\n\n// Stable donut colour order — index into CHART_SERIES_COLORS by status.\nconst APP_STATUSES: GovApplicationStatus[] = [\n 'DRAFT',\n 'SUBMITTED',\n 'IN_REVIEW',\n 'INFO_REQUESTED',\n 'APPROVED',\n 'REJECTED',\n 'WITHDRAWN',\n];\n\n/**\n * Converts a svc-computed `GovDashboardTrend` into the `MetricsCard` delta prop.\n * FLAT trends (no meaningful period-over-period movement) return undefined so\n * the tile falls back to its plain sublabel instead of an ambiguous 0% arrow.\n *\n * `goodWhenUp` flips the green/red framing per metric — e.g. more applications\n * filed is good news (green on UP), but more pending payments or open\n * grievances is NOT (green on DOWN instead).\n */\nfunction toDelta(trend: GovDashboardTrend, goodWhenUp: boolean): MetricDelta | undefined {\n if (trend.direction === 'FLAT') return undefined;\n const isUp = trend.direction === 'UP';\n const magnitude =\n trend.changePercent != null\n ? `${Math.abs(trend.changePercent).toFixed(1)}%`\n : `${trend.current} new`;\n return {\n value: magnitude,\n direction: isUp ? 'up' : 'down',\n positive: isUp === goodWhenUp,\n caption: 'vs last 30 days',\n };\n}\n\nfunction buildTrendSeries(dates: string[], nowMs: number): AreaPoint[] {\n const now = new Date(nowMs);\n const start = new Date(now.getFullYear(), now.getMonth(), now.getDate());\n start.setTime(start.getTime() - (TREND_DAYS - 1) * DAY_MS);\n\n const perDay = new Array<number>(TREND_DAYS).fill(0);\n let baseline = 0;\n\n for (const iso of dates) {\n const when = new Date(iso);\n if (Number.isNaN(when.getTime())) continue;\n const dayIndex = Math.floor((when.getTime() - start.getTime()) / DAY_MS);\n if (dayIndex < 0) baseline += 1;\n else if (dayIndex < TREND_DAYS) perDay[dayIndex] += 1;\n }\n\n let running = baseline;\n return perDay.map((count, index) => {\n running += count;\n const day = new Date(start.getTime() + index * DAY_MS);\n return {\n label: day.toLocaleDateString(undefined, { month: 'short', day: 'numeric' }),\n value: running,\n };\n });\n}\n\nexport function DashboardPage() {\n const { navigateTo } = useGovCitizenHub();\n const [nowMs] = useState(() => Date.now());\n\n // Authoritative, backend-computed totals for every tile + the status donut.\n const summary = useGovDashboardSummary();\n // A recent window — ONLY drives the trend chart + recent-activity list.\n const applications = useGovApplications({ pagination: { limit: RECENT_WINDOW } });\n // Corpus-wide service breakdown (not capped to the recent window above).\n const byService = useGovApplicationsByService();\n\n const appItems = useMemo(() => applications.data?.items ?? [], [applications.data]);\n\n const trend = useMemo(\n () =>\n buildTrendSeries(\n appItems.map((a) => a.createdAt),\n nowMs\n ),\n [appItems, nowMs]\n );\n\n const statusBuckets = useMemo(() => {\n const byStatus = summary.data?.applicationsByStatus ?? [];\n return byStatus\n .map((bucket) => {\n const orderIndex = APP_STATUSES.indexOf(bucket.status);\n const colorIndex = orderIndex >= 0 ? orderIndex : 0;\n return {\n name: formatEnumLabel(bucket.status),\n value: bucket.count,\n color: CHART_SERIES_COLORS[colorIndex % CHART_SERIES_COLORS.length],\n };\n })\n .filter((slice) => slice.value > 0);\n }, [summary.data]);\n\n const statusTotal = useMemo(\n () => statusBuckets.reduce((sum, slice) => sum + slice.value, 0),\n [statusBuckets]\n );\n\n const recent = useMemo(\n () =>\n [...appItems]\n .sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())\n .slice(0, 6),\n [appItems]\n );\n\n const topServices = useMemo(\n () => (byService.data ?? []).slice(0, TOP_SERVICES_COUNT),\n [byService.data]\n );\n const topServicesMax = useMemo(\n () => topServices.reduce((max, row) => Math.max(max, row.count), 0),\n [topServices]\n );\n\n const metricsLoading = summary.isLoading;\n const trendLoading = applications.isLoading;\n const applicationsTotal = summary.data?.applicationsTotal ?? 0;\n const pendingAmount = summary.data?.pendingPaymentsAmount ?? 0;\n\n const cards = [\n {\n label: 'Applications',\n value: formatNumber(applicationsTotal),\n sublabel: 'filed to date',\n delta: summary.data ? toDelta(summary.data.applicationsTotalTrend, true) : undefined,\n icon: <FileText className=\"h-5 w-5\" />,\n path: 'applications',\n featured: true,\n },\n {\n label: 'Pending payments',\n value: formatNumber(summary.data?.pendingPayments ?? 0),\n sublabel:\n pendingAmount > 0\n ? `${formatCurrency(pendingAmount, DEFAULT_CURRENCY)} due`\n : 'all settled',\n delta: summary.data ? toDelta(summary.data.pendingPaymentsTrend, false) : undefined,\n icon: <CreditCard className=\"h-5 w-5\" />,\n path: 'payments',\n accent: 'warning' as const,\n },\n {\n label: 'Open grievances',\n value: formatNumber(summary.data?.openGrievances ?? 0),\n sublabel: 'awaiting acknowledgement',\n delta: summary.data ? toDelta(summary.data.openGrievancesTrend, false) : undefined,\n icon: <MessageSquareWarning className=\"h-5 w-5\" />,\n path: 'grievances',\n accent: 'error' as const,\n },\n {\n label: 'Active permits',\n value: formatNumber(summary.data?.activePermits ?? 0),\n sublabel: 'currently valid',\n delta: summary.data ? toDelta(summary.data.activePermitsTrend, true) : undefined,\n icon: <BadgeCheck className=\"h-5 w-5\" />,\n path: 'permits',\n accent: 'success' as const,\n },\n {\n label: 'Published services',\n value: formatNumber(summary.data?.publishedServices ?? 0),\n sublabel: 'available to citizens',\n delta: summary.data ? toDelta(summary.data.publishedServicesTrend, true) : undefined,\n icon: <Briefcase className=\"h-5 w-5\" />,\n path: 'services',\n },\n {\n label: 'Active agencies',\n value: formatNumber(summary.data?.activeAgencies ?? 0),\n sublabel: 'delivering services',\n delta: summary.data ? toDelta(summary.data.activeAgenciesTrend, true) : undefined,\n icon: <Building2 className=\"h-5 w-5\" />,\n path: 'agencies',\n },\n ];\n\n return (\n <PageLayout\n title=\"GovCitizenHub\"\n titleGradient\n aurora\n description=\"Your live government service-delivery operations, at a glance.\"\n >\n <div className=\"grid grid-cols-2 gap-4 sm:grid-cols-3 xl:grid-cols-6\">\n {cards.map((card) => (\n <MetricsCard\n key={card.label}\n icon={card.icon}\n value={metricsLoading ? '—' : card.value}\n label={card.label}\n sublabel={card.sublabel}\n delta={metricsLoading ? undefined : card.delta}\n featured={card.featured}\n accent={card.accent}\n onClick={() => navigateTo(card.path)}\n />\n ))}\n </div>\n\n <div className=\"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-5\">\n <GlassCard treatment=\"glass\" className=\"p-5 lg:col-span-3\">\n <div className=\"flex items-start justify-between gap-4\">\n <div>\n <h2 className=\"text-lg font-semibold text-text-primary\">Applications over time</h2>\n <p className=\"mt-0.5 text-xs text-text-muted\">\n Cumulative filings (recent sample, not a total)\n </p>\n </div>\n <span className=\"shrink-0 rounded-full border border-border-seam bg-bg-surface px-3 py-1 text-xs font-medium text-text-secondary\">\n Last 30 days\n </span>\n </div>\n <div className=\"mt-4\">\n {trendLoading ? (\n <Skeleton className=\"h-[260px] w-full rounded-card\" />\n ) : (\n <GovAreaChart data={trend} emptyLabel=\"No applications filed recently.\" />\n )}\n </div>\n </GlassCard>\n\n <GlassCard treatment=\"plain\" className=\"border-border-seam p-5 lg:col-span-2\">\n <h2 className=\"text-lg font-semibold text-text-primary\">Applications by status</h2>\n <div className=\"mt-3\">\n {metricsLoading ? (\n <Skeleton className=\"h-[240px] w-full rounded-card\" />\n ) : statusBuckets.length === 0 ? (\n <EmptyState\n title=\"No applications yet\"\n description=\"Filed applications will break down here by status.\"\n />\n ) : (\n <>\n <GovDonutChart\n data={statusBuckets}\n centerValue={formatNumber(applicationsTotal)}\n centerLabel=\"Total\"\n />\n <ChartLegend\n className=\"mt-4\"\n items={statusBuckets.map((slice) => {\n const denom = statusTotal || 1;\n const pct = Math.round((slice.value / denom) * 100);\n return {\n label: slice.name,\n color: slice.color,\n value: `${formatNumber(slice.value)} (${pct}%)`,\n };\n })}\n />\n </>\n )}\n </div>\n </GlassCard>\n </div>\n\n <GlassCard treatment=\"plain\" className=\"mt-6 border-border-seam p-5\">\n <div>\n <h2 className=\"text-lg font-semibold text-text-primary\">Applications by service</h2>\n <p className=\"mt-0.5 text-xs text-text-muted\">\n Corpus-wide volume, not limited to the recent sample above\n </p>\n </div>\n <div className=\"mt-4\">\n {byService.isLoading ? (\n <div className=\"space-y-3\">\n {Array.from({ length: 3 }, (_, i) => (\n <Skeleton key={i} className=\"h-8 w-full rounded-card\" />\n ))}\n </div>\n ) : topServices.length === 0 ? (\n <EmptyState\n title=\"No applications yet\"\n description=\"Once citizens file applications, the busiest services will rank here.\"\n />\n ) : (\n <ul className=\"space-y-3\">\n {topServices.map((row) => {\n const pct = topServicesMax > 0 ? Math.round((row.count / topServicesMax) * 100) : 0;\n return (\n <li key={row.serviceId}>\n <button\n type=\"button\"\n onClick={() => navigateTo(`services/${row.serviceId}`)}\n className=\"flex w-full items-center gap-3 rounded-button text-left outline-none focus-visible:ring-1 focus-visible:ring-[var(--color-focus-ring)]\"\n >\n <span className=\"w-40 shrink-0 truncate text-sm font-medium text-text-primary\">\n {row.serviceName}\n </span>\n <span className=\"h-2 flex-1 overflow-hidden rounded-full bg-bg-sunken\">\n <span\n className=\"block h-full rounded-full bg-[var(--color-action-primary-bg)]\"\n style={{ width: `${pct}%` }}\n />\n </span>\n <span className=\"w-10 shrink-0 text-right text-sm font-semibold tabular-nums text-text-primary\">\n {formatNumber(row.count)}\n </span>\n </button>\n </li>\n );\n })}\n </ul>\n )}\n </div>\n </GlassCard>\n\n <GlassCard treatment=\"plain\" className=\"mt-6 border-border-seam p-5\">\n <div className=\"flex items-center justify-between gap-4\">\n <div>\n <h2 className=\"text-lg font-semibold text-text-primary\">Recent applications</h2>\n <p className=\"mt-0.5 text-xs text-text-muted\">Latest filings (recent sample)</p>\n </div>\n <button\n type=\"button\"\n onClick={() => navigateTo('applications')}\n className=\"inline-flex items-center gap-1 text-sm font-medium text-action-primary-text outline-none transition-opacity hover:opacity-80 focus-visible:ring-1 focus-visible:ring-[var(--color-focus-ring)]\"\n >\n View all <ChevronRight className=\"h-4 w-4\" />\n </button>\n </div>\n <div className=\"mt-3\">\n {trendLoading ? (\n <div className=\"space-y-3\">\n {Array.from({ length: 4 }, (_, i) => (\n <Skeleton key={i} className=\"h-12 w-full rounded-card\" />\n ))}\n </div>\n ) : recent.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title=\"No applications yet\"\n description=\"Citizen applications will appear here as they are filed.\"\n />\n ) : (\n <div className=\"overflow-x-auto\">\n <table className=\"w-full min-w-[34rem] border-collapse text-left\">\n <thead>\n <tr className=\"border-b border-border-seam text-xs font-medium uppercase tracking-wide text-text-muted\">\n <th scope=\"col\" className=\"py-2.5 pr-3 font-medium\">\n Reference No.\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 font-medium\">\n Status\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 font-medium\">\n Priority\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 font-medium\">\n Submitted on\n </th>\n <th scope=\"col\" className=\"w-8\" aria-label=\"Open\" />\n </tr>\n </thead>\n <tbody>\n {recent.map((app) => (\n <tr\n key={app.id}\n tabIndex={0}\n role=\"button\"\n aria-label={`Open application ${app.reference}`}\n onClick={() => navigateTo(`applications/${app.id}`)}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n navigateTo(`applications/${app.id}`);\n }\n }}\n className=\"group cursor-pointer border-b border-border-subtle outline-none transition-colors last:border-0 hover:bg-bg-sunken/60 focus-visible:bg-bg-sunken/60\"\n >\n <td className=\"py-3 pr-3\">\n <span className=\"flex items-center gap-2.5\">\n <span className=\"flex size-8 shrink-0 items-center justify-center rounded-button bg-[var(--color-accent-soft)] text-action-primary-text\">\n <FileText className=\"h-4 w-4\" />\n </span>\n <span className=\"truncate text-sm font-medium text-text-primary\">\n {app.reference}\n </span>\n </span>\n </td>\n <td className=\"px-3 py-3\">\n <StatusBadge status={app.status} />\n </td>\n <td className=\"px-3 py-3\">\n <StatusBadge status={app.priority} />\n </td>\n <td className=\"px-3 py-3 text-sm text-text-secondary\">\n {formatRelativeTime(app.submittedAt ?? app.createdAt)}\n </td>\n <td className=\"pr-1\">\n <ChevronRight className=\"h-4 w-4 text-text-muted transition-transform group-hover:translate-x-0.5\" />\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )}\n </div>\n </GlassCard>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AA8CA,IAAM,IAAS,OAAU,KAAK,KACxB,IAAa,IAEb,IAAmB,OAEnB,IAAgB,KAEhB,IAAqB,GAGrB,IAAuC;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAWA,SAAS,EAAQ,GAA0B,GAA8C;CACvF,IAAI,EAAM,cAAc,QAAQ;CAChC,IAAM,IAAO,EAAM,cAAc;CAKjC,OAAO;EACL,OAJA,EAAM,iBAAiB,OAEnB,GAAG,EAAM,QAAQ,QADjB,GAAG,KAAK,IAAI,EAAM,aAAa,EAAE,QAAQ,CAAC,EAAE;EAIhD,WAAW,IAAO,OAAO;EACzB,UAAU,MAAS;EACnB,SAAS;CACX;AACF;AAEA,SAAS,EAAiB,GAAiB,GAA4B;CACrE,IA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AU,WAAU,UAAW,CAAA;WAC3B,CAAA,GACN,kBAAC,QAAD;YAAM,WAAU;sBACb,EAAI;WACD,CAAA,CACF;;SACJ,CAAA;SACJ,kBAAC,MAAD;UAAI,WAAU;oBACZ,kBAAC,GAAD,EAAa,QAAQ,EAAI,OAAS,CAAA;SAChC,CAAA;SACJ,kBAAC,MAAD;UAAI,WAAU;oBACZ,kBAAC,GAAD,EAAa,QAAQ,EAAI,SAAW,CAAA;SAClC,CAAA;SACJ,kBAAC,MAAD;UAAI,WAAU;oBACX,EAAmB,EAAI,eAAe,EAAI,SAAS;SAClD,CAAA;SACJ,kBAAC,MAAD;UAAI,WAAU;oBACZ,kBAAC,GAAD,EAAc,WAAU,2EAA4E,CAAA;SAClG,CAAA;QACF;UAnCG,EAAI,EAmCP,CACL,EACI,CAAA,CACF;;KACJ,CAAA;IAEJ,CAAA,CACI;;EACD;;AAEhB"}
|
|
1
|
+
{"version":3,"file":"DashboardPage.js","names":[],"sources":["../../../src/govcitizenhub/pages/DashboardPage.tsx"],"sourcesContent":["/**\n * DashboardPage — the GovCitizenHub operations control center.\n * @module govcitizenhub/pages\n *\n * The six metric tiles and the \"Applications by status\" donut read from\n * `govDashboardSummary` — svc-computed, full-corpus AUTHORITATIVE counts, never\n * a capped client-side window. The \"Recent applications\" area trend and the\n * recent-activity list are the ONLY surfaces sourced from a paged read of the\n * latest applications, and are labelled as a recent sample so they never imply\n * a total.\n */\n\nimport { useMemo, useState } from 'react';\nimport {\n FileText,\n CreditCard,\n MessageSquareWarning,\n BadgeCheck,\n Briefcase,\n Building2,\n ChevronRight,\n} from 'lucide-react';\nimport { GlassCard, Skeleton } from '@burdenoff/fe-libs/ui';\n\nimport { PageLayout } from '../components/PageLayout';\nimport { MetricsCard } from '../components/MetricsCard';\nimport {\n GovAreaChart,\n GovDonutChart,\n ChartLegend,\n CHART_SERIES_COLORS,\n type AreaPoint,\n} from '../components/GovCharts';\nimport { StatusBadge } from '../components/StatusBadge';\nimport { EmptyState } from '../components/EmptyState';\nimport type { MetricDelta } from '../components/MetricsCard';\nimport { useGovApplications, useGovDashboardSummary, useGovApplicationsByService } from '../hooks';\nimport { useGovCitizenHub } from '../context';\nimport { useTr } from '../../shared/hooks/useTr';\nimport {\n formatNumber,\n formatCurrency,\n formatRelativeTime,\n formatEnumLabel,\n} from '../utils/formatters';\nimport type { GovApplicationStatus, GovDashboardTrend } from '../types';\n\nconst DAY_MS = 24 * 60 * 60 * 1000;\nconst TREND_DAYS = 30;\n/** Default currency for the aggregate pending-payments amount (svc summary has no currency). */\nconst DEFAULT_CURRENCY = 'INR';\n/** Size of the recent-applications window used for the trend + activity list only. */\nconst RECENT_WINDOW = 100;\n/** How many services to show in the \"Applications by service\" breakdown. */\nconst TOP_SERVICES_COUNT = 5;\n\n// Stable donut colour order — index into CHART_SERIES_COLORS by status.\nconst APP_STATUSES: GovApplicationStatus[] = [\n 'DRAFT',\n 'SUBMITTED',\n 'IN_REVIEW',\n 'INFO_REQUESTED',\n 'APPROVED',\n 'REJECTED',\n 'WITHDRAWN',\n];\n\n/**\n * Converts a svc-computed `GovDashboardTrend` into the `MetricsCard` delta prop.\n * FLAT trends (no meaningful period-over-period movement) return undefined so\n * the tile falls back to its plain sublabel instead of an ambiguous 0% arrow.\n *\n * `goodWhenUp` flips the green/red framing per metric — e.g. more applications\n * filed is good news (green on UP), but more pending payments or open\n * grievances is NOT (green on DOWN instead).\n */\nfunction toDelta(\n trend: GovDashboardTrend,\n goodWhenUp: boolean,\n vsCaption: string\n): MetricDelta | undefined {\n if (trend.direction === 'FLAT') return undefined;\n const isUp = trend.direction === 'UP';\n const magnitude =\n trend.changePercent != null\n ? `${Math.abs(trend.changePercent).toFixed(1)}%`\n : `${trend.current} new`;\n return {\n value: magnitude,\n direction: isUp ? 'up' : 'down',\n positive: isUp === goodWhenUp,\n caption: vsCaption,\n };\n}\n\nfunction buildTrendSeries(dates: string[], nowMs: number): AreaPoint[] {\n const now = new Date(nowMs);\n const start = new Date(now.getFullYear(), now.getMonth(), now.getDate());\n start.setTime(start.getTime() - (TREND_DAYS - 1) * DAY_MS);\n\n const perDay = new Array<number>(TREND_DAYS).fill(0);\n let baseline = 0;\n\n for (const iso of dates) {\n const when = new Date(iso);\n if (Number.isNaN(when.getTime())) continue;\n const dayIndex = Math.floor((when.getTime() - start.getTime()) / DAY_MS);\n if (dayIndex < 0) baseline += 1;\n else if (dayIndex < TREND_DAYS) perDay[dayIndex] += 1;\n }\n\n let running = baseline;\n return perDay.map((count, index) => {\n running += count;\n const day = new Date(start.getTime() + index * DAY_MS);\n return {\n label: day.toLocaleDateString(undefined, { month: 'short', day: 'numeric' }),\n value: running,\n };\n });\n}\n\nexport function DashboardPage() {\n const { navigateTo } = useGovCitizenHub();\n const tr = useTr();\n const [nowMs] = useState(() => Date.now());\n\n // Authoritative, backend-computed totals for every tile + the status donut.\n const summary = useGovDashboardSummary();\n // A recent window — ONLY drives the trend chart + recent-activity list.\n const applications = useGovApplications({ pagination: { limit: RECENT_WINDOW } });\n // Corpus-wide service breakdown (not capped to the recent window above).\n const byService = useGovApplicationsByService();\n\n const appItems = useMemo(() => applications.data?.items ?? [], [applications.data]);\n\n const trend = useMemo(\n () =>\n buildTrendSeries(\n appItems.map((a) => a.createdAt),\n nowMs\n ),\n [appItems, nowMs]\n );\n\n const statusBuckets = useMemo(() => {\n const byStatus = summary.data?.applicationsByStatus ?? [];\n return byStatus\n .map((bucket) => {\n const orderIndex = APP_STATUSES.indexOf(bucket.status);\n const colorIndex = orderIndex >= 0 ? orderIndex : 0;\n return {\n name: formatEnumLabel(bucket.status),\n value: bucket.count,\n color: CHART_SERIES_COLORS[colorIndex % CHART_SERIES_COLORS.length],\n };\n })\n .filter((slice) => slice.value > 0);\n }, [summary.data]);\n\n const statusTotal = useMemo(\n () => statusBuckets.reduce((sum, slice) => sum + slice.value, 0),\n [statusBuckets]\n );\n\n const recent = useMemo(\n () =>\n [...appItems]\n .sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())\n .slice(0, 6),\n [appItems]\n );\n\n const topServices = useMemo(\n () => (byService.data ?? []).slice(0, TOP_SERVICES_COUNT),\n [byService.data]\n );\n const topServicesMax = useMemo(\n () => topServices.reduce((max, row) => Math.max(max, row.count), 0),\n [topServices]\n );\n\n const metricsLoading = summary.isLoading;\n const trendLoading = applications.isLoading;\n const applicationsTotal = summary.data?.applicationsTotal ?? 0;\n const pendingAmount = summary.data?.pendingPaymentsAmount ?? 0;\n\n const vsLast30Days = tr('govcitizenhub.vsLast30Days', 'vs last 30 days');\n\n const cards = [\n {\n label: tr('govcitizenhub.metricApplications', 'Applications'),\n value: formatNumber(applicationsTotal),\n sublabel: tr('govcitizenhub.metricApplicationsSub', 'filed to date'),\n delta: summary.data ? toDelta(summary.data.applicationsTotalTrend, true, vsLast30Days) : undefined,\n icon: <FileText className=\"h-5 w-5\" />,\n path: 'applications',\n featured: true,\n },\n {\n label: tr('govcitizenhub.metricPendingPayments', 'Pending payments'),\n value: formatNumber(summary.data?.pendingPayments ?? 0),\n sublabel:\n pendingAmount > 0\n ? tr('govcitizenhub.metricPendingPaymentsDue', '{{amount}} due', {\n amount: formatCurrency(pendingAmount, DEFAULT_CURRENCY),\n })\n : tr('govcitizenhub.metricPendingPaymentsSettled', 'all settled'),\n delta: summary.data ? toDelta(summary.data.pendingPaymentsTrend, false, vsLast30Days) : undefined,\n icon: <CreditCard className=\"h-5 w-5\" />,\n path: 'payments',\n accent: 'warning' as const,\n },\n {\n label: tr('govcitizenhub.metricOpenGrievances', 'Open grievances'),\n value: formatNumber(summary.data?.openGrievances ?? 0),\n sublabel: tr('govcitizenhub.metricOpenGrievancesSub', 'awaiting acknowledgement'),\n delta: summary.data ? toDelta(summary.data.openGrievancesTrend, false, vsLast30Days) : undefined,\n icon: <MessageSquareWarning className=\"h-5 w-5\" />,\n path: 'grievances',\n accent: 'error' as const,\n },\n {\n label: tr('govcitizenhub.metricActivePermits', 'Active permits'),\n value: formatNumber(summary.data?.activePermits ?? 0),\n sublabel: tr('govcitizenhub.metricActivePermitsSub', 'currently valid'),\n delta: summary.data ? toDelta(summary.data.activePermitsTrend, true, vsLast30Days) : undefined,\n icon: <BadgeCheck className=\"h-5 w-5\" />,\n path: 'permits',\n accent: 'success' as const,\n },\n {\n label: tr('govcitizenhub.metricPublishedServices', 'Published services'),\n value: formatNumber(summary.data?.publishedServices ?? 0),\n sublabel: tr('govcitizenhub.metricPublishedServicesSub', 'available to citizens'),\n delta: summary.data ? toDelta(summary.data.publishedServicesTrend, true, vsLast30Days) : undefined,\n icon: <Briefcase className=\"h-5 w-5\" />,\n path: 'services',\n },\n {\n label: tr('govcitizenhub.metricActiveAgencies', 'Active agencies'),\n value: formatNumber(summary.data?.activeAgencies ?? 0),\n sublabel: tr('govcitizenhub.metricActiveAgenciesSub', 'delivering services'),\n delta: summary.data ? toDelta(summary.data.activeAgenciesTrend, true, vsLast30Days) : undefined,\n icon: <Building2 className=\"h-5 w-5\" />,\n path: 'agencies',\n },\n ];\n\n return (\n <PageLayout\n title={tr('govcitizenhub.dashboardTitle', 'GovCitizenHub')}\n titleGradient\n aurora\n description={tr(\n 'govcitizenhub.dashboardDescription',\n 'Your live government service-delivery operations, at a glance.'\n )}\n >\n <div className=\"grid grid-cols-2 gap-4 sm:grid-cols-3 xl:grid-cols-6\">\n {cards.map((card) => (\n <MetricsCard\n key={card.label}\n icon={card.icon}\n value={metricsLoading ? '—' : card.value}\n label={card.label}\n sublabel={card.sublabel}\n delta={metricsLoading ? undefined : card.delta}\n featured={card.featured}\n accent={card.accent}\n onClick={() => navigateTo(card.path)}\n />\n ))}\n </div>\n\n <div className=\"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-5\">\n <GlassCard treatment=\"glass\" className=\"p-5 lg:col-span-3\">\n <div className=\"flex items-start justify-between gap-4\">\n <div>\n <h2 className=\"text-lg font-semibold text-text-primary\">\n {tr('govcitizenhub.applicationsOverTime', 'Applications over time')}\n </h2>\n <p className=\"mt-0.5 text-xs text-text-muted\">\n {tr('govcitizenhub.applicationsOverTimeHint', 'Cumulative filings (recent sample, not a total)')}\n </p>\n </div>\n <span className=\"shrink-0 rounded-full border border-border-seam bg-bg-surface px-3 py-1 text-xs font-medium text-text-secondary\">\n {tr('govcitizenhub.last30Days', 'Last 30 days')}\n </span>\n </div>\n <div className=\"mt-4\">\n {trendLoading ? (\n <Skeleton className=\"h-[260px] w-full rounded-card\" />\n ) : (\n <GovAreaChart\n data={trend}\n emptyLabel={tr(\n 'govcitizenhub.noApplicationsRecentHint',\n 'Citizen applications will appear here as they are filed.'\n )}\n />\n )}\n </div>\n </GlassCard>\n\n <GlassCard treatment=\"plain\" className=\"border-border-seam p-5 lg:col-span-2\">\n <h2 className=\"text-lg font-semibold text-text-primary\">\n {tr('govcitizenhub.applicationsByStatus', 'Applications by status')}\n </h2>\n <div className=\"mt-3\">\n {metricsLoading ? (\n <Skeleton className=\"h-[240px] w-full rounded-card\" />\n ) : statusBuckets.length === 0 ? (\n <EmptyState\n title={tr('govcitizenhub.noApplicationsYet', 'No applications yet')}\n description={tr(\n 'govcitizenhub.noApplicationsStatusHint',\n 'Filed applications will break down here by status.'\n )}\n />\n ) : (\n <>\n <GovDonutChart\n data={statusBuckets}\n centerValue={formatNumber(applicationsTotal)}\n centerLabel={tr('govcitizenhub.chartTotal', 'Total')}\n />\n <ChartLegend\n className=\"mt-4\"\n items={statusBuckets.map((slice) => {\n const denom = statusTotal || 1;\n const pct = Math.round((slice.value / denom) * 100);\n return {\n label: slice.name,\n color: slice.color,\n value: `${formatNumber(slice.value)} (${pct}%)`,\n };\n })}\n />\n </>\n )}\n </div>\n </GlassCard>\n </div>\n\n <GlassCard treatment=\"plain\" className=\"mt-6 border-border-seam p-5\">\n <div>\n <h2 className=\"text-lg font-semibold text-text-primary\">\n {tr('govcitizenhub.applicationsByService', 'Applications by service')}\n </h2>\n <p className=\"mt-0.5 text-xs text-text-muted\">\n {tr(\n 'govcitizenhub.applicationsByServiceHint',\n 'Corpus-wide volume, not limited to the recent sample above'\n )}\n </p>\n </div>\n <div className=\"mt-4\">\n {byService.isLoading ? (\n <div className=\"space-y-3\">\n {Array.from({ length: 3 }, (_, i) => (\n <Skeleton key={i} className=\"h-8 w-full rounded-card\" />\n ))}\n </div>\n ) : topServices.length === 0 ? (\n <EmptyState\n title={tr('govcitizenhub.noApplicationsYet', 'No applications yet')}\n description={tr(\n 'govcitizenhub.noApplicationsServiceHint',\n 'Once citizens file applications, the busiest services will rank here.'\n )}\n />\n ) : (\n <ul className=\"space-y-3\">\n {topServices.map((row) => {\n const pct = topServicesMax > 0 ? Math.round((row.count / topServicesMax) * 100) : 0;\n return (\n <li key={row.serviceId}>\n <button\n type=\"button\"\n onClick={() => navigateTo(`services/${row.serviceId}`)}\n className=\"flex w-full items-center gap-3 rounded-button text-left outline-none focus-visible:ring-1 focus-visible:ring-[var(--color-focus-ring)]\"\n >\n <span className=\"w-40 shrink-0 truncate text-sm font-medium text-text-primary\">\n {row.serviceName}\n </span>\n <span className=\"h-2 flex-1 overflow-hidden rounded-full bg-bg-sunken\">\n <span\n className=\"block h-full rounded-full bg-[var(--color-action-primary-bg)]\"\n style={{ width: `${pct}%` }}\n />\n </span>\n <span className=\"w-10 shrink-0 text-right text-sm font-semibold tabular-nums text-text-primary\">\n {formatNumber(row.count)}\n </span>\n </button>\n </li>\n );\n })}\n </ul>\n )}\n </div>\n </GlassCard>\n\n <GlassCard treatment=\"plain\" className=\"mt-6 border-border-seam p-5\">\n <div className=\"flex items-center justify-between gap-4\">\n <div>\n <h2 className=\"text-lg font-semibold text-text-primary\">\n {tr('govcitizenhub.recentApplications', 'Recent applications')}\n </h2>\n <p className=\"mt-0.5 text-xs text-text-muted\">\n {tr('govcitizenhub.recentApplicationsHint', 'Latest filings (recent sample)')}\n </p>\n </div>\n <button\n type=\"button\"\n onClick={() => navigateTo('applications')}\n className=\"inline-flex items-center gap-1 text-sm font-medium text-action-primary-text outline-none transition-opacity hover:opacity-80 focus-visible:ring-1 focus-visible:ring-[var(--color-focus-ring)]\"\n >\n {tr('common.viewAll', 'View all')} <ChevronRight className=\"h-4 w-4\" />\n </button>\n </div>\n <div className=\"mt-3\">\n {trendLoading ? (\n <div className=\"space-y-3\">\n {Array.from({ length: 4 }, (_, i) => (\n <Skeleton key={i} className=\"h-12 w-full rounded-card\" />\n ))}\n </div>\n ) : recent.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={tr('govcitizenhub.noApplicationsYet', 'No applications yet')}\n description={tr(\n 'govcitizenhub.noApplicationsRecentHint',\n 'Citizen applications will appear here as they are filed.'\n )}\n />\n ) : (\n <div className=\"overflow-x-auto\">\n <table className=\"w-full min-w-[34rem] border-collapse text-left\">\n <thead>\n <tr className=\"border-b border-border-seam text-xs font-medium uppercase tracking-wide text-text-muted\">\n <th scope=\"col\" className=\"py-2.5 pr-3 font-medium\">\n {tr('govcitizenhub.referenceNo', 'Reference No.')}\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 font-medium\">\n {tr('govcitizenhub.status', 'Status')}\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 font-medium\">\n {tr('govcitizenhub.priority', 'Priority')}\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 font-medium\">\n {tr('govcitizenhub.submittedOn', 'Submitted on')}\n </th>\n <th scope=\"col\" className=\"w-8\" aria-label={tr('govcitizenhub.open', 'Open')} />\n </tr>\n </thead>\n <tbody>\n {recent.map((app) => (\n <tr\n key={app.id}\n tabIndex={0}\n role=\"button\"\n aria-label={`Open application ${app.reference}`}\n onClick={() => navigateTo(`applications/${app.id}`)}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n navigateTo(`applications/${app.id}`);\n }\n }}\n className=\"group cursor-pointer border-b border-border-subtle outline-none transition-colors last:border-0 hover:bg-bg-sunken/60 focus-visible:bg-bg-sunken/60\"\n >\n <td className=\"py-3 pr-3\">\n <span className=\"flex items-center gap-2.5\">\n <span className=\"flex size-8 shrink-0 items-center justify-center rounded-button bg-[var(--color-accent-soft)] text-action-primary-text\">\n <FileText className=\"h-4 w-4\" />\n </span>\n <span className=\"truncate text-sm font-medium text-text-primary\">\n {app.reference}\n </span>\n </span>\n </td>\n <td className=\"px-3 py-3\">\n <StatusBadge status={app.status} />\n </td>\n <td className=\"px-3 py-3\">\n <StatusBadge status={app.priority} />\n </td>\n <td className=\"px-3 py-3 text-sm text-text-secondary\">\n {formatRelativeTime(app.submittedAt ?? app.createdAt)}\n </td>\n <td className=\"pr-1\">\n <ChevronRight className=\"h-4 w-4 text-text-muted transition-transform group-hover:translate-x-0.5\" />\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )}\n </div>\n </GlassCard>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;AA+CA,IAAM,IAAS,OAAU,KAAK,KACxB,IAAa,IAEb,IAAmB,OAEnB,IAAgB,KAEhB,IAAqB,GAGrB,IAAuC;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;AACF;AAWA,SAAS,EACP,GACA,GACA,GACyB;CACzB,IAAI,EAAM,cAAc,QAAQ;CAChC,IAAM,IAAO,EAAM,cAAc;CAKjC,OAAO;EACL,OAJA,EAAM,iBAAiB,OAEnB,GAAG,EAAM,QAAQ,QADjB,GAAG,KAAK,IAAI,EAAM,aAAa,EAAE,QAAQ,CAAC,EAAE;EAIhD,WAAW,IAAO,OAAO;EACzB,UAAU,MAAS;EACnB,SAAS;CACX;AACF;AAEA,SAAS,EAAiB,GAAiB,GAA4B;CACrE,IAAM,IAAM,IAAI,KAAK,CAAK,GACpB,IAAQ,IAAI,KAAK,EAAI,YAAY,GAAG,EAAI,SAAS,GAAG,EAAI,QAAQ,CAAC;CACvE,EAAM,QAAQ,EAAM,QAAQ,KAAK,IAAa,KAAK,CAAM;CAEzD,IAAM,IAAa,MAAc,CAAU,EAAE,KAAK,CAAC,GAC/C,IAAW;CAEf,KAAK,IAAM,KAAO,GAAO;EACvB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
* useTr — translation hook with fallback semantics.
|
|
3
|
+
*
|
|
4
|
+
* Wraps `useI18n().t()` so that when a key has no translation (i.e. the
|
|
5
|
+
* provider returns the key itself), the caller's English fallback is used
|
|
6
|
+
* instead. This keeps consumer call sites consistent and avoids leaking
|
|
7
|
+
* untranslated keys into the UI.
|
|
8
|
+
*
|
|
9
|
+
* Supports optional interpolation params using `{{key}}` placeholders.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* const tr = useTr();
|
|
13
|
+
* return <h1>{tr('govcitizenhub.dashboard.title', 'Dashboard')}</h1>;
|
|
14
|
+
* return <p>{tr('govcitizenhub.delete.confirm', 'Delete {{count}} items?', { count: 5 })}</p>;
|
|
15
|
+
*/
|
|
16
|
+
export declare function useTr(): (key: string, fallback: string, params?: Record<string, string | number>) => string;
|
|
17
|
+
//# sourceMappingURL=useTr.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTr.d.ts","sourceRoot":"","sources":["../../../src/shared/hooks/useTr.ts"],"names":[],"mappings":"AAGA;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,KAAK,IAAI,CACvB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,MAAM,EAChB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAAC,KACrC,MAAM,CAcV"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { useCallback as e } from "react";
|
|
2
|
+
import { useI18n as t } from "@burdenoff/fe-libs/shared/providers/shell/I18nProvider";
|
|
3
|
+
//#region src/shared/hooks/useTr.ts
|
|
4
|
+
function n() {
|
|
5
|
+
let { t: n } = t();
|
|
6
|
+
return e((e, t, r) => {
|
|
7
|
+
let i = n(e, t), a = i === e ? t : i;
|
|
8
|
+
return r ? Object.entries(r).reduce((e, [t, n]) => e.replace(RegExp(`\\{\\{${t}\\}\\}`, "g"), String(n)), a) : a;
|
|
9
|
+
}, [n]);
|
|
10
|
+
}
|
|
11
|
+
//#endregion
|
|
12
|
+
export { n as useTr };
|
|
13
|
+
|
|
14
|
+
//# sourceMappingURL=useTr.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useTr.js","names":[],"sources":["../../../src/shared/hooks/useTr.ts"],"sourcesContent":["import { useCallback } from 'react';\nimport { useI18n } from '@burdenoff/fe-libs/shared/providers/shell/I18nProvider';\n\n/**\n * useTr — translation hook with fallback semantics.\n *\n * Wraps `useI18n().t()` so that when a key has no translation (i.e. the\n * provider returns the key itself), the caller's English fallback is used\n * instead. This keeps consumer call sites consistent and avoids leaking\n * untranslated keys into the UI.\n *\n * Supports optional interpolation params using `{{key}}` placeholders.\n *\n * @example\n * const tr = useTr();\n * return <h1>{tr('govcitizenhub.dashboard.title', 'Dashboard')}</h1>;\n * return <p>{tr('govcitizenhub.delete.confirm', 'Delete {{count}} items?', { count: 5 })}</p>;\n */\nexport function useTr(): (\n key: string,\n fallback: string,\n params?: Record<string, string | number>\n) => string {\n const { t } = useI18n();\n return useCallback(\n (key: string, fallback: string, params?: Record<string, string | number>): string => {\n const translated = t(key, fallback);\n const raw = translated === key ? fallback : translated;\n if (!params) return raw;\n return Object.entries(params).reduce(\n (str, [k, v]) => str.replace(new RegExp(`\\\\{\\\\{${k}\\\\}\\\\}`, 'g'), String(v)),\n raw\n );\n },\n [t]\n );\n}\n"],"mappings":";;;AAkBA,SAAgB,IAIJ;CACV,IAAM,EAAE,SAAM,EAAQ;CACtB,OAAO,GACJ,GAAa,GAAkB,MAAqD;EACnF,IAAM,IAAa,EAAE,GAAK,CAAQ,GAC5B,IAAM,MAAe,IAAM,IAAW;EAE5C,OADK,IACE,OAAO,QAAQ,CAAM,EAAE,QAC3B,GAAK,CAAC,GAAG,OAAO,EAAI,QAAY,OAAO,SAAS,EAAE,SAAS,GAAG,GAAG,OAAO,CAAC,CAAC,GAC3E,CACF,IAJoB;CAKtB,GACA,CAAC,CAAC,CACJ;AACF"}
|