@burdenoff/microfe-govcitizenhub 2026.720.4 → 2026.720.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.
Files changed (30) hide show
  1. package/dist/govcitizenhub/components/DynamicFormFields.d.ts +17 -0
  2. package/dist/govcitizenhub/components/DynamicFormFields.d.ts.map +1 -0
  3. package/dist/govcitizenhub/components/DynamicFormFields.js +101 -0
  4. package/dist/govcitizenhub/components/DynamicFormFields.js.map +1 -0
  5. package/dist/govcitizenhub/hooks/useGovApi.d.ts +3 -4
  6. package/dist/govcitizenhub/hooks/useGovApi.d.ts.map +1 -1
  7. package/dist/govcitizenhub/hooks/useGovApi.js +10 -4
  8. package/dist/govcitizenhub/hooks/useGovApi.js.map +1 -1
  9. package/dist/govcitizenhub/pages/agencies/AgenciesPage.d.ts +3 -2
  10. package/dist/govcitizenhub/pages/agencies/AgenciesPage.d.ts.map +1 -1
  11. package/dist/govcitizenhub/pages/agencies/AgenciesPage.js.map +1 -1
  12. package/dist/govcitizenhub/pages/applications/ApplicationsPage.d.ts.map +1 -1
  13. package/dist/govcitizenhub/pages/applications/ApplicationsPage.js +170 -150
  14. package/dist/govcitizenhub/pages/applications/ApplicationsPage.js.map +1 -1
  15. package/dist/govcitizenhub/pages/applications/NewApplicationPage.d.ts +9 -5
  16. package/dist/govcitizenhub/pages/applications/NewApplicationPage.d.ts.map +1 -1
  17. package/dist/govcitizenhub/pages/applications/NewApplicationPage.js +148 -244
  18. package/dist/govcitizenhub/pages/applications/NewApplicationPage.js.map +1 -1
  19. package/dist/govcitizenhub/pages/services/FormFieldBuilder.d.ts +7 -28
  20. package/dist/govcitizenhub/pages/services/FormFieldBuilder.d.ts.map +1 -1
  21. package/dist/govcitizenhub/pages/services/FormFieldBuilder.js +203 -136
  22. package/dist/govcitizenhub/pages/services/FormFieldBuilder.js.map +1 -1
  23. package/dist/govcitizenhub/pages/services/ServiceFormDialog.d.ts.map +1 -1
  24. package/dist/govcitizenhub/pages/services/ServiceFormDialog.js +156 -114
  25. package/dist/govcitizenhub/pages/services/ServiceFormDialog.js.map +1 -1
  26. package/dist/govcitizenhub/utils/dynamicForm.d.ts +46 -0
  27. package/dist/govcitizenhub/utils/dynamicForm.d.ts.map +1 -0
  28. package/dist/govcitizenhub/utils/dynamicForm.js +59 -0
  29. package/dist/govcitizenhub/utils/dynamicForm.js.map +1 -0
  30. package/package.json +1 -1
@@ -0,0 +1,17 @@
1
+ import { DynamicFormField } from '../utils/dynamicForm';
2
+
3
+ export interface DynamicFormFieldsProps {
4
+ fields: DynamicFormField[];
5
+ values: Record<string, string>;
6
+ onChange: (key: string, value: string) => void;
7
+ /** For `file` fields: the human filename to display (the value itself holds the file id). */
8
+ fileNames?: Record<string, string>;
9
+ uploadingKey?: string | null;
10
+ onFileSelect?: (key: string, files: FileList | null) => void;
11
+ disabled?: boolean;
12
+ /** Preview mode (inside the builder): file uploads are shown but inert. */
13
+ previewMode?: boolean;
14
+ idPrefix?: string;
15
+ }
16
+ export declare function DynamicFormFields({ fields, values, onChange, fileNames, uploadingKey, onFileSelect, disabled, previewMode, idPrefix, }: DynamicFormFieldsProps): import("react/jsx-runtime").JSX.Element | null;
17
+ //# sourceMappingURL=DynamicFormFields.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DynamicFormFields.d.ts","sourceRoot":"","sources":["../../../src/govcitizenhub/components/DynamicFormFields.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAcH,OAAO,EAAkB,KAAK,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AAG7E,MAAM,WAAW,sBAAsB;IACrC,MAAM,EAAE,gBAAgB,EAAE,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,QAAQ,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAC/C,6FAA6F;IAC7F,SAAS,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACnC,YAAY,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,YAAY,CAAC,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,QAAQ,GAAG,IAAI,KAAK,IAAI,CAAC;IAC7D,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,2EAA2E;IAC3E,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,wBAAgB,iBAAiB,CAAC,EAChC,MAAM,EACN,MAAM,EACN,QAAQ,EACR,SAAc,EACd,YAAmB,EACnB,YAAY,EACZ,QAAgB,EAChB,WAAmB,EACnB,QAAc,GACf,EAAE,sBAAsB,kDAgExB"}
@@ -0,0 +1,101 @@
1
+ import { cn as e } from "../utils/cn.js";
2
+ import { isFieldVisible as t } from "../utils/dynamicForm.js";
3
+ import { CheckCircle2 as n, Loader2 as r, UploadCloud as i } from "lucide-react";
4
+ import { jsx as a, jsxs as o } from "react/jsx-runtime";
5
+ import { Input as s, Label as c, Select as l, SelectContent as u, SelectItem as d, SelectTrigger as f, SelectValue as p, Textarea as m } from "@burdenoff/fe-libs/ui";
6
+ //#region src/govcitizenhub/components/DynamicFormFields.tsx
7
+ function h({ fields: n, values: r, onChange: i, fileNames: h = {}, uploadingKey: _ = null, onFileSelect: v, disabled: y = !1, previewMode: b = !1, idPrefix: x = "f" }) {
8
+ let S = n.filter((e) => t(e, r, n));
9
+ return S.length === 0 ? null : /* @__PURE__ */ a("div", {
10
+ className: "grid gap-4 sm:grid-cols-2",
11
+ children: S.map((t) => {
12
+ let n = t.type === "textarea" || t.type === "file" ? "sm:col-span-2" : "", S = `${x}-${t.key}`;
13
+ return /* @__PURE__ */ o("div", {
14
+ className: e("grid gap-1.5", n),
15
+ children: [/* @__PURE__ */ o(c, {
16
+ htmlFor: S,
17
+ children: [t.label, t.required && /* @__PURE__ */ a("span", {
18
+ className: "text-status-error-text",
19
+ children: " *"
20
+ })]
21
+ }), t.type === "textarea" ? /* @__PURE__ */ a(m, {
22
+ id: S,
23
+ value: r[t.key] ?? "",
24
+ onChange: (e) => i(t.key, e.target.value),
25
+ disabled: y,
26
+ rows: 3
27
+ }) : t.type === "select" ? /* @__PURE__ */ o(l, {
28
+ value: r[t.key] ?? "",
29
+ onValueChange: (e) => i(t.key, e),
30
+ disabled: y,
31
+ children: [/* @__PURE__ */ a(f, {
32
+ id: S,
33
+ "aria-label": t.label,
34
+ children: /* @__PURE__ */ a(p, { placeholder: "Select…" })
35
+ }), /* @__PURE__ */ a(u, { children: (t.options ?? []).map((e) => /* @__PURE__ */ a(d, {
36
+ value: e,
37
+ children: e
38
+ }, e)) })]
39
+ }) : t.type === "file" ? /* @__PURE__ */ a(g, {
40
+ id: S,
41
+ label: t.label,
42
+ fileName: h[t.key],
43
+ uploading: _ === t.key,
44
+ disabled: y || b,
45
+ onSelect: (e) => v?.(t.key, e)
46
+ }) : /* @__PURE__ */ a(s, {
47
+ id: S,
48
+ type: t.type === "number" ? "number" : t.type === "date" ? "date" : "text",
49
+ value: r[t.key] ?? "",
50
+ onChange: (e) => i(t.key, e.target.value),
51
+ disabled: y
52
+ })]
53
+ }, t.key);
54
+ })
55
+ });
56
+ }
57
+ function g({ id: t, label: s, fileName: c, uploading: l, disabled: u, onSelect: d }) {
58
+ return /* @__PURE__ */ o("label", {
59
+ htmlFor: t,
60
+ className: e("flex items-center gap-3 rounded-xl border-2 border-dashed border-border-seam bg-bg-sunken/40 px-4 py-4 transition-colors", u ? "cursor-not-allowed opacity-70" : "cursor-pointer hover:border-border-strong", l && "cursor-wait opacity-70"),
61
+ children: [
62
+ /* @__PURE__ */ a("span", {
63
+ className: "inline-flex size-9 shrink-0 items-center justify-center rounded-full bg-[var(--color-accent-soft)] text-action-primary-text",
64
+ children: l ? /* @__PURE__ */ a(r, {
65
+ className: "size-5 animate-spin",
66
+ "aria-hidden": "true"
67
+ }) : c ? /* @__PURE__ */ a(n, {
68
+ className: "size-5 text-status-success-text",
69
+ "aria-hidden": "true"
70
+ }) : /* @__PURE__ */ a(i, {
71
+ className: "size-5",
72
+ "aria-hidden": "true"
73
+ })
74
+ }),
75
+ /* @__PURE__ */ o("span", {
76
+ className: "min-w-0 flex-1",
77
+ children: [/* @__PURE__ */ a("span", {
78
+ className: "block truncate text-sm font-medium text-text-primary",
79
+ children: l ? "Uploading…" : c || "Click to upload or drag & drop"
80
+ }), /* @__PURE__ */ a("span", {
81
+ className: "mt-0.5 block text-xs text-text-muted",
82
+ children: c ? "Uploaded · click to replace" : "PDF, JPG or PNG"
83
+ })]
84
+ }),
85
+ /* @__PURE__ */ a("input", {
86
+ id: t,
87
+ type: "file",
88
+ className: "sr-only",
89
+ "aria-label": `Upload ${s}`,
90
+ disabled: u || l,
91
+ onChange: (e) => {
92
+ d(e.target.files), e.target.value = "";
93
+ }
94
+ })
95
+ ]
96
+ });
97
+ }
98
+ //#endregion
99
+ export { h as DynamicFormFields };
100
+
101
+ //# sourceMappingURL=DynamicFormFields.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"DynamicFormFields.js","names":[],"sources":["../../../src/govcitizenhub/components/DynamicFormFields.tsx"],"sourcesContent":["/**\n * DynamicFormFields — renders a service's dynamic `formSchema` fields.\n * @module govcitizenhub/components\n *\n * The single renderer shared by the citizen-facing `NewApplicationPage` and the\n * no-code service builder's live preview (`ServiceFormDialog`) so a field an\n * agency author sees in preview is pixel-for-pixel what a citizen fills in —\n * including conditional (`showIf`) visibility (BOFF-4540).\n */\n\nimport {\n Input,\n Label,\n Textarea,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@burdenoff/fe-libs/ui';\nimport { CheckCircle2, Loader2, UploadCloud } from 'lucide-react';\n\nimport { isFieldVisible, type DynamicFormField } from '../utils/dynamicForm';\nimport { cn } from '../utils/cn';\n\nexport interface DynamicFormFieldsProps {\n fields: DynamicFormField[];\n values: Record<string, string>;\n onChange: (key: string, value: string) => void;\n /** For `file` fields: the human filename to display (the value itself holds the file id). */\n fileNames?: Record<string, string>;\n uploadingKey?: string | null;\n onFileSelect?: (key: string, files: FileList | null) => void;\n disabled?: boolean;\n /** Preview mode (inside the builder): file uploads are shown but inert. */\n previewMode?: boolean;\n idPrefix?: string;\n}\n\nexport function DynamicFormFields({\n fields,\n values,\n onChange,\n fileNames = {},\n uploadingKey = null,\n onFileSelect,\n disabled = false,\n previewMode = false,\n idPrefix = 'f',\n}: DynamicFormFieldsProps) {\n const visibleFields = fields.filter((f) => isFieldVisible(f, values, fields));\n\n if (visibleFields.length === 0) return null;\n\n return (\n <div className=\"grid gap-4 sm:grid-cols-2\">\n {visibleFields.map((field) => {\n const spanFull = field.type === 'textarea' || field.type === 'file' ? 'sm:col-span-2' : '';\n const fieldId = `${idPrefix}-${field.key}`;\n return (\n <div key={field.key} className={cn('grid gap-1.5', spanFull)}>\n <Label htmlFor={fieldId}>\n {field.label}\n {field.required && <span className=\"text-status-error-text\"> *</span>}\n </Label>\n {field.type === 'textarea' ? (\n <Textarea\n id={fieldId}\n value={values[field.key] ?? ''}\n onChange={(e) => onChange(field.key, e.target.value)}\n disabled={disabled}\n rows={3}\n />\n ) : field.type === 'select' ? (\n <Select\n value={values[field.key] ?? ''}\n onValueChange={(v) => onChange(field.key, v)}\n disabled={disabled}\n >\n <SelectTrigger id={fieldId} aria-label={field.label}>\n <SelectValue placeholder=\"Select…\" />\n </SelectTrigger>\n <SelectContent>\n {(field.options ?? []).map((opt) => (\n <SelectItem key={opt} value={opt}>\n {opt}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n ) : field.type === 'file' ? (\n <FileFieldControl\n id={fieldId}\n label={field.label}\n fileName={fileNames[field.key]}\n uploading={uploadingKey === field.key}\n disabled={disabled || previewMode}\n onSelect={(list) => onFileSelect?.(field.key, list)}\n />\n ) : (\n <Input\n id={fieldId}\n type={field.type === 'number' ? 'number' : field.type === 'date' ? 'date' : 'text'}\n value={values[field.key] ?? ''}\n onChange={(e) => onChange(field.key, e.target.value)}\n disabled={disabled}\n />\n )}\n </div>\n );\n })}\n </div>\n );\n}\n\n/** A click/drag upload control for a dynamic `file` form field. */\nfunction FileFieldControl({\n id,\n label,\n fileName,\n uploading,\n disabled,\n onSelect,\n}: {\n id: string;\n label: string;\n fileName?: string;\n uploading: boolean;\n disabled?: boolean;\n onSelect: (files: FileList | null) => void;\n}) {\n return (\n <label\n htmlFor={id}\n className={cn(\n 'flex items-center gap-3 rounded-xl border-2 border-dashed border-border-seam bg-bg-sunken/40 px-4 py-4 transition-colors',\n disabled ? 'cursor-not-allowed opacity-70' : 'cursor-pointer hover:border-border-strong',\n uploading && 'cursor-wait opacity-70'\n )}\n >\n <span className=\"inline-flex size-9 shrink-0 items-center justify-center rounded-full bg-[var(--color-accent-soft)] text-action-primary-text\">\n {uploading ? (\n <Loader2 className=\"size-5 animate-spin\" aria-hidden=\"true\" />\n ) : fileName ? (\n <CheckCircle2 className=\"size-5 text-status-success-text\" aria-hidden=\"true\" />\n ) : (\n <UploadCloud className=\"size-5\" aria-hidden=\"true\" />\n )}\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate text-sm font-medium text-text-primary\">\n {uploading ? 'Uploading…' : fileName ? fileName : 'Click to upload or drag & drop'}\n </span>\n <span className=\"mt-0.5 block text-xs text-text-muted\">\n {fileName ? 'Uploaded · click to replace' : 'PDF, JPG or PNG'}\n </span>\n </span>\n <input\n id={id}\n type=\"file\"\n className=\"sr-only\"\n aria-label={`Upload ${label}`}\n disabled={disabled || uploading}\n onChange={(e) => {\n onSelect(e.target.files);\n e.target.value = '';\n }}\n />\n </label>\n );\n}\n"],"mappings":";;;;;;AAuCA,SAAgB,EAAkB,EAChC,WACA,WACA,aACA,eAAY,CAAC,GACb,kBAAe,MACf,iBACA,cAAW,IACX,iBAAc,IACd,cAAW,OACc;CACzB,IAAM,IAAgB,EAAO,QAAQ,MAAM,EAAe,GAAG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KAC5B,WAAW,MAAM,EAAS,EAAM,KAAK,EAAE,OAAO,KAAK;KACzC;IACX,CAAA,CAEA;MAhDK,EAAM,GAgDX;EAET,CAAC;CACE,CAAA;AAET;AAGA,SAAS,EAAiB,EACxB,OACA,UACA,aACA,cACA,aACA,eAQC;CACD,OACE,kBAAC,SAAD;EACE,SAAS;EACT,WAAW,EACT,4HACA,IAAW,kCAAkC,6CAC7C,KAAa,wBACf;YANF;GAQE,kBAAC,QAAD;IAAM,WAAU;cACb,IACC,kBAAC,GAAD;KAAS,WAAU;KAAsB,eAAY;IAAQ,CAAA,IAC3D,IACF,kBAAC,GAAD;KAAc,WAAU;KAAkC,eAAY;IAAQ,CAAA,IAE9E,kBAAC,GAAD;KAAa,WAAU;KAAS,eAAY;IAAQ,CAAA;GAElD,CAAA;GACN,kBAAC,QAAD;IAAM,WAAU;cAAhB,CACE,kBAAC,QAAD;KAAM,WAAU;eACb,IAAY,eAAe,KAAsB;IAC9C,CAAA,GACN,kBAAC,QAAD;KAAM,WAAU;eACb,IAAW,gCAAgC;IACxC,CAAA,CACF;;GACN,kBAAC,SAAD;IACM;IACJ,MAAK;IACL,WAAU;IACV,cAAY,UAAU;IACtB,UAAU,KAAY;IACtB,WAAW,MAAM;KAEf,AADA,EAAS,EAAE,OAAO,KAAK,GACvB,EAAE,OAAO,QAAQ;IACnB;GACD,CAAA;EACI;;AAEX"}
@@ -88,10 +88,9 @@ export interface PermitFilters {
88
88
  pagination?: PaginationInput;
89
89
  }
90
90
  /**
91
- * `govListPermits` returns a bare ARRAY (not a connection), but now accepts an
92
- * optional offset `pagination` arg (default page size 50). Callers page with
93
- * `{ limit, offset }`; `hasMore` is inferred from a full-length page since the
94
- * svc does not return a total.
91
+ * `govListPermits` returns a paginated `GovPermitConnection`, flattened to a
92
+ * plain array here since PermitsPage reads `data` as GovPermit[] and infers
93
+ * `hasMore` itself from a full-length page. Callers page with `{ limit, offset }`.
95
94
  */
96
95
  export declare const useGovPermits: (filters?: PermitFilters) => import('@tanstack/react-query').UseQueryResult<GovPermit[], Error>;
97
96
  export declare const useGovIssuePermit: () => import('@tanstack/react-query').UseMutationResult<GovPermit, Error, GovIssuePermitInput, unknown>;
@@ -1 +1 @@
1
- {"version":3,"file":"useGovApi.d.ts","sourceRoot":"","sources":["../../../src/govcitizenhub/hooks/useGovApi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,EAC1B,uBAAuB,EACvB,eAAe,EAChB,MAAM,UAAU,CAAC;AAsIlB,eAAO,MAAM,sBAAsB,kFA8BlC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,uFAevC,CAAC;AAEF,qFAAqF;AACrF,eAAO,MAAM,2BAA2B,2FAevC,CAAC;AAEF,2FAA2F;AAC3F,eAAO,MAAM,wBAAwB,wFAepC,CAAC;AAMF,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,eAAe,CAAC;CAC9B;AAED,eAAO,MAAM,cAAc,GAAI,UAAS,aAAkB,uEAezD,CAAC;AAEF,eAAO,MAAM,YAAY,GAAI,IAAI,MAAM,GAAG,SAAS,4EAgBlD,CAAC;AAEF,eAAO,MAAM,kBAAkB,0GAgB9B,CAAC;AAEF,eAAO,M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eAAO,MAAM,eAAe,GAAI,IAAI,MAAM,GAAG,SAAS,+EAgBrD,CAAC;AAEF,eAAO,MAAM,qBAAqB,gHAgBjC,CAAC;AAEF,eAAO,MAAM,qBAAqB;QAIC,MAAM;WAAS,uBAAuB;WAexE,CAAC;AAEF,eAAO,MAAM,yBAAyB;QAK5B,MAAM;YACF,kBAAkB;iBACb,MAAM,GAAG,IAAI;WAgB/B,CAAC"}
1
+ {"version":3,"file":"useGovApi.d.ts","sourceRoot":"","sources":["../../../src/govcitizenhub/hooks/useGovApi.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAOH,OAAO,KAAK,EACV,aAAa,EACb,SAAS,EACT,UAAU,EACV,kBAAkB,EAClB,gBAAgB,EAChB,cAAc,EACd,oBAAoB,EACpB,WAAW,EACX,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,yBAAyB,EACzB,yBAAyB,EACzB,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,uBAAuB,EACvB,mBAAmB,EACnB,wBAAwB,EACxB,0BAA0B,EAC1B,uBAAuB,EACvB,eAAe,EAChB,MAAM,UAAU,CAAC;AAsIlB,eAAO,MAAM,sBAAsB,kFA8BlC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,2BAA2B,uFAevC,CAAC;AAEF,qFAAqF;AACrF,eAAO,MAAM,2BAA2B,2FAevC,CAAC;AAEF,2FAA2F;AAC3F,eAAO,MAAM,wBAAwB,wFAepC,CAAC;AAQF,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,UAAU,CAAC,EAAE,eAAe,CAAC;CAC9B;AAED,eAAO,MAAM,cAAc,GAAI,UAAS,aAAkB,uEAkBzD,C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E,kBAAkB,CAAC;IAC5B,UAAU,CAAC,EAAE,eAAe,CAAC;CAC9B;AAED,eAAO,MAAM,gBAAgB,GAAI,UAAS,gBAAqB,uFAuB9D,CAAC;AAEF,eAAO,MAAM,eAAe,GAAI,IAAI,MAAM,GAAG,SAAS,+EAgBrD,CAAC;AAEF,eAAO,MAAM,qBAAqB,gHAgBjC,CAAC;AAEF,eAAO,MAAM,qBAAqB;QAIC,MAAM;WAAS,uBAAuB;WAexE,CAAC;AAEF,eAAO,MAAM,yBAAyB;QAK5B,MAAM;YACF,kBAAkB;iBACb,MAAM,GAAG,IAAI;WAgB/B,CAAC"}
@@ -97,11 +97,14 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
97
97
  return r({
98
98
  queryKey: [...c.agencies, t],
99
99
  queryFn: async () => (await s(`query GovListAgencies($isActive: Boolean, $pagination: PaginationInput) {
100
- govListAgencies(isActive: $isActive, pagination: $pagination) { ${d} }
100
+ govListAgencies(isActive: $isActive, pagination: $pagination) {
101
+ items { ${d} }
102
+ pageInfo { cursor hasMore }
103
+ }
101
104
  }`, {
102
105
  isActive: t.isActive,
103
106
  pagination: u(t.pagination ?? { limit: 100 })
104
- }, n)).govListAgencies
107
+ }, n)).govListAgencies.items
105
108
  });
106
109
  }, w = (t) => {
107
110
  let { apiGatewayUrl: n } = e();
@@ -340,13 +343,16 @@ var o = (e) => /^\s*mutation\b/.test(e), s = async (e, n, r) => {
340
343
  return r({
341
344
  queryKey: [...c.permits, t],
342
345
  queryFn: async () => (await s(`query GovListPermits($holderId: ID, $serviceId: ID, $status: GovPermitStatus, $pagination: PaginationInput) {
343
- govListPermits(holderId: $holderId, serviceId: $serviceId, status: $status, pagination: $pagination) { ${h} }
346
+ govListPermits(holderId: $holderId, serviceId: $serviceId, status: $status, pagination: $pagination) {
347
+ items { ${h} }
348
+ pageInfo { cursor hasMore }
349
+ }
344
350
  }`, {
345
351
  holderId: t.holderId,
346
352
  serviceId: t.serviceId,
347
353
  status: t.status,
348
354
  pagination: u(t.pagination)
349
- }, n)).govListPermits
355
+ }, n)).govListPermits.items
350
356
  });
351
357
  }, K = () => {
352
358
  let { apiGatewayUrl: t } = e(), r = i();
@@ -1 +1 @@
1
- {"version":3,"file":"useGovApi.js","names":[],"sources":["../../../src/govcitizenhub/hooks/useGovApi.ts"],"sourcesContent":["/**\n * GovCitizenHub API hooks\n * @module govcitizenhub/hooks\n *\n * React-Query hooks wired DIRECTLY to the real `wspace-govcitizenhub-svc`\n * federated GraphQL contract (the `gov*` operations). Every query/mutation below\n * uses an inline gql string whose fields match the svc `.hive-schema.graphql`\n * exactly. No mock data.\n *\n * Transport: `graphqlFetch({ gateway: 'workspace', workspaceToken: true })` — the\n * host shell supplies the gateway base URL + a workspace-scoped token.\n *\n * IMPORTANT: `User`/`File` are id-only federation stubs in this subgraph. We\n * never select `citizen { firstName }` or `file { url }`.\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useGovCitizenHub } from '../context';\nimport { clearGraphqlResponseCache } from '../lib/graphql-cache';\nimport type {\n GovConnection,\n GovAgency,\n GovService,\n GovServiceCategory,\n GovServiceStatus,\n GovApplication,\n GovApplicationStatus,\n GovDocument,\n GovDocumentStatus,\n GovCaseNote,\n GovPermit,\n GovPermitStatus,\n GovPayment,\n GovPaymentStatus,\n GovGrievance,\n GovGrievanceStatus,\n GovCreateAgencyInput,\n GovUpdateAgencyInput,\n GovCreateServiceInput,\n GovUpdateServiceInput,\n GovCreateApplicationInput,\n GovUpdateApplicationInput,\n GovAddDocumentInput,\n GovAddCaseNoteInput,\n GovCreatePaymentInput,\n GovIssuePermitInput,\n GovReportGrievanceInput,\n GovUpdateGrievanceInput,\n GovDashboardSummary,\n GovApplicationSlaSummary,\n GovServiceApplicationCount,\n GovDeskApplicationCount,\n PaginationInput,\n} from '../types';\n\n// ============================================================================\n// Transport\n// ============================================================================\n\nconst isMutation = (query: string): boolean => /^\\s*mutation\\b/.test(query);\n\nconst govQuery = async <TData>(\n query: string,\n variables: Record<string, unknown>,\n baseUrl?: string\n): Promise<TData> => {\n // A mutation must never be served from — or coalesced onto — the read cache,\n // and the resolved read cache must be dropped once it commits so the\n // React-Query refetch that follows sees the new state, not a stale (≤15s)\n // pre-write response. Clear before AND after the write.\n const mutating = isMutation(query);\n if (mutating) clearGraphqlResponseCache();\n\n const response = await graphqlFetch<TData>({\n gateway: 'workspace',\n baseUrl,\n query,\n variables,\n workspaceToken: true,\n });\n\n if (mutating) clearGraphqlResponseCache();\n\n // GraphQL partial success: the gateway can attach a non-fatal top-level error\n // (e.g. a be-sdk activity/usage tracking side-effect) alongside a fully-resolved\n // payload. Only treat the request as failed when it produced NO usable data —\n // otherwise the operation genuinely succeeded and surfacing the background error\n // as a destructive toast would mislead the user.\n const data = response.data as Record<string, unknown> | null | undefined;\n const hasUsableData =\n data != null && Object.values(data).some((value) => value !== null && value !== undefined);\n\n if (!hasUsableData) {\n throw new Error(response.errors?.[0]?.message ?? 'GraphQL response did not include data');\n }\n if (response.errors?.length) {\n // Non-fatal: keep the data, but leave a breadcrumb for diagnostics.\n console.warn('[govcitizenhub] GraphQL partial error (data returned):', response.errors);\n }\n return response.data as TData;\n};\n\n// React-Query key roots (one namespace per domain entity).\nconst KEY = {\n dashboard: ['govcitizenhub', 'dashboard-summary'] as const,\n applicationSlaSummary: ['govcitizenhub', 'application-sla-summary'] as const,\n applicationsByService: ['govcitizenhub', 'applications-by-service'] as const,\n applicationsByDesk: ['govcitizenhub', 'applications-by-desk'] as const,\n agencies: ['govcitizenhub', 'agencies'] as const,\n agency: (id: string) => ['govcitizenhub', 'agency', id] as const,\n services: ['govcitizenhub', 'services'] as const,\n service: (id: string) => ['govcitizenhub', 'service', id] as const,\n applications: ['govcitizenhub', 'applications'] as const,\n application: (id: string) => ['govcitizenhub', 'application', id] as const,\n payments: ['govcitizenhub', 'payments'] as const,\n payment: (id: string) => ['govcitizenhub', 'payment', id] as const,\n permits: ['govcitizenhub', 'permits'] as const,\n grievances: ['govcitizenhub', 'grievances'] as const,\n grievance: (id: string) => ['govcitizenhub', 'grievance', id] as const,\n};\n\nconst DEFAULT_PAGE: PaginationInput = { limit: 50 };\n\n/** Build a clean PaginationInput, dropping nullish cursor so the svc never sees `cursor: null`. */\nconst page = (p?: PaginationInput): PaginationInput => {\n const base = p ?? DEFAULT_PAGE;\n const result: PaginationInput = { limit: base.limit ?? DEFAULT_PAGE.limit };\n if (base.offset != null) result.offset = base.offset;\n if (base.cursor != null) result.cursor = base.cursor;\n return result;\n};\n\n// ============================================================================\n// Reusable gql field selections (codegen-free strictness)\n// ============================================================================\n\nconst AGENCY_FIELDS = `\n id workspaceId code contactEmail contactPhone description isActive jurisdiction\n name tags createdAt updatedAt\n`;\n\nconst SERVICE_FIELDS = `\n id workspaceId agencyId category currency eligibility feeAmount feeType formSchema\n name publishedAt requiredDocuments slaDays slug status summary tags createdAt updatedAt\n`;\n\nconst DOCUMENT_FIELDS = `\n id workspaceId applicationId name status requirement rejectionReason\n file { id } createdAt updatedAt\n`;\n\nconst CASE_NOTE_FIELDS = `\n id workspaceId applicationId authorId body type createdAt updatedAt\n`;\n\nconst PERMIT_FIELDS = `\n id workspaceId applicationId serviceId holderId title verificationCode status\n issuedAt expiresAt revokedAt revokeReason file { id } createdAt updatedAt\n`;\n\nconst PAYMENT_FIELDS = `\n id workspaceId applicationId payerId amount currency status receiptNumber\n providerRef lineItems paidAt refundedAt createdAt updatedAt\n`;\n\nconst APPLICATION_FIELDS = `\n id workspaceId reference serviceId citizenId assignedToId status priority dueDate\n submittedAt decidedAt decisionReason tags createdAt updatedAt\n`;\n\nconst GRIEVANCE_FIELDS = `\n id workspaceId title description category status priority location latitude longitude\n photoFileIds reporterId agencyId assignedToId resolution resolvedAt tags createdAt updatedAt\n`;\n\n// ============================================================================\n// Dashboard summary (authoritative, backend-computed counts)\n// ============================================================================\n\n/**\n * Reads `govDashboardSummary` — the svc-computed operations totals. These are\n * authoritative (full-corpus counts, not a capped client-side window), so the\n * dashboard tiles and status donut MUST source from here, never from a paged\n * list's `items.length`.\n */\nconst DASHBOARD_TREND_FIELDS = `current previous changePercent direction`;\n\nexport const useGovDashboardSummary = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.dashboard,\n queryFn: async () => {\n const result = await govQuery<{ govDashboardSummary: GovDashboardSummary }>(\n `query GovDashboardSummary {\n govDashboardSummary {\n applicationsTotal\n applicationsByStatus { status count }\n pendingPayments\n pendingPaymentsAmount\n openGrievances\n activePermits\n publishedServices\n activeAgencies\n applicationsTotalTrend { ${DASHBOARD_TREND_FIELDS} }\n pendingPaymentsTrend { ${DASHBOARD_TREND_FIELDS} }\n openGrievancesTrend { ${DASHBOARD_TREND_FIELDS} }\n activePermitsTrend { ${DASHBOARD_TREND_FIELDS} }\n publishedServicesTrend { ${DASHBOARD_TREND_FIELDS} }\n activeAgenciesTrend { ${DASHBOARD_TREND_FIELDS} }\n }\n }`,\n {},\n apiGatewayUrl\n );\n return result.govDashboardSummary;\n },\n });\n};\n\n/**\n * Reads `govApplicationSlaSummary` — the svc-computed, corpus-wide SLA\n * breakdown across every non-terminal application. Unlike a page-level SLA\n * strip, this is accurate regardless of which page of results is loaded.\n */\nexport const useGovApplicationSlaSummary = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.applicationSlaSummary,\n queryFn: async () => {\n const result = await govQuery<{ govApplicationSlaSummary: GovApplicationSlaSummary }>(\n `query GovApplicationSlaSummary {\n govApplicationSlaSummary { onTrack dueSoon overdue noDueDate }\n }`,\n {},\n apiGatewayUrl\n );\n return result.govApplicationSlaSummary;\n },\n });\n};\n\n/** Reads `govApplicationsByService` — corpus-wide application volume per service. */\nexport const useGovApplicationsByService = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.applicationsByService,\n queryFn: async () => {\n const result = await govQuery<{ govApplicationsByService: GovServiceApplicationCount[] }>(\n `query GovApplicationsByService {\n govApplicationsByService { serviceId serviceName count }\n }`,\n {},\n apiGatewayUrl\n );\n return result.govApplicationsByService;\n },\n });\n};\n\n/** Reads `govApplicationsByDesk` — corpus-wide application volume per assigned officer. */\nexport const useGovApplicationsByDesk = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.applicationsByDesk,\n queryFn: async () => {\n const result = await govQuery<{ govApplicationsByDesk: GovDeskApplicationCount[] }>(\n `query GovApplicationsByDesk {\n govApplicationsByDesk { assignedToId count }\n }`,\n {},\n apiGatewayUrl\n );\n return result.govApplicationsByDesk;\n },\n });\n};\n\n// ============================================================================\n// Agencies (list = ARRAY, not a connection)\n// ============================================================================\n\nexport interface AgencyFilters {\n isActive?: boolean;\n pagination?: PaginationInput;\n}\n\nexport const useGovAgencies = (filters: AgencyFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.agencies, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListAgencies: GovAgency[] }>(\n `query GovListAgencies($isActive: Boolean, $pagination: PaginationInput) {\n govListAgencies(isActive: $isActive, pagination: $pagination) { ${AGENCY_FIELDS} }\n }`,\n { isActive: filters.isActive, pagination: page(filters.pagination ?? { limit: 100 }) },\n apiGatewayUrl\n );\n return result.govListAgencies;\n },\n });\n};\n\nexport const useGovAgency = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.agency(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govAgency: GovAgency | null }>(\n `query GovAgency($id: ID!) {\n govAgency(id: $id) { ${AGENCY_FIELDS} services { ${SERVICE_FIELDS} } }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govAgency;\n },\n });\n};\n\nexport const useGovCreateAgency = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateAgencyInput) => {\n const result = await govQuery<{ govCreateAgency: GovAgency }>(\n `mutation GovCreateAgency($input: GovCreateAgencyInput!) {\n govCreateAgency(input: $input) { ${AGENCY_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateAgency;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.agencies }),\n });\n};\n\nexport const useGovUpdateAgency = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateAgencyInput }) => {\n const result = await govQuery<{ govUpdateAgency: GovAgency }>(\n `mutation GovUpdateAgency($id: ID!, $input: GovUpdateAgencyInput!) {\n govUpdateAgency(id: $id, input: $input) { ${AGENCY_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateAgency;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.agencies });\n qc.invalidateQueries({ queryKey: KEY.agency(data.id) });\n },\n });\n};\n\nexport const useGovArchiveAgency = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govArchiveAgency: boolean }>(\n `mutation GovArchiveAgency($id: ID!) { govArchiveAgency(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govArchiveAgency;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.agencies }),\n });\n};\n\n// ============================================================================\n// Services (connection)\n// ============================================================================\n\nexport interface ServiceFilters {\n agencyId?: string;\n category?: GovServiceCategory;\n status?: GovServiceStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovServices = (filters: ServiceFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.services, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListServices: GovConnection<GovService> }>(\n `query GovListServices($agencyId: ID, $category: GovServiceCategory, $status: GovServiceStatus, $pagination: PaginationInput) {\n govListServices(agencyId: $agencyId, category: $category, status: $status, pagination: $pagination) {\n items { ${SERVICE_FIELDS} agency { id name } }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n agencyId: filters.agencyId,\n category: filters.category,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListServices;\n },\n });\n};\n\nexport const useGovService = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.service(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govService: GovService | null }>(\n `query GovService($id: ID!) {\n govService(id: $id) { ${SERVICE_FIELDS} agency { ${AGENCY_FIELDS} } }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govService;\n },\n });\n};\n\nexport const useGovCreateService = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateServiceInput) => {\n const result = await govQuery<{ govCreateService: GovService }>(\n `mutation GovCreateService($input: GovCreateServiceInput!) {\n govCreateService(input: $input) { ${SERVICE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateService;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.services }),\n });\n};\n\nexport const useGovUpdateService = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateServiceInput }) => {\n const result = await govQuery<{ govUpdateService: GovService }>(\n `mutation GovUpdateService($id: ID!, $input: GovUpdateServiceInput!) {\n govUpdateService(id: $id, input: $input) { ${SERVICE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateService;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.services });\n qc.invalidateQueries({ queryKey: KEY.service(data.id) });\n },\n });\n};\n\nexport const useGovTransitionService = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; status: GovServiceStatus }) => {\n const result = await govQuery<{ govTransitionService: GovService }>(\n `mutation GovTransitionService($id: ID!, $status: GovServiceStatus!) {\n govTransitionService(id: $id, status: $status) { ${SERVICE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govTransitionService;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.services });\n qc.invalidateQueries({ queryKey: KEY.service(data.id) });\n },\n });\n};\n\n// ============================================================================\n// Applications (connection)\n// ============================================================================\n\nexport interface ApplicationFilters {\n assignedToId?: string;\n citizenId?: string;\n serviceId?: string;\n status?: GovApplicationStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovApplications = (filters: ApplicationFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.applications, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListApplications: GovConnection<GovApplication> }>(\n `query GovListApplications($assignedToId: ID, $citizenId: ID, $serviceId: ID, $status: GovApplicationStatus, $pagination: PaginationInput) {\n govListApplications(assignedToId: $assignedToId, citizenId: $citizenId, serviceId: $serviceId, status: $status, pagination: $pagination) {\n items { ${APPLICATION_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n assignedToId: filters.assignedToId,\n citizenId: filters.citizenId,\n serviceId: filters.serviceId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListApplications;\n },\n });\n};\n\nexport const useGovApplication = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.application(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govApplication: GovApplication | null }>(\n `query GovApplication($id: ID!) {\n govApplication(id: $id) {\n ${APPLICATION_FIELDS}\n formData\n documents { ${DOCUMENT_FIELDS} }\n notes { ${CASE_NOTE_FIELDS} }\n permits { ${PERMIT_FIELDS} }\n }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govApplication;\n },\n });\n};\n\nexport const useGovCreateApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateApplicationInput) => {\n const result = await govQuery<{ govCreateApplication: GovApplication }>(\n `mutation GovCreateApplication($input: GovCreateApplicationInput!) {\n govCreateApplication(input: $input) { ${APPLICATION_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateApplication;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.applications }),\n });\n};\n\nexport const useGovUpdateApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateApplicationInput }) => {\n const result = await govQuery<{ govUpdateApplication: GovApplication }>(\n `mutation GovUpdateApplication($id: ID!, $input: GovUpdateApplicationInput!) {\n govUpdateApplication(id: $id, input: $input) { ${APPLICATION_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateApplication;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.application(data.id) });\n },\n });\n};\n\nexport const useGovSubmitApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govSubmitApplication: GovApplication }>(\n `mutation GovSubmitApplication($id: ID!) {\n govSubmitApplication(id: $id) { ${APPLICATION_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govSubmitApplication;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.application(data.id) });\n },\n });\n};\n\nexport const useGovTransitionApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n status: GovApplicationStatus;\n reason?: string | null;\n }) => {\n const result = await govQuery<{ govTransitionApplication: GovApplication }>(\n `mutation GovTransitionApplication($id: ID!, $status: GovApplicationStatus!, $reason: String) {\n govTransitionApplication(id: $id, status: $status, reason: $reason) { ${APPLICATION_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govTransitionApplication;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.application(data.id) });\n },\n });\n};\n\n// ============================================================================\n// Documents (attached to an application)\n// ============================================================================\n\nexport const useGovAddDocument = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovAddDocumentInput) => {\n const result = await govQuery<{ govAddDocument: GovDocument }>(\n `mutation GovAddDocument($input: GovAddDocumentInput!) {\n govAddDocument(input: $input) { ${DOCUMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govAddDocument;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n qc.invalidateQueries({ queryKey: KEY.applications });\n },\n });\n};\n\nexport const useGovReviewDocument = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n status: GovDocumentStatus;\n rejectionReason?: string | null;\n applicationId?: string;\n }) => {\n const result = await govQuery<{ govReviewDocument: GovDocument }>(\n `mutation GovReviewDocument($id: ID!, $status: GovDocumentStatus!, $rejectionReason: String) {\n govReviewDocument(id: $id, status: $status, rejectionReason: $rejectionReason) { ${DOCUMENT_FIELDS} }\n }`,\n { id: vars.id, status: vars.status, rejectionReason: vars.rejectionReason },\n apiGatewayUrl\n );\n return result.govReviewDocument;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\n// ============================================================================\n// Case notes (domain-owned casework timeline)\n// ============================================================================\n\nexport const useGovAddCaseNote = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovAddCaseNoteInput) => {\n const result = await govQuery<{ govAddCaseNote: GovCaseNote }>(\n `mutation GovAddCaseNote($input: GovAddCaseNoteInput!) {\n govAddCaseNote(input: $input) { ${CASE_NOTE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govAddCaseNote;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\n// ============================================================================\n// Payments (connection)\n// ============================================================================\n\nexport interface PaymentFilters {\n applicationId?: string;\n payerId?: string;\n status?: GovPaymentStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovPayments = (filters: PaymentFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.payments, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListPayments: GovConnection<GovPayment> }>(\n `query GovListPayments($applicationId: ID, $payerId: ID, $status: GovPaymentStatus, $pagination: PaginationInput) {\n govListPayments(applicationId: $applicationId, payerId: $payerId, status: $status, pagination: $pagination) {\n items { ${PAYMENT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n applicationId: filters.applicationId,\n payerId: filters.payerId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListPayments;\n },\n });\n};\n\nexport const useGovCreatePayment = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreatePaymentInput) => {\n const result = await govQuery<{ govCreatePayment: GovPayment }>(\n `mutation GovCreatePayment($input: GovCreatePaymentInput!) {\n govCreatePayment(input: $input) { ${PAYMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreatePayment;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.payments });\n if (data.applicationId)\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\nexport const useGovMarkPaymentPaid = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; providerRef?: string | null }) => {\n const result = await govQuery<{ govMarkPaymentPaid: GovPayment }>(\n `mutation GovMarkPaymentPaid($id: ID!, $providerRef: String) {\n govMarkPaymentPaid(id: $id, providerRef: $providerRef) { ${PAYMENT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govMarkPaymentPaid;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.payments }),\n });\n};\n\nexport const useGovRefundPayment = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govRefundPayment: GovPayment }>(\n `mutation GovRefundPayment($id: ID!) {\n govRefundPayment(id: $id) { ${PAYMENT_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govRefundPayment;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.payments }),\n });\n};\n\n// ============================================================================\n// Permits (list = ARRAY, no pagination) + public verification\n// ============================================================================\n\nexport interface PermitFilters {\n holderId?: string;\n serviceId?: string;\n status?: GovPermitStatus;\n pagination?: PaginationInput;\n}\n\n/**\n * `govListPermits` returns a bare ARRAY (not a connection), but now accepts an\n * optional offset `pagination` arg (default page size 50). Callers page with\n * `{ limit, offset }`; `hasMore` is inferred from a full-length page since the\n * svc does not return a total.\n */\nexport const useGovPermits = (filters: PermitFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.permits, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListPermits: GovPermit[] }>(\n `query GovListPermits($holderId: ID, $serviceId: ID, $status: GovPermitStatus, $pagination: PaginationInput) {\n govListPermits(holderId: $holderId, serviceId: $serviceId, status: $status, pagination: $pagination) { ${PERMIT_FIELDS} }\n }`,\n {\n holderId: filters.holderId,\n serviceId: filters.serviceId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListPermits;\n },\n });\n};\n\nexport const useGovIssuePermit = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovIssuePermitInput) => {\n const result = await govQuery<{ govIssuePermit: GovPermit }>(\n `mutation GovIssuePermit($input: GovIssuePermitInput!) {\n govIssuePermit(input: $input) { ${PERMIT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govIssuePermit;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.permits });\n if (data.applicationId)\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\nexport const useGovRevokePermit = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; reason?: string | null }) => {\n const result = await govQuery<{ govRevokePermit: GovPermit }>(\n `mutation GovRevokePermit($id: ID!, $reason: String) {\n govRevokePermit(id: $id, reason: $reason) { ${PERMIT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govRevokePermit;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.permits }),\n });\n};\n\n/**\n * Public permit verification by printed code. `govVerifyPermit` is a PUBLIC field\n * (no auth), but we keep the workspace-token transport for a consistent gateway\n * path. `enabled` is false until a code is supplied so the query is manual.\n */\nexport const useGovVerifyPermit = (verificationCode: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: ['govcitizenhub', 'verify-permit', verificationCode ?? ''],\n enabled: Boolean(verificationCode),\n retry: false,\n queryFn: async () => {\n const result = await govQuery<{ govVerifyPermit: GovPermit | null }>(\n `query GovVerifyPermit($verificationCode: String!) {\n govVerifyPermit(verificationCode: $verificationCode) { ${PERMIT_FIELDS} }\n }`,\n { verificationCode },\n apiGatewayUrl\n );\n return result.govVerifyPermit;\n },\n });\n};\n\n// ============================================================================\n// Grievances (connection)\n// ============================================================================\n\nexport interface GrievanceFilters {\n agencyId?: string;\n reporterId?: string;\n status?: GovGrievanceStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovGrievances = (filters: GrievanceFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.grievances, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListGrievances: GovConnection<GovGrievance> }>(\n `query GovListGrievances($agencyId: ID, $reporterId: ID, $status: GovGrievanceStatus, $pagination: PaginationInput) {\n govListGrievances(agencyId: $agencyId, reporterId: $reporterId, status: $status, pagination: $pagination) {\n items { ${GRIEVANCE_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n agencyId: filters.agencyId,\n reporterId: filters.reporterId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListGrievances;\n },\n });\n};\n\nexport const useGovGrievance = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.grievance(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govGrievance: GovGrievance | null }>(\n `query GovGrievance($id: ID!) {\n govGrievance(id: $id) { ${GRIEVANCE_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govGrievance;\n },\n });\n};\n\nexport const useGovReportGrievance = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovReportGrievanceInput) => {\n const result = await govQuery<{ govReportGrievance: GovGrievance }>(\n `mutation GovReportGrievance($input: GovReportGrievanceInput!) {\n govReportGrievance(input: $input) { ${GRIEVANCE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govReportGrievance;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.grievances }),\n });\n};\n\nexport const useGovUpdateGrievance = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateGrievanceInput }) => {\n const result = await govQuery<{ govUpdateGrievance: GovGrievance }>(\n `mutation GovUpdateGrievance($id: ID!, $input: GovUpdateGrievanceInput!) {\n govUpdateGrievance(id: $id, input: $input) { ${GRIEVANCE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateGrievance;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.grievances });\n qc.invalidateQueries({ queryKey: KEY.grievance(data.id) });\n },\n });\n};\n\nexport const useGovTransitionGrievance = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n status: GovGrievanceStatus;\n resolution?: string | null;\n }) => {\n const result = await govQuery<{ govTransitionGrievance: GovGrievance }>(\n `mutation GovTransitionGrievance($id: ID!, $status: GovGrievanceStatus!, $resolution: String) {\n govTransitionGrievance(id: $id, status: $status, resolution: $resolution) { ${GRIEVANCE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govTransitionGrievance;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.grievances });\n qc.invalidateQueries({ queryKey: KEY.grievance(data.id) });\n },\n });\n};\n"],"mappings":";;;;;;AA6DA,IAAM,KAAc,MAA2B,iBAAiB,KAAK,CAAK,GAEpE,IAAW,OACf,GACA,GACA,MACmB;CAKnB,IAAM,IAAW,EAAW,CAAK;CACjC,AAAI,KAAU,EAA0B;CAExC,IAAM,IAAW,MAAM,EAAoB;EACzC,SAAS;EACT;EACA;EACA;EACA,gBAAgB;CAClB,CAAC;CAED,AAAI,KAAU,EAA0B;CAOxC,IAAM,IAAO,EAAS;CAItB,IAAI,EAFF,KAAQ,QAAQ,OAAO,OAAO,CAAI,EAAE,MAAM,MAAU,KAAU,IAA2B,IAGzF,MAAU,MAAM,EAAS,S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AE;EAChC,SAAS,EAAQ;EACjB,SAAS,aAQA,MAPc,EACnB;oCAC4B,EAAiB;YAE7C,EAAE,MAAG,GACL,CACF,GACc;CAElB,CAAC;AACH,GAEa,UAA8B;CACzC,IAAM,EAAE,qBAAkB,EAAiB,GACrC,IAAK,EAAe;CAC1B,OAAO,EAAY;EACjB,YAAY,OAAO,OAQV,MAPc,EACnB;gDACwC,EAAiB;YAEzD,EAAE,SAAM,GACR,CACF,GACc;EAEhB,iBAAiB,EAAG,kBAAkB,EAAE,UAAU,EAAI,WAAW,CAAC;CACpE,CAAC;AACH,GAEa,UAA8B;CACzC,IAAM,EAAE,qBAAkB,EAAiB,GACrC,IAAK,EAAe;CAC1B,OAAO,EAAY;EACjB,YAAY,OAAO,OAQV,MAPc,EACnB;yDACiD,EAAiB;YAElE,GACA,CACF,GACc;EAEhB,YAAY,MAAS;GAEnB,AADA,EAAG,kBAAkB,EAAE,UAAU,EAAI,WAAW,CAAC,GACjD,EAAG,kBAAkB,EAAE,UAAU,EAAI,UAAU,EAAK,EAAE,EAAE,CAAC;EAC3D;CACF,CAAC;AACH,GAEa,UAAkC;CAC7C,IAAM,EAAE,qBAAkB,EAAiB,GACrC,IAAK,EAAe;CAC1B,OAAO,EAAY;EACjB,YAAY,OAAO,OAYV,MAPc,EACnB;wFACgF,EAAiB;YAEjG,GACA,CACF,GACc;EAEhB,YAAY,MAAS;GAEnB,AADA,EAAG,kBAAkB,EAAE,UAAU,EAAI,WAAW,CAAC,GACjD,EAAG,kBAAkB,EAAE,UAAU,EAAI,UAAU,EAAK,EAAE,EAAE,CAAC;EAC3D;CACF,CAAC;AACH"}
1
+ {"version":3,"file":"useGovApi.js","names":[],"sources":["../../../src/govcitizenhub/hooks/useGovApi.ts"],"sourcesContent":["/**\n * GovCitizenHub API hooks\n * @module govcitizenhub/hooks\n *\n * React-Query hooks wired DIRECTLY to the real `wspace-govcitizenhub-svc`\n * federated GraphQL contract (the `gov*` operations). Every query/mutation below\n * uses an inline gql string whose fields match the svc `.hive-schema.graphql`\n * exactly. No mock data.\n *\n * Transport: `graphqlFetch({ gateway: 'workspace', workspaceToken: true })` — the\n * host shell supplies the gateway base URL + a workspace-scoped token.\n *\n * IMPORTANT: `User`/`File` are id-only federation stubs in this subgraph. We\n * never select `citizen { firstName }` or `file { url }`.\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useGovCitizenHub } from '../context';\nimport { clearGraphqlResponseCache } from '../lib/graphql-cache';\nimport type {\n GovConnection,\n GovAgency,\n GovService,\n GovServiceCategory,\n GovServiceStatus,\n GovApplication,\n GovApplicationStatus,\n GovDocument,\n GovDocumentStatus,\n GovCaseNote,\n GovPermit,\n GovPermitStatus,\n GovPayment,\n GovPaymentStatus,\n GovGrievance,\n GovGrievanceStatus,\n GovCreateAgencyInput,\n GovUpdateAgencyInput,\n GovCreateServiceInput,\n GovUpdateServiceInput,\n GovCreateApplicationInput,\n GovUpdateApplicationInput,\n GovAddDocumentInput,\n GovAddCaseNoteInput,\n GovCreatePaymentInput,\n GovIssuePermitInput,\n GovReportGrievanceInput,\n GovUpdateGrievanceInput,\n GovDashboardSummary,\n GovApplicationSlaSummary,\n GovServiceApplicationCount,\n GovDeskApplicationCount,\n PaginationInput,\n} from '../types';\n\n// ============================================================================\n// Transport\n// ============================================================================\n\nconst isMutation = (query: string): boolean => /^\\s*mutation\\b/.test(query);\n\nconst govQuery = async <TData>(\n query: string,\n variables: Record<string, unknown>,\n baseUrl?: string\n): Promise<TData> => {\n // A mutation must never be served from — or coalesced onto — the read cache,\n // and the resolved read cache must be dropped once it commits so the\n // React-Query refetch that follows sees the new state, not a stale (≤15s)\n // pre-write response. Clear before AND after the write.\n const mutating = isMutation(query);\n if (mutating) clearGraphqlResponseCache();\n\n const response = await graphqlFetch<TData>({\n gateway: 'workspace',\n baseUrl,\n query,\n variables,\n workspaceToken: true,\n });\n\n if (mutating) clearGraphqlResponseCache();\n\n // GraphQL partial success: the gateway can attach a non-fatal top-level error\n // (e.g. a be-sdk activity/usage tracking side-effect) alongside a fully-resolved\n // payload. Only treat the request as failed when it produced NO usable data —\n // otherwise the operation genuinely succeeded and surfacing the background error\n // as a destructive toast would mislead the user.\n const data = response.data as Record<string, unknown> | null | undefined;\n const hasUsableData =\n data != null && Object.values(data).some((value) => value !== null && value !== undefined);\n\n if (!hasUsableData) {\n throw new Error(response.errors?.[0]?.message ?? 'GraphQL response did not include data');\n }\n if (response.errors?.length) {\n // Non-fatal: keep the data, but leave a breadcrumb for diagnostics.\n console.warn('[govcitizenhub] GraphQL partial error (data returned):', response.errors);\n }\n return response.data as TData;\n};\n\n// React-Query key roots (one namespace per domain entity).\nconst KEY = {\n dashboard: ['govcitizenhub', 'dashboard-summary'] as const,\n applicationSlaSummary: ['govcitizenhub', 'application-sla-summary'] as const,\n applicationsByService: ['govcitizenhub', 'applications-by-service'] as const,\n applicationsByDesk: ['govcitizenhub', 'applications-by-desk'] as const,\n agencies: ['govcitizenhub', 'agencies'] as const,\n agency: (id: string) => ['govcitizenhub', 'agency', id] as const,\n services: ['govcitizenhub', 'services'] as const,\n service: (id: string) => ['govcitizenhub', 'service', id] as const,\n applications: ['govcitizenhub', 'applications'] as const,\n application: (id: string) => ['govcitizenhub', 'application', id] as const,\n payments: ['govcitizenhub', 'payments'] as const,\n payment: (id: string) => ['govcitizenhub', 'payment', id] as const,\n permits: ['govcitizenhub', 'permits'] as const,\n grievances: ['govcitizenhub', 'grievances'] as const,\n grievance: (id: string) => ['govcitizenhub', 'grievance', id] as const,\n};\n\nconst DEFAULT_PAGE: PaginationInput = { limit: 50 };\n\n/** Build a clean PaginationInput, dropping nullish cursor so the svc never sees `cursor: null`. */\nconst page = (p?: PaginationInput): PaginationInput => {\n const base = p ?? DEFAULT_PAGE;\n const result: PaginationInput = { limit: base.limit ?? DEFAULT_PAGE.limit };\n if (base.offset != null) result.offset = base.offset;\n if (base.cursor != null) result.cursor = base.cursor;\n return result;\n};\n\n// ============================================================================\n// Reusable gql field selections (codegen-free strictness)\n// ============================================================================\n\nconst AGENCY_FIELDS = `\n id workspaceId code contactEmail contactPhone description isActive jurisdiction\n name tags createdAt updatedAt\n`;\n\nconst SERVICE_FIELDS = `\n id workspaceId agencyId category currency eligibility feeAmount feeType formSchema\n name publishedAt requiredDocuments slaDays slug status summary tags createdAt updatedAt\n`;\n\nconst DOCUMENT_FIELDS = `\n id workspaceId applicationId name status requirement rejectionReason\n file { id } createdAt updatedAt\n`;\n\nconst CASE_NOTE_FIELDS = `\n id workspaceId applicationId authorId body type createdAt updatedAt\n`;\n\nconst PERMIT_FIELDS = `\n id workspaceId applicationId serviceId holderId title verificationCode status\n issuedAt expiresAt revokedAt revokeReason file { id } createdAt updatedAt\n`;\n\nconst PAYMENT_FIELDS = `\n id workspaceId applicationId payerId amount currency status receiptNumber\n providerRef lineItems paidAt refundedAt createdAt updatedAt\n`;\n\nconst APPLICATION_FIELDS = `\n id workspaceId reference serviceId citizenId assignedToId status priority dueDate\n submittedAt decidedAt decisionReason tags createdAt updatedAt\n`;\n\nconst GRIEVANCE_FIELDS = `\n id workspaceId title description category status priority location latitude longitude\n photoFileIds reporterId agencyId assignedToId resolution resolvedAt tags createdAt updatedAt\n`;\n\n// ============================================================================\n// Dashboard summary (authoritative, backend-computed counts)\n// ============================================================================\n\n/**\n * Reads `govDashboardSummary` — the svc-computed operations totals. These are\n * authoritative (full-corpus counts, not a capped client-side window), so the\n * dashboard tiles and status donut MUST source from here, never from a paged\n * list's `items.length`.\n */\nconst DASHBOARD_TREND_FIELDS = `current previous changePercent direction`;\n\nexport const useGovDashboardSummary = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.dashboard,\n queryFn: async () => {\n const result = await govQuery<{ govDashboardSummary: GovDashboardSummary }>(\n `query GovDashboardSummary {\n govDashboardSummary {\n applicationsTotal\n applicationsByStatus { status count }\n pendingPayments\n pendingPaymentsAmount\n openGrievances\n activePermits\n publishedServices\n activeAgencies\n applicationsTotalTrend { ${DASHBOARD_TREND_FIELDS} }\n pendingPaymentsTrend { ${DASHBOARD_TREND_FIELDS} }\n openGrievancesTrend { ${DASHBOARD_TREND_FIELDS} }\n activePermitsTrend { ${DASHBOARD_TREND_FIELDS} }\n publishedServicesTrend { ${DASHBOARD_TREND_FIELDS} }\n activeAgenciesTrend { ${DASHBOARD_TREND_FIELDS} }\n }\n }`,\n {},\n apiGatewayUrl\n );\n return result.govDashboardSummary;\n },\n });\n};\n\n/**\n * Reads `govApplicationSlaSummary` — the svc-computed, corpus-wide SLA\n * breakdown across every non-terminal application. Unlike a page-level SLA\n * strip, this is accurate regardless of which page of results is loaded.\n */\nexport const useGovApplicationSlaSummary = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.applicationSlaSummary,\n queryFn: async () => {\n const result = await govQuery<{ govApplicationSlaSummary: GovApplicationSlaSummary }>(\n `query GovApplicationSlaSummary {\n govApplicationSlaSummary { onTrack dueSoon overdue noDueDate }\n }`,\n {},\n apiGatewayUrl\n );\n return result.govApplicationSlaSummary;\n },\n });\n};\n\n/** Reads `govApplicationsByService` — corpus-wide application volume per service. */\nexport const useGovApplicationsByService = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.applicationsByService,\n queryFn: async () => {\n const result = await govQuery<{ govApplicationsByService: GovServiceApplicationCount[] }>(\n `query GovApplicationsByService {\n govApplicationsByService { serviceId serviceName count }\n }`,\n {},\n apiGatewayUrl\n );\n return result.govApplicationsByService;\n },\n });\n};\n\n/** Reads `govApplicationsByDesk` — corpus-wide application volume per assigned officer. */\nexport const useGovApplicationsByDesk = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.applicationsByDesk,\n queryFn: async () => {\n const result = await govQuery<{ govApplicationsByDesk: GovDeskApplicationCount[] }>(\n `query GovApplicationsByDesk {\n govApplicationsByDesk { assignedToId count }\n }`,\n {},\n apiGatewayUrl\n );\n return result.govApplicationsByDesk;\n },\n });\n};\n\n// ============================================================================\n// Agencies (server-side: paginated GovAgencyConnection; this hook flattens it\n// back to a plain array since every current consumer — AgenciesPage,\n// ServiceFormDialog, GrievancesPage — reads `data` as GovAgency[])\n// ============================================================================\n\nexport interface AgencyFilters {\n isActive?: boolean;\n pagination?: PaginationInput;\n}\n\nexport const useGovAgencies = (filters: AgencyFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.agencies, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListAgencies: GovConnection<GovAgency> }>(\n `query GovListAgencies($isActive: Boolean, $pagination: PaginationInput) {\n govListAgencies(isActive: $isActive, pagination: $pagination) {\n items { ${AGENCY_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { isActive: filters.isActive, pagination: page(filters.pagination ?? { limit: 100 }) },\n apiGatewayUrl\n );\n return result.govListAgencies.items;\n },\n });\n};\n\nexport const useGovAgency = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.agency(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govAgency: GovAgency | null }>(\n `query GovAgency($id: ID!) {\n govAgency(id: $id) { ${AGENCY_FIELDS} services { ${SERVICE_FIELDS} } }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govAgency;\n },\n });\n};\n\nexport const useGovCreateAgency = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateAgencyInput) => {\n const result = await govQuery<{ govCreateAgency: GovAgency }>(\n `mutation GovCreateAgency($input: GovCreateAgencyInput!) {\n govCreateAgency(input: $input) { ${AGENCY_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateAgency;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.agencies }),\n });\n};\n\nexport const useGovUpdateAgency = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateAgencyInput }) => {\n const result = await govQuery<{ govUpdateAgency: GovAgency }>(\n `mutation GovUpdateAgency($id: ID!, $input: GovUpdateAgencyInput!) {\n govUpdateAgency(id: $id, input: $input) { ${AGENCY_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateAgency;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.agencies });\n qc.invalidateQueries({ queryKey: KEY.agency(data.id) });\n },\n });\n};\n\nexport const useGovArchiveAgency = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govArchiveAgency: boolean }>(\n `mutation GovArchiveAgency($id: ID!) { govArchiveAgency(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govArchiveAgency;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.agencies }),\n });\n};\n\n// ============================================================================\n// Services (connection)\n// ============================================================================\n\nexport interface ServiceFilters {\n agencyId?: string;\n category?: GovServiceCategory;\n status?: GovServiceStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovServices = (filters: ServiceFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.services, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListServices: GovConnection<GovService> }>(\n `query GovListServices($agencyId: ID, $category: GovServiceCategory, $status: GovServiceStatus, $pagination: PaginationInput) {\n govListServices(agencyId: $agencyId, category: $category, status: $status, pagination: $pagination) {\n items { ${SERVICE_FIELDS} agency { id name } }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n agencyId: filters.agencyId,\n category: filters.category,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListServices;\n },\n });\n};\n\nexport const useGovService = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.service(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govService: GovService | null }>(\n `query GovService($id: ID!) {\n govService(id: $id) { ${SERVICE_FIELDS} agency { ${AGENCY_FIELDS} } }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govService;\n },\n });\n};\n\nexport const useGovCreateService = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateServiceInput) => {\n const result = await govQuery<{ govCreateService: GovService }>(\n `mutation GovCreateService($input: GovCreateServiceInput!) {\n govCreateService(input: $input) { ${SERVICE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateService;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.services }),\n });\n};\n\nexport const useGovUpdateService = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateServiceInput }) => {\n const result = await govQuery<{ govUpdateService: GovService }>(\n `mutation GovUpdateService($id: ID!, $input: GovUpdateServiceInput!) {\n govUpdateService(id: $id, input: $input) { ${SERVICE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateService;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.services });\n qc.invalidateQueries({ queryKey: KEY.service(data.id) });\n },\n });\n};\n\nexport const useGovTransitionService = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; status: GovServiceStatus }) => {\n const result = await govQuery<{ govTransitionService: GovService }>(\n `mutation GovTransitionService($id: ID!, $status: GovServiceStatus!) {\n govTransitionService(id: $id, status: $status) { ${SERVICE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govTransitionService;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.services });\n qc.invalidateQueries({ queryKey: KEY.service(data.id) });\n },\n });\n};\n\n// ============================================================================\n// Applications (connection)\n// ============================================================================\n\nexport interface ApplicationFilters {\n assignedToId?: string;\n citizenId?: string;\n serviceId?: string;\n status?: GovApplicationStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovApplications = (filters: ApplicationFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.applications, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListApplications: GovConnection<GovApplication> }>(\n `query GovListApplications($assignedToId: ID, $citizenId: ID, $serviceId: ID, $status: GovApplicationStatus, $pagination: PaginationInput) {\n govListApplications(assignedToId: $assignedToId, citizenId: $citizenId, serviceId: $serviceId, status: $status, pagination: $pagination) {\n items { ${APPLICATION_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n assignedToId: filters.assignedToId,\n citizenId: filters.citizenId,\n serviceId: filters.serviceId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListApplications;\n },\n });\n};\n\nexport const useGovApplication = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.application(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govApplication: GovApplication | null }>(\n `query GovApplication($id: ID!) {\n govApplication(id: $id) {\n ${APPLICATION_FIELDS}\n formData\n documents { ${DOCUMENT_FIELDS} }\n notes { ${CASE_NOTE_FIELDS} }\n permits { ${PERMIT_FIELDS} }\n }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govApplication;\n },\n });\n};\n\nexport const useGovCreateApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateApplicationInput) => {\n const result = await govQuery<{ govCreateApplication: GovApplication }>(\n `mutation GovCreateApplication($input: GovCreateApplicationInput!) {\n govCreateApplication(input: $input) { ${APPLICATION_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateApplication;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.applications }),\n });\n};\n\nexport const useGovUpdateApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateApplicationInput }) => {\n const result = await govQuery<{ govUpdateApplication: GovApplication }>(\n `mutation GovUpdateApplication($id: ID!, $input: GovUpdateApplicationInput!) {\n govUpdateApplication(id: $id, input: $input) { ${APPLICATION_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateApplication;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.application(data.id) });\n },\n });\n};\n\nexport const useGovSubmitApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govSubmitApplication: GovApplication }>(\n `mutation GovSubmitApplication($id: ID!) {\n govSubmitApplication(id: $id) { ${APPLICATION_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govSubmitApplication;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.application(data.id) });\n },\n });\n};\n\nexport const useGovTransitionApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n status: GovApplicationStatus;\n reason?: string | null;\n }) => {\n const result = await govQuery<{ govTransitionApplication: GovApplication }>(\n `mutation GovTransitionApplication($id: ID!, $status: GovApplicationStatus!, $reason: String) {\n govTransitionApplication(id: $id, status: $status, reason: $reason) { ${APPLICATION_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govTransitionApplication;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.application(data.id) });\n },\n });\n};\n\n// ============================================================================\n// Documents (attached to an application)\n// ============================================================================\n\nexport const useGovAddDocument = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovAddDocumentInput) => {\n const result = await govQuery<{ govAddDocument: GovDocument }>(\n `mutation GovAddDocument($input: GovAddDocumentInput!) {\n govAddDocument(input: $input) { ${DOCUMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govAddDocument;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n qc.invalidateQueries({ queryKey: KEY.applications });\n },\n });\n};\n\nexport const useGovReviewDocument = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n status: GovDocumentStatus;\n rejectionReason?: string | null;\n applicationId?: string;\n }) => {\n const result = await govQuery<{ govReviewDocument: GovDocument }>(\n `mutation GovReviewDocument($id: ID!, $status: GovDocumentStatus!, $rejectionReason: String) {\n govReviewDocument(id: $id, status: $status, rejectionReason: $rejectionReason) { ${DOCUMENT_FIELDS} }\n }`,\n { id: vars.id, status: vars.status, rejectionReason: vars.rejectionReason },\n apiGatewayUrl\n );\n return result.govReviewDocument;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\n// ============================================================================\n// Case notes (domain-owned casework timeline)\n// ============================================================================\n\nexport const useGovAddCaseNote = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovAddCaseNoteInput) => {\n const result = await govQuery<{ govAddCaseNote: GovCaseNote }>(\n `mutation GovAddCaseNote($input: GovAddCaseNoteInput!) {\n govAddCaseNote(input: $input) { ${CASE_NOTE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govAddCaseNote;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\n// ============================================================================\n// Payments (connection)\n// ============================================================================\n\nexport interface PaymentFilters {\n applicationId?: string;\n payerId?: string;\n status?: GovPaymentStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovPayments = (filters: PaymentFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.payments, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListPayments: GovConnection<GovPayment> }>(\n `query GovListPayments($applicationId: ID, $payerId: ID, $status: GovPaymentStatus, $pagination: PaginationInput) {\n govListPayments(applicationId: $applicationId, payerId: $payerId, status: $status, pagination: $pagination) {\n items { ${PAYMENT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n applicationId: filters.applicationId,\n payerId: filters.payerId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListPayments;\n },\n });\n};\n\nexport const useGovCreatePayment = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreatePaymentInput) => {\n const result = await govQuery<{ govCreatePayment: GovPayment }>(\n `mutation GovCreatePayment($input: GovCreatePaymentInput!) {\n govCreatePayment(input: $input) { ${PAYMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreatePayment;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.payments });\n if (data.applicationId)\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\nexport const useGovMarkPaymentPaid = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; providerRef?: string | null }) => {\n const result = await govQuery<{ govMarkPaymentPaid: GovPayment }>(\n `mutation GovMarkPaymentPaid($id: ID!, $providerRef: String) {\n govMarkPaymentPaid(id: $id, providerRef: $providerRef) { ${PAYMENT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govMarkPaymentPaid;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.payments }),\n });\n};\n\nexport const useGovRefundPayment = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govRefundPayment: GovPayment }>(\n `mutation GovRefundPayment($id: ID!) {\n govRefundPayment(id: $id) { ${PAYMENT_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govRefundPayment;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.payments }),\n });\n};\n\n// ============================================================================\n// Permits (list = ARRAY, no pagination) + public verification\n// ============================================================================\n\nexport interface PermitFilters {\n holderId?: string;\n serviceId?: string;\n status?: GovPermitStatus;\n pagination?: PaginationInput;\n}\n\n/**\n * `govListPermits` returns a paginated `GovPermitConnection`, flattened to a\n * plain array here since PermitsPage reads `data` as GovPermit[] and infers\n * `hasMore` itself from a full-length page. Callers page with `{ limit, offset }`.\n */\nexport const useGovPermits = (filters: PermitFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.permits, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListPermits: GovConnection<GovPermit> }>(\n `query GovListPermits($holderId: ID, $serviceId: ID, $status: GovPermitStatus, $pagination: PaginationInput) {\n govListPermits(holderId: $holderId, serviceId: $serviceId, status: $status, pagination: $pagination) {\n items { ${PERMIT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n holderId: filters.holderId,\n serviceId: filters.serviceId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListPermits.items;\n },\n });\n};\n\nexport const useGovIssuePermit = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovIssuePermitInput) => {\n const result = await govQuery<{ govIssuePermit: GovPermit }>(\n `mutation GovIssuePermit($input: GovIssuePermitInput!) {\n govIssuePermit(input: $input) { ${PERMIT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govIssuePermit;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.permits });\n if (data.applicationId)\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\nexport const useGovRevokePermit = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; reason?: string | null }) => {\n const result = await govQuery<{ govRevokePermit: GovPermit }>(\n `mutation GovRevokePermit($id: ID!, $reason: String) {\n govRevokePermit(id: $id, reason: $reason) { ${PERMIT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govRevokePermit;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.permits }),\n });\n};\n\n/**\n * Public permit verification by printed code. `govVerifyPermit` is a PUBLIC field\n * (no auth), but we keep the workspace-token transport for a consistent gateway\n * path. `enabled` is false until a code is supplied so the query is manual.\n */\nexport const useGovVerifyPermit = (verificationCode: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: ['govcitizenhub', 'verify-permit', verificationCode ?? ''],\n enabled: Boolean(verificationCode),\n retry: false,\n queryFn: async () => {\n const result = await govQuery<{ govVerifyPermit: GovPermit | null }>(\n `query GovVerifyPermit($verificationCode: String!) {\n govVerifyPermit(verificationCode: $verificationCode) { ${PERMIT_FIELDS} }\n }`,\n { verificationCode },\n apiGatewayUrl\n );\n return result.govVerifyPermit;\n },\n });\n};\n\n// ============================================================================\n// Grievances (connection)\n// ============================================================================\n\nexport interface GrievanceFilters {\n agencyId?: string;\n reporterId?: string;\n status?: GovGrievanceStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovGrievances = (filters: GrievanceFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.grievances, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListGrievances: GovConnection<GovGrievance> }>(\n `query GovListGrievances($agencyId: ID, $reporterId: ID, $status: GovGrievanceStatus, $pagination: PaginationInput) {\n govListGrievances(agencyId: $agencyId, reporterId: $reporterId, status: $status, pagination: $pagination) {\n items { ${GRIEVANCE_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n agencyId: filters.agencyId,\n reporterId: filters.reporterId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListGrievances;\n },\n });\n};\n\nexport const useGovGrievance = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.grievance(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govGrievance: GovGrievance | null }>(\n `query GovGrievance($id: ID!) {\n govGrievance(id: $id) { ${GRIEVANCE_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govGrievance;\n },\n });\n};\n\nexport const useGovReportGrievance = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovReportGrievanceInput) => {\n const result = await govQuery<{ govReportGrievance: GovGrievance }>(\n `mutation GovReportGrievance($input: GovReportGrievanceInput!) {\n govReportGrievance(input: $input) { ${GRIEVANCE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govReportGrievance;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.grievances }),\n });\n};\n\nexport const useGovUpdateGrievance = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateGrievanceInput }) => {\n const result = await govQuery<{ govUpdateGrievance: GovGrievance }>(\n `mutation GovUpdateGrievance($id: ID!, $input: GovUpdateGrievanceInput!) {\n govUpdateGrievance(id: $id, input: $input) { ${GRIEVANCE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateGrievance;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.grievances });\n qc.invalidateQueries({ queryKey: KEY.grievance(data.id) });\n },\n });\n};\n\nexport const useGovTransitionGrievance = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n status: GovGrievanceStatus;\n resolution?: string | null;\n }) => {\n const result = await govQuery<{ govTransitionGrievance: GovGrievance }>(\n `mutation GovTransitionGrievance($id: ID!, $status: GovGrievanceStatus!, $resolution: String) {\n govTransitionGrievance(id: $id, status: $status, resolution: $resolution) { ${GRIEVANCE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govTransitionGrievance;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.grievances });\n qc.invalidateQueries({ queryKey: KEY.grievance(data.id) });\n },\n });\n};\n"],"mappings":";;;;;;AA6DA,IAAM,KAAc,MAA2B,iBAAiB,KAAK,CAAK,GAEpE,IAAW,OACf,GACA,GACA,MACmB;CAKnB,IAAM,IAAW,EAAW,CAAK;CACjC,AAAI,KAAU,EAA0B;CAExC,IAAM,IAAW,MAAM,EAAoB;EACzC,SAAS;EACT;EACA;EACA;EACA,gBAAgB;CAClB,CAAC;CAED,AAAI,KAAU,EAA0B;CAOxC,IAAM,IAAO,EAAS;CAItB,IAAI,EAFF,KAAQ,QAAQ,OAAO,OAAO,CAAI,EAAE,MAAM,MAAU,KAAU,IAA2B,IAGzF,MAAU,MAAM,EAAS,SAAS,IAAI,WAAW,uCAAuC;CAM1F,OAJI,EAAS,QAAQ,UAEnB,QAAQ,KAAK,0DAA0D,EAAS,MAAM,GAEjF,EAAS;AAClB,GAGM,IAAM;CACV,WAAW,CAAC,iBAAiB,mBAAmB;CAChD,uBAAuB,CAAC,iBAAiB,yBAAyB;CAClE,uBAAuB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CAC1B,OAAO,EAAY;EACjB,YAAY,OAAO,OAQV,MAPc,EACnB;gDACwC,EAAiB;YAEzD,EAAE,SAAM,GACR,CACF,GACc;EAEhB,iBAAiB,EAAG,kBAAkB,EAAE,UAAU,EAAI,WAAW,CAAC;CACpE,CAAC;AACH,GAEa,UAA8B;CACzC,IAAM,EAAE,qBAAkB,EAAiB,GACrC,IAAK,EAAe;CAC1B,OAAO,EAAY;EACjB,YAAY,OAAO,OAQV,MAPc,EACnB;yDACiD,EAAiB;YAElE,GACA,CACF,GACc;EAEhB,YAAY,MAAS;GAEnB,AADA,EAAG,kBAAkB,EAAE,UAAU,EAAI,WAAW,CAAC,GACjD,EAAG,kBAAkB,EAAE,UAAU,EAAI,UAAU,EAAK,EAAE,EAAE,CAAC;EAC3D;CACF,CAAC;AACH,GAEa,UAAkC;CAC7C,IAAM,EAAE,qBAAkB,EAAiB,GACrC,IAAK,EAAe;CAC1B,OAAO,EAAY;EACjB,YAAY,OAAO,OAYV,MAPc,EACnB;wFACgF,EAAiB;YAEjG,GACA,CACF,GACc;EAEhB,YAAY,MAAS;GAEnB,AADA,EAAG,kBAAkB,EAAE,UAAU,EAAI,WAAW,CAAC,GACjD,EAAG,kBAAkB,EAAE,UAAU,EAAI,UAAU,EAAK,EAAE,EAAE,CAAC;EAC3D;CACF,CAAC;AACH"}
@@ -2,8 +2,9 @@
2
2
  * AgenciesPage — manage the government agencies that own services.
3
3
  * @module govcitizenhub/pages/agencies
4
4
  *
5
- * Reads `govListAgencies` (an ARRAY, not a connection) and offers full CRUD:
6
- * create / edit via {@link AgencyFormDialog}, a quick active/inactive toggle
5
+ * Reads `govListAgencies` (a paginated `GovAgencyConnection`, flattened to a
6
+ * plain array by {@link useGovAgencies}) and offers full CRUD: create / edit
7
+ * via {@link AgencyFormDialog}, a quick active/inactive toggle
7
8
  * (`govUpdateAgency`) and a confirm-guarded archive (`govArchiveAgency`). Each
8
9
  * card shows its live services count via a page-local `govListServices` query.
9
10
  */
@@ -1 +1 @@
1
- {"version":3,"file":"AgenciesPage.d.ts","sourceRoot":"","sources":["../../../../src/govcitizenhub/pages/agencies/AgenciesPage.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA4MH,wBAAgB,YAAY,4CAyK3B"}
1
+ {"version":3,"file":"AgenciesPage.d.ts","sourceRoot":"","sources":["../../../../src/govcitizenhub/pages/agencies/AgenciesPage.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AA4MH,wBAAgB,YAAY,4CAyK3B"}
@@ -1 +1 @@
1
- {"version":3,"file":"AgenciesPage.js","names":[],"sources":["../../../../src/govcitizenhub/pages/agencies/AgenciesPage.tsx"],"sourcesContent":["/**\n * AgenciesPage — manage the government agencies that own services.\n * @module govcitizenhub/pages/agencies\n *\n * Reads `govListAgencies` (an ARRAY, not a connection) and offers full CRUD:\n * create / edit via {@link AgencyFormDialog}, a quick active/inactive toggle\n * (`govUpdateAgency`) and a confirm-guarded archive (`govArchiveAgency`). Each\n * card shows its live services count via a page-local `govListServices` query.\n */\n\nimport { useMemo, useState } from 'react';\nimport {\n Plus,\n Mail,\n Phone,\n MapPin,\n MoreVertical,\n Pencil,\n Archive,\n Info,\n X,\n Search,\n Building2,\n Layers,\n} from 'lucide-react';\nimport {\n Button,\n GlassCard,\n Input,\n Switch,\n Skeleton,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from '@burdenoff/fe-libs/ui';\nimport { useQuery } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { PageLayout } from '../../components/PageLayout';\nimport { FilterTabs, type FilterOption } from '../../components/FilterTabs';\nimport { StatusBadge } from '../../components/StatusBadge';\nimport { EmptyState } from '../../components/EmptyState';\nimport { ErrorView } from '../../components/StateViews';\nimport { ConfirmDialog } from '../../components/ConfirmDialog';\nimport { AgencyFormDialog } from './AgencyFormDialog';\nimport { useGovAgencies, useGovArchiveAgency, useGovUpdateAgency } from '../../hooks';\nimport { useGovCitizenHub } from '../../context';\nimport { notify, describeError } from '../../lib/toast';\nimport type { GovAgency } from '../../types';\n\ntype ActiveFilter = 'ALL' | 'ACTIVE' | 'INACTIVE';\n\nconst FILTERS: FilterOption<ActiveFilter>[] = [\n { value: 'ALL', label: 'All' },\n { value: 'ACTIVE', label: 'Active' },\n { value: 'INACTIVE', label: 'Inactive' },\n];\n\nconst SERVICES_COUNT_MAX = 100;\n\n/**\n * Page-local services count. `govListServices` is a connection with no total, so\n * we read one capped page and show `items.length` (with a `100+` affordance if\n * more exist). Defined here via `graphqlFetch` — the shared hook file is untouched.\n */\nconst SERVICES_COUNT_QUERY = `\n query GovAgencyServicesCount($agencyId: ID!, $pagination: PaginationInput) {\n govListServices(agencyId: $agencyId, pagination: $pagination) {\n items { id }\n pageInfo { hasMore }\n }\n }\n`;\n\nfunction useAgencyServicesCount(agencyId: string) {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: ['govcitizenhub', 'agency-services-count', agencyId],\n staleTime: 60_000,\n queryFn: async () => {\n const response = await graphqlFetch<{\n govListServices: { items: { id: string }[]; pageInfo: { hasMore: boolean } };\n }>({\n gateway: 'workspace',\n baseUrl: apiGatewayUrl,\n workspaceToken: true,\n query: SERVICES_COUNT_QUERY,\n variables: { agencyId, pagination: { limit: SERVICES_COUNT_MAX } },\n });\n if (response.errors?.length) {\n throw new Error(response.errors[0]?.message ?? 'Could not count services');\n }\n const conn = response.data?.govListServices;\n return { count: conn?.items.length ?? 0, hasMore: conn?.pageInfo.hasMore ?? false };\n },\n });\n}\n\nfunction ServicesCount({ agencyId }: { agencyId: string }) {\n const { data, isLoading } = useAgencyServicesCount(agencyId);\n if (isLoading) {\n return <Skeleton className=\"inline-block h-3.5 w-16 rounded\" />;\n }\n const count = data?.count ?? 0;\n const label = data?.hasMore ? `${SERVICES_COUNT_MAX}+` : count;\n return (\n <span className=\"inline-flex items-center gap-1.5 text-sm text-text-secondary\">\n <Layers className=\"size-3.5 text-text-muted\" />\n <span className=\"font-medium text-text-primary tabular-nums\">{label}</span>{' '}\n {count === 1 && !data?.hasMore ? 'service' : 'services'}\n </span>\n );\n}\n\nfunction AgencyCard({\n agency,\n onEdit,\n onArchive,\n onToggleActive,\n toggleBusy,\n}: {\n agency: GovAgency;\n onEdit: () => void;\n onArchive: () => void;\n onToggleActive: (next: boolean) => void;\n toggleBusy: boolean;\n}) {\n return (\n <GlassCard treatment=\"plain\" className=\"flex flex-col border-border-seam p-5\">\n <div className=\"flex items-start gap-3\">\n <span className=\"inline-flex size-12 shrink-0 items-center justify-center rounded-xl bg-[var(--color-accent-soft)] text-action-primary-text\">\n <Building2 className=\"size-6\" aria-hidden=\"true\" />\n </span>\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex items-start justify-between gap-2\">\n <div className=\"min-w-0\">\n <h2\n className=\"truncate text-base font-semibold text-text-primary\"\n title={agency.name}\n >\n {agency.name}\n </h2>\n {agency.jurisdiction && (\n <p className=\"truncate text-xs text-text-muted\">{agency.jurisdiction}</p>\n )}\n </div>\n <DropdownMenu>\n <DropdownMenuTrigger\n className=\"inline-flex size-8 shrink-0 items-center justify-center rounded-button text-text-secondary hover:bg-bg-sunken hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n aria-label={`Actions for ${agency.name}`}\n >\n <MoreVertical className=\"size-4\" />\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"min-w-40\">\n <DropdownMenuItem className=\"gap-2\" onSelect={onEdit}>\n <Pencil className=\"size-4\" /> Edit\n </DropdownMenuItem>\n <DropdownMenuItem\n className=\"gap-2 text-status-error-text focus:text-status-error-text\"\n onSelect={onArchive}\n >\n <Archive className=\"size-4\" /> Archive\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n </div>\n </div>\n\n <div className=\"mt-4 space-y-1.5 text-sm text-text-secondary\">\n {agency.code && (\n <p className=\"flex items-center gap-1.5\">\n <span className=\"inline-flex rounded bg-bg-sunken px-1.5 py-0.5 font-mono text-xs text-text-secondary\">\n {agency.code}\n </span>\n </p>\n )}\n {agency.contactPhone && (\n <p className=\"flex items-center gap-1.5\">\n <Phone className=\"size-3.5 shrink-0 text-text-muted\" /> {agency.contactPhone}\n </p>\n )}\n {agency.contactEmail && (\n <p className=\"flex items-center gap-1.5\">\n <Mail className=\"size-3.5 shrink-0 text-text-muted\" />\n <span className=\"truncate\">{agency.contactEmail}</span>\n </p>\n )}\n {agency.jurisdiction && (\n <p className=\"flex items-center gap-1.5\">\n <MapPin className=\"size-3.5 shrink-0 text-text-muted\" /> {agency.jurisdiction}\n </p>\n )}\n </div>\n\n <div className=\"mt-4 flex items-center justify-between gap-3 border-t border-border-seam pt-4\">\n <ServicesCount agencyId={agency.id} />\n <div className=\"flex items-center gap-2.5\">\n <StatusBadge status={agency.isActive ? 'ACTIVE' : 'RETIRED'} />\n <Switch\n checked={agency.isActive}\n onCheckedChange={onToggleActive}\n disabled={toggleBusy}\n aria-label={`${agency.isActive ? 'Deactivate' : 'Activate'} ${agency.name}`}\n />\n </div>\n </div>\n </GlassCard>\n );\n}\n\nexport function AgenciesPage() {\n const [filter, setFilter] = useState<ActiveFilter>('ALL');\n const [search, setSearch] = useState('');\n const [bannerOpen, setBannerOpen] = useState(true);\n const { data, isLoading, isError, refetch } = useGovAgencies(\n filter === 'ALL' ? {} : { isActive: filter === 'ACTIVE' }\n );\n const archiveAgency = useGovArchiveAgency();\n const updateAgency = useGovUpdateAgency();\n\n const [formOpen, setFormOpen] = useState(false);\n const [editing, setEditing] = useState<GovAgency | null>(null);\n const [archiving, setArchiving] = useState<GovAgency | null>(null);\n const [togglingId, setTogglingId] = useState<string | null>(null);\n\n const agencies = useMemo(() => data ?? [], [data]);\n const query = search.trim().toLowerCase();\n const visible = useMemo(\n () =>\n query\n ? agencies.filter(\n (a) =>\n a.name.toLowerCase().includes(query) ||\n (a.jurisdiction ?? '').toLowerCase().includes(query) ||\n (a.code ?? '').toLowerCase().includes(query) ||\n (a.contactEmail ?? '').toLowerCase().includes(query)\n )\n : agencies,\n [agencies, query]\n );\n\n const openCreate = () => {\n setEditing(null);\n setFormOpen(true);\n };\n const openEdit = (agency: GovAgency) => {\n setEditing(agency);\n setFormOpen(true);\n };\n\n const toggleActive = async (agency: GovAgency, next: boolean) => {\n setTogglingId(agency.id);\n try {\n await updateAgency.mutateAsync({ id: agency.id, input: { isActive: next } });\n notify.success(next ? 'Agency activated' : 'Agency deactivated', agency.name);\n } catch (err) {\n notify.error('Could not update agency', describeError(err));\n } finally {\n setTogglingId(null);\n }\n };\n\n const confirmArchive = async () => {\n if (!archiving) return;\n try {\n await archiveAgency.mutateAsync(archiving.id);\n notify.success('Agency archived', archiving.name);\n setArchiving(null);\n } catch (err) {\n notify.error('Could not archive agency', describeError(err));\n }\n };\n\n return (\n <PageLayout\n title=\"Agencies\"\n titleGradient\n description=\"Government departments and bodies that own and deliver public services.\"\n actions={\n <Button onClick={openCreate}>\n <Plus className=\"mr-1.5 h-4 w-4\" /> New agency\n </Button>\n }\n >\n {bannerOpen && (\n <div className=\"mb-5 flex items-start gap-3 rounded-card border border-[var(--color-accent-soft)] bg-[var(--color-accent-soft)] px-4 py-3\">\n <Info className=\"mt-0.5 size-4 shrink-0 text-action-primary-text\" aria-hidden=\"true\" />\n <p className=\"min-w-0 flex-1 text-sm text-action-primary-text\">\n Each agency is isolated in its own workspace, sharing common identity and standards.\n </p>\n <button\n type=\"button\"\n onClick={() => setBannerOpen(false)}\n aria-label=\"Dismiss multi-tenancy note\"\n className=\"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-action-primary-text/70 transition-colors hover:bg-bg-surface/40 hover:text-action-primary-text focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n >\n <X className=\"size-4\" />\n </button>\n </div>\n )}\n\n <div className=\"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between\">\n <FilterTabs options={FILTERS} value={filter} onChange={setFilter} />\n <div className=\"relative w-full sm:max-w-xs\">\n <Search className=\"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-text-muted\" />\n <Input\n value={search}\n onChange={(e) => setSearch(e.target.value)}\n placeholder=\"Search agencies…\"\n aria-label=\"Search agencies\"\n className=\"pl-9\"\n />\n </div>\n </div>\n\n {isLoading ? (\n <div className=\"grid gap-4 sm:grid-cols-2 xl:grid-cols-3\">\n {Array.from({ length: 6 }, (_, i) => (\n <GlassCard key={i} treatment=\"plain\" className=\"space-y-3 p-5\">\n <div className=\"flex items-center gap-3\">\n <Skeleton className=\"size-12 rounded-xl\" />\n <Skeleton className=\"h-5 w-1/2 rounded\" />\n </div>\n <Skeleton className=\"h-4 w-3/4 rounded\" />\n <Skeleton className=\"h-4 w-2/3 rounded\" />\n </GlassCard>\n ))}\n </div>\n ) : isError ? (\n <ErrorView message=\"We couldn't load agencies.\" onRetry={() => refetch()} />\n ) : agencies.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title=\"No agencies yet\"\n description=\"Create your first agency to start publishing services citizens can apply for.\"\n action={\n <Button onClick={openCreate}>\n <Plus className=\"mr-1.5 h-4 w-4\" /> New agency\n </Button>\n }\n />\n ) : visible.length === 0 ? (\n <EmptyState\n illustration=\"empty-search\"\n title=\"No matching agencies\"\n description={`Nothing matches “${search.trim()}”.`}\n />\n ) : (\n <div className=\"grid gap-4 sm:grid-cols-2 xl:grid-cols-3\">\n {visible.map((agency) => (\n <AgencyCard\n key={agency.id}\n agency={agency}\n onEdit={() => openEdit(agency)}\n onArchive={() => setArchiving(agency)}\n onToggleActive={(next) => toggleActive(agency, next)}\n toggleBusy={togglingId === agency.id}\n />\n ))}\n </div>\n )}\n\n <AgencyFormDialog\n open={formOpen}\n onOpenChange={setFormOpen}\n agency={editing}\n onSaved={() => refetch()}\n />\n <ConfirmDialog\n open={Boolean(archiving)}\n onOpenChange={(next) => (next ? undefined : setArchiving(null))}\n title={`Archive ${archiving?.name ?? 'agency'}?`}\n description=\"The agency will be archived and hidden from citizens. You can recreate or edit it later.\"\n confirmLabel=\"Archive\"\n destructive\n onConfirm={confirmArchive}\n />\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAqDA,IAAM,IAAwC;CAC5C;EAAE,OAAO;EAAO,OAAO;CAAM;CAC7B;EAAE,OAAO;EAAU,OAAO;CAAS;CACnC;EAAE,OAAO;EAAY,OAAO;CAAW;AACzC,GAEM,IAAqB,KAOrB,IAAuB;AAS7B,SAAS,EAAuB,GAAkB;CAChD,IAAM,EAAE,qBAAkB,EAAiB;CAC3C,OAAO,EAAS;EACd,UAAU;GAAC;GAAiB;GAAyB;EAAQ;EAC7D,WAAW;EACX,SAAS,YAAY;GACnB,IAAM,IAAW,MAAM,EAEpB;IACD,SAAS;IACT,SAAS;IACT,gBAAgB;IAChB,OAAO;IACP,WAAW;KAAE;KAAU,YAAY,EAAE,OAAO,EAAmB;IAAE;GACnE,CAAC;GACD,IAAI,EAAS,QAAQ,QACnB,MAAU,MAAM,EAAS,OAAO,IAAI,WAAW,0BAA0B;GAE3E,IAAM,IAAO,EAAS,MAAM;GAC5B,OAAO;IAAE,OAAO,GAAM,MAAM,UAAU;IAAG,SAAS,GAAM,SAAS,WAAW;GAAM;EACpF;CACF,CAAC;AACH;AAEA,SAAS,EAAc,EAAE,eAAkC;CACzD,IAAM,EAAE,SAAM,iBAAc,EAAuB,CAAQ;CAC3D,IAAI,GACF,OAAO,kBAAC,GAAD,EAAU,WAAU,kCAAmC,CAAA;CAEhE,IAAM,IAAQ,GAAM,SAAS,GACvB,IAAQ,GAAM,UAAU,GAAG,EAAmB,KAAK;CACzD,OACE,kBAAC,QAAD;EAAM,WAAU;YAAhB;GACE,kBAAC,GAAD,EAAQ,WAAU,2BAA4B,CAAA;GAC9C,kBAAC,QAAD;IAAM,WAAU;cAA8C;GAAY,CAAA;GAAE;GAC3E,MAAU,KAAK,CAAC,GAAM,UAAU,YAAY;EACzC;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kBAAC,GAAD;IACE,MAAM,EAAQ;IACd,eAAe,MAAU,IAAO,KAAA,IAAY,EAAa,IAAI;IAC7D,OAAO,WAAW,GAAW,QAAQ,SAAS;IAC9C,aAAY;IACZ,cAAa;IACb,aAAA;IACA,WAAW,YAjHkB;KAC5B,OACL,IAAI;MAGF,AAFA,MAAM,EAAc,YAAY,EAAU,EAAE,GAC5C,EAAO,QAAQ,mBAAmB,EAAU,IAAI,GAChD,EAAa,IAAI;KACnB,SAAS,GAAK;MACZ,EAAO,MAAM,4BAA4B,EAAc,CAAG,CAAC;KAC7D;IACF;GAyGK,CAAA;EACS;;AAEhB"}
1
+ {"version":3,"file":"AgenciesPage.js","names":[],"sources":["../../../../src/govcitizenhub/pages/agencies/AgenciesPage.tsx"],"sourcesContent":["/**\n * AgenciesPage — manage the government agencies that own services.\n * @module govcitizenhub/pages/agencies\n *\n * Reads `govListAgencies` (a paginated `GovAgencyConnection`, flattened to a\n * plain array by {@link useGovAgencies}) and offers full CRUD: create / edit\n * via {@link AgencyFormDialog}, a quick active/inactive toggle\n * (`govUpdateAgency`) and a confirm-guarded archive (`govArchiveAgency`). Each\n * card shows its live services count via a page-local `govListServices` query.\n */\n\nimport { useMemo, useState } from 'react';\nimport {\n Plus,\n Mail,\n Phone,\n MapPin,\n MoreVertical,\n Pencil,\n Archive,\n Info,\n X,\n Search,\n Building2,\n Layers,\n} from 'lucide-react';\nimport {\n Button,\n GlassCard,\n Input,\n Switch,\n Skeleton,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n} from '@burdenoff/fe-libs/ui';\nimport { useQuery } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { PageLayout } from '../../components/PageLayout';\nimport { FilterTabs, type FilterOption } from '../../components/FilterTabs';\nimport { StatusBadge } from '../../components/StatusBadge';\nimport { EmptyState } from '../../components/EmptyState';\nimport { ErrorView } from '../../components/StateViews';\nimport { ConfirmDialog } from '../../components/ConfirmDialog';\nimport { AgencyFormDialog } from './AgencyFormDialog';\nimport { useGovAgencies, useGovArchiveAgency, useGovUpdateAgency } from '../../hooks';\nimport { useGovCitizenHub } from '../../context';\nimport { notify, describeError } from '../../lib/toast';\nimport type { GovAgency } from '../../types';\n\ntype ActiveFilter = 'ALL' | 'ACTIVE' | 'INACTIVE';\n\nconst FILTERS: FilterOption<ActiveFilter>[] = [\n { value: 'ALL', label: 'All' },\n { value: 'ACTIVE', label: 'Active' },\n { value: 'INACTIVE', label: 'Inactive' },\n];\n\nconst SERVICES_COUNT_MAX = 100;\n\n/**\n * Page-local services count. `govListServices` is a connection with no total, so\n * we read one capped page and show `items.length` (with a `100+` affordance if\n * more exist). Defined here via `graphqlFetch` — the shared hook file is untouched.\n */\nconst SERVICES_COUNT_QUERY = `\n query GovAgencyServicesCount($agencyId: ID!, $pagination: PaginationInput) {\n govListServices(agencyId: $agencyId, pagination: $pagination) {\n items { id }\n pageInfo { hasMore }\n }\n }\n`;\n\nfunction useAgencyServicesCount(agencyId: string) {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: ['govcitizenhub', 'agency-services-count', agencyId],\n staleTime: 60_000,\n queryFn: async () => {\n const response = await graphqlFetch<{\n govListServices: { items: { id: string }[]; pageInfo: { hasMore: boolean } };\n }>({\n gateway: 'workspace',\n baseUrl: apiGatewayUrl,\n workspaceToken: true,\n query: SERVICES_COUNT_QUERY,\n variables: { agencyId, pagination: { limit: SERVICES_COUNT_MAX } },\n });\n if (response.errors?.length) {\n throw new Error(response.errors[0]?.message ?? 'Could not count services');\n }\n const conn = response.data?.govListServices;\n return { count: conn?.items.length ?? 0, hasMore: conn?.pageInfo.hasMore ?? false };\n },\n });\n}\n\nfunction ServicesCount({ agencyId }: { agencyId: string }) {\n const { data, isLoading } = useAgencyServicesCount(agencyId);\n if (isLoading) {\n return <Skeleton className=\"inline-block h-3.5 w-16 rounded\" />;\n }\n const count = data?.count ?? 0;\n const label = data?.hasMore ? `${SERVICES_COUNT_MAX}+` : count;\n return (\n <span className=\"inline-flex items-center gap-1.5 text-sm text-text-secondary\">\n <Layers className=\"size-3.5 text-text-muted\" />\n <span className=\"font-medium text-text-primary tabular-nums\">{label}</span>{' '}\n {count === 1 && !data?.hasMore ? 'service' : 'services'}\n </span>\n );\n}\n\nfunction AgencyCard({\n agency,\n onEdit,\n onArchive,\n onToggleActive,\n toggleBusy,\n}: {\n agency: GovAgency;\n onEdit: () => void;\n onArchive: () => void;\n onToggleActive: (next: boolean) => void;\n toggleBusy: boolean;\n}) {\n return (\n <GlassCard treatment=\"plain\" className=\"flex flex-col border-border-seam p-5\">\n <div className=\"flex items-start gap-3\">\n <span className=\"inline-flex size-12 shrink-0 items-center justify-center rounded-xl bg-[var(--color-accent-soft)] text-action-primary-text\">\n <Building2 className=\"size-6\" aria-hidden=\"true\" />\n </span>\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex items-start justify-between gap-2\">\n <div className=\"min-w-0\">\n <h2\n className=\"truncate text-base font-semibold text-text-primary\"\n title={agency.name}\n >\n {agency.name}\n </h2>\n {agency.jurisdiction && (\n <p className=\"truncate text-xs text-text-muted\">{agency.jurisdiction}</p>\n )}\n </div>\n <DropdownMenu>\n <DropdownMenuTrigger\n className=\"inline-flex size-8 shrink-0 items-center justify-center rounded-button text-text-secondary hover:bg-bg-sunken hover:text-text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n aria-label={`Actions for ${agency.name}`}\n >\n <MoreVertical className=\"size-4\" />\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\" className=\"min-w-40\">\n <DropdownMenuItem className=\"gap-2\" onSelect={onEdit}>\n <Pencil className=\"size-4\" /> Edit\n </DropdownMenuItem>\n <DropdownMenuItem\n className=\"gap-2 text-status-error-text focus:text-status-error-text\"\n onSelect={onArchive}\n >\n <Archive className=\"size-4\" /> Archive\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n </div>\n </div>\n\n <div className=\"mt-4 space-y-1.5 text-sm text-text-secondary\">\n {agency.code && (\n <p className=\"flex items-center gap-1.5\">\n <span className=\"inline-flex rounded bg-bg-sunken px-1.5 py-0.5 font-mono text-xs text-text-secondary\">\n {agency.code}\n </span>\n </p>\n )}\n {agency.contactPhone && (\n <p className=\"flex items-center gap-1.5\">\n <Phone className=\"size-3.5 shrink-0 text-text-muted\" /> {agency.contactPhone}\n </p>\n )}\n {agency.contactEmail && (\n <p className=\"flex items-center gap-1.5\">\n <Mail className=\"size-3.5 shrink-0 text-text-muted\" />\n <span className=\"truncate\">{agency.contactEmail}</span>\n </p>\n )}\n {agency.jurisdiction && (\n <p className=\"flex items-center gap-1.5\">\n <MapPin className=\"size-3.5 shrink-0 text-text-muted\" /> {agency.jurisdiction}\n </p>\n )}\n </div>\n\n <div className=\"mt-4 flex items-center justify-between gap-3 border-t border-border-seam pt-4\">\n <ServicesCount agencyId={agency.id} />\n <div className=\"flex items-center gap-2.5\">\n <StatusBadge status={agency.isActive ? 'ACTIVE' : 'RETIRED'} />\n <Switch\n checked={agency.isActive}\n onCheckedChange={onToggleActive}\n disabled={toggleBusy}\n aria-label={`${agency.isActive ? 'Deactivate' : 'Activate'} ${agency.name}`}\n />\n </div>\n </div>\n </GlassCard>\n );\n}\n\nexport function AgenciesPage() {\n const [filter, setFilter] = useState<ActiveFilter>('ALL');\n const [search, setSearch] = useState('');\n const [bannerOpen, setBannerOpen] = useState(true);\n const { data, isLoading, isError, refetch } = useGovAgencies(\n filter === 'ALL' ? {} : { isActive: filter === 'ACTIVE' }\n );\n const archiveAgency = useGovArchiveAgency();\n const updateAgency = useGovUpdateAgency();\n\n const [formOpen, setFormOpen] = useState(false);\n const [editing, setEditing] = useState<GovAgency | null>(null);\n const [archiving, setArchiving] = useState<GovAgency | null>(null);\n const [togglingId, setTogglingId] = useState<string | null>(null);\n\n const agencies = useMemo(() => data ?? [], [data]);\n const query = search.trim().toLowerCase();\n const visible = useMemo(\n () =>\n query\n ? agencies.filter(\n (a) =>\n a.name.toLowerCase().includes(query) ||\n (a.jurisdiction ?? '').toLowerCase().includes(query) ||\n (a.code ?? '').toLowerCase().includes(query) ||\n (a.contactEmail ?? '').toLowerCase().includes(query)\n )\n : agencies,\n [agencies, query]\n );\n\n const openCreate = () => {\n setEditing(null);\n setFormOpen(true);\n };\n const openEdit = (agency: GovAgency) => {\n setEditing(agency);\n setFormOpen(true);\n };\n\n const toggleActive = async (agency: GovAgency, next: boolean) => {\n setTogglingId(agency.id);\n try {\n await updateAgency.mutateAsync({ id: agency.id, input: { isActive: next } });\n notify.success(next ? 'Agency activated' : 'Agency deactivated', agency.name);\n } catch (err) {\n notify.error('Could not update agency', describeError(err));\n } finally {\n setTogglingId(null);\n }\n };\n\n const confirmArchive = async () => {\n if (!archiving) return;\n try {\n await archiveAgency.mutateAsync(archiving.id);\n notify.success('Agency archived', archiving.name);\n setArchiving(null);\n } catch (err) {\n notify.error('Could not archive agency', describeError(err));\n }\n };\n\n return (\n <PageLayout\n title=\"Agencies\"\n titleGradient\n description=\"Government departments and bodies that own and deliver public services.\"\n actions={\n <Button onClick={openCreate}>\n <Plus className=\"mr-1.5 h-4 w-4\" /> New agency\n </Button>\n }\n >\n {bannerOpen && (\n <div className=\"mb-5 flex items-start gap-3 rounded-card border border-[var(--color-accent-soft)] bg-[var(--color-accent-soft)] px-4 py-3\">\n <Info className=\"mt-0.5 size-4 shrink-0 text-action-primary-text\" aria-hidden=\"true\" />\n <p className=\"min-w-0 flex-1 text-sm text-action-primary-text\">\n Each agency is isolated in its own workspace, sharing common identity and standards.\n </p>\n <button\n type=\"button\"\n onClick={() => setBannerOpen(false)}\n aria-label=\"Dismiss multi-tenancy note\"\n className=\"inline-flex size-6 shrink-0 items-center justify-center rounded-md text-action-primary-text/70 transition-colors hover:bg-bg-surface/40 hover:text-action-primary-text focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-border-focus\"\n >\n <X className=\"size-4\" />\n </button>\n </div>\n )}\n\n <div className=\"mb-5 flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between\">\n <FilterTabs options={FILTERS} value={filter} onChange={setFilter} />\n <div className=\"relative w-full sm:max-w-xs\">\n <Search className=\"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-text-muted\" />\n <Input\n value={search}\n onChange={(e) => setSearch(e.target.value)}\n placeholder=\"Search agencies…\"\n aria-label=\"Search agencies\"\n className=\"pl-9\"\n />\n </div>\n </div>\n\n {isLoading ? (\n <div className=\"grid gap-4 sm:grid-cols-2 xl:grid-cols-3\">\n {Array.from({ length: 6 }, (_, i) => (\n <GlassCard key={i} treatment=\"plain\" className=\"space-y-3 p-5\">\n <div className=\"flex items-center gap-3\">\n <Skeleton className=\"size-12 rounded-xl\" />\n <Skeleton className=\"h-5 w-1/2 rounded\" />\n </div>\n <Skeleton className=\"h-4 w-3/4 rounded\" />\n <Skeleton className=\"h-4 w-2/3 rounded\" />\n </GlassCard>\n ))}\n </div>\n ) : isError ? (\n <ErrorView message=\"We couldn't load agencies.\" onRetry={() => refetch()} />\n ) : agencies.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title=\"No agencies yet\"\n description=\"Create your first agency to start publishing services citizens can apply for.\"\n action={\n <Button onClick={openCreate}>\n <Plus className=\"mr-1.5 h-4 w-4\" /> New agency\n </Button>\n }\n />\n ) : visible.length === 0 ? (\n <EmptyState\n illustration=\"empty-search\"\n title=\"No matching agencies\"\n description={`Nothing matches “${search.trim()}”.`}\n />\n ) : (\n <div className=\"grid gap-4 sm:grid-cols-2 xl:grid-cols-3\">\n {visible.map((agency) => (\n <AgencyCard\n key={agency.id}\n agency={agency}\n onEdit={() => openEdit(agency)}\n onArchive={() => setArchiving(agency)}\n onToggleActive={(next) => toggleActive(agency, next)}\n toggleBusy={togglingId === agency.id}\n />\n ))}\n </div>\n )}\n\n <AgencyFormDialog\n open={formOpen}\n onOpenChange={setFormOpen}\n agency={editing}\n onSaved={() => refetch()}\n />\n <ConfirmDialog\n open={Boolean(archiving)}\n onOpenChange={(next) => (next ? undefined : setArchiving(null))}\n title={`Archive ${archiving?.name ?? 'agency'}?`}\n description=\"The agency will be archived and hidden from citizens. You can recreate or edit it later.\"\n confirmLabel=\"Archive\"\n destructive\n onConfirm={confirmArchive}\n />\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AAsDA,IAAM,IAAwC;CAC5C;EAAE,OAAO;EAAO,OAAO;CAAM;CAC7B;EAAE,OAAO;EAAU,OAAO;CAAS;CACnC;EAAE,OAAO;EAAY,OAAO;CAAW;AACzC,GAEM,IAAqB,KAOrB,IAAuB;AAS7B,SAAS,EAAuB,GAAkB;CAChD,IAAM,EAAE,qBAAkB,EAAiB;CAC3C,OAAO,EAAS;EACd,UAAU;GAAC;GAAiB;GAAyB;EAAQ;EAC7D,WAAW;EACX,SAAS,YAAY;GACnB,IAAM,IAAW,MAAM,EAEpB;IACD,SAAS;IACT,SAAS;IACT,gBAAgB;IAChB,OAAO;IACP,WAAW;KAAE;KAAU,YAAY,EAAE,OAAO,EAAmB;IAAE;GACnE,CAAC;GACD,IAAI,EAAS,QAAQ,QACnB,MAAU,MAAM,EAAS,OAAO,IAAI,WAAW,0BAA0B;GAE3E,IAAM,IAAO,EAAS,MAAM;GAC5B,OAAO;IAAE,OAAO,GAAM,MAAM,UAAU;IAAG,SAAS,GAAM,SAAS,WAAW;GAAM;EACpF;CACF,CAAC;AACH;AAEA,SAAS,EAAc,EAAE,eAAkC;CACzD,IAAM,EAAE,SAAM,iBAAc,EAAuB,CAAQ;CAC3D,IAAI,GACF,OAAO,kBAAC,GAAD,EAAU,WAAU,kCAAmC,CAAA;CAEhE,IAAM,IAAQ,GAAM,SAAS,GACvB,IAAQ,GAAM,UAAU,GAAG,EAAmB,KAAK;CACzD,OACE,kBAAC,QAAD;EAAM,WAAU;YAAhB;GACE,kBAAC,GAAD,EAAQ,WAAU,2BAA4B,CAAA;GAC9C,kBAA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,CAAA;GAGP,kBAAC,GAAD;IACE,MAAM;IACN,cAAc;IACd,QAAQ;IACR,eAAe,EAAQ;GACxB,CAAA;GACD,kBAAC,GAAD;IACE,MAAM,EAAQ;IACd,eAAe,MAAU,IAAO,KAAA,IAAY,EAAa,IAAI;IAC7D,OAAO,WAAW,GAAW,QAAQ,SAAS;IAC9C,aAAY;IACZ,cAAa;IACb,aAAA;IACA,WAAW,YAjHkB;KAC5B,OACL,IAAI;MAGF,AAFA,MAAM,EAAc,YAAY,EAAU,EAAE,GAC5C,EAAO,QAAQ,mBAAmB,EAAU,IAAI,GAChD,EAAa,IAAI;KACnB,SAAS,GAAK;MACZ,EAAO,MAAM,4BAA4B,EAAc,CAAG,CAAC;KAC7D;IACF;GAyGK,CAAA;EACS;;AAEhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"ApplicationsPage.d.ts","sourceRoot":"","sources":["../../../../src/govcitizenhub/pages/applications/ApplicationsPage.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AA4NH,wBAAgB,gBAAgB,4CA6Q/B"}
1
+ {"version":3,"file":"ApplicationsPage.d.ts","sourceRoot":"","sources":["../../../../src/govcitizenhub/pages/applications/ApplicationsPage.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAwPH,wBAAgB,gBAAgB,4CA8R/B"}