@burdenoff/microfe-govcitizenhub 2026.1123.1 → 2026.1123.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/govcitizenhub/components/DynamicFormFields.js +62 -62
- package/dist/govcitizenhub/components/DynamicFormFields.js.map +1 -1
- package/dist/govcitizenhub/hooks/useGovApi.js +1 -1
- package/dist/govcitizenhub/hooks/useGovApi.js.map +1 -1
- package/dist/govcitizenhub/pages/applications/NewApplicationPage.js +160 -153
- package/dist/govcitizenhub/pages/applications/NewApplicationPage.js.map +1 -1
- package/dist/govcitizenhub/pages/services/EligibilityRulesBuilder.d.ts +10 -0
- package/dist/govcitizenhub/pages/services/EligibilityRulesBuilder.js +183 -0
- package/dist/govcitizenhub/pages/services/EligibilityRulesBuilder.js.map +1 -0
- package/dist/govcitizenhub/pages/services/FormFieldBuilder.js +6 -0
- package/dist/govcitizenhub/pages/services/FormFieldBuilder.js.map +1 -1
- package/dist/govcitizenhub/pages/services/ServiceFormDialog.js +99 -78
- package/dist/govcitizenhub/pages/services/ServiceFormDialog.js.map +1 -1
- package/dist/govcitizenhub/types/index.d.ts +13 -0
- package/dist/govcitizenhub/utils/dynamicForm.d.ts +2 -1
- package/dist/govcitizenhub/utils/dynamicForm.js +20 -17
- package/dist/govcitizenhub/utils/dynamicForm.js.map +1 -1
- package/dist/govcitizenhub/utils/eligibilityRules.d.ts +6 -0
- package/dist/govcitizenhub/utils/eligibilityRules.js +61 -0
- package/dist/govcitizenhub/utils/eligibilityRules.js.map +1 -0
- package/package.json +1 -1
|
@@ -1,66 +1,66 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { cn as
|
|
3
|
-
import { CheckCircle2 as
|
|
4
|
-
import { jsx as
|
|
5
|
-
import { Input as
|
|
1
|
+
import { dynamicInputType as e, visibleFormSections as t } from "../utils/dynamicForm.js";
|
|
2
|
+
import { cn as n } from "../utils/cn.js";
|
|
3
|
+
import { CheckCircle2 as r, Loader2 as i, UploadCloud as a } from "lucide-react";
|
|
4
|
+
import { jsx as o, jsxs as s } from "react/jsx-runtime";
|
|
5
|
+
import { Input as c, Label as l, Select as u, SelectContent as d, SelectItem as f, SelectTrigger as p, SelectValue as m, Textarea as h } from "@burdenoff/fe-libs/ui";
|
|
6
6
|
// src/govcitizenhub/components/DynamicFormFields.tsx
|
|
7
|
-
function
|
|
8
|
-
let
|
|
9
|
-
if (
|
|
10
|
-
let
|
|
11
|
-
let
|
|
12
|
-
return /* @__PURE__ */
|
|
13
|
-
className:
|
|
14
|
-
children: [/* @__PURE__ */
|
|
15
|
-
htmlFor:
|
|
16
|
-
children: [
|
|
7
|
+
function g({ fields: r, values: i, onChange: a, fileNames: g = {}, uploadingKey: v = null, onFileSelect: y, disabled: b = !1, previewMode: x = !1, idPrefix: S = "f" }) {
|
|
8
|
+
let C = t(r, i);
|
|
9
|
+
if (C.length === 0) return null;
|
|
10
|
+
let w = (t) => {
|
|
11
|
+
let r = t.type === "textarea" || t.type === "file" ? "sm:col-span-2" : "", C = `${S}-${t.key}`;
|
|
12
|
+
return /* @__PURE__ */ s("div", {
|
|
13
|
+
className: n("grid gap-1.5", r),
|
|
14
|
+
children: [/* @__PURE__ */ s(l, {
|
|
15
|
+
htmlFor: C,
|
|
16
|
+
children: [t.label, t.required && /* @__PURE__ */ o("span", {
|
|
17
17
|
className: "text-status-error-text",
|
|
18
18
|
children: " *"
|
|
19
19
|
})]
|
|
20
|
-
}),
|
|
21
|
-
id:
|
|
22
|
-
value:
|
|
23
|
-
onChange: (
|
|
24
|
-
disabled:
|
|
20
|
+
}), t.type === "textarea" ? /* @__PURE__ */ o(h, {
|
|
21
|
+
id: C,
|
|
22
|
+
value: i[t.key] ?? "",
|
|
23
|
+
onChange: (e) => a(t.key, e.target.value),
|
|
24
|
+
disabled: b,
|
|
25
25
|
rows: 3
|
|
26
|
-
}) :
|
|
27
|
-
value:
|
|
28
|
-
onValueChange: (
|
|
29
|
-
disabled:
|
|
30
|
-
children: [/* @__PURE__ */
|
|
31
|
-
id:
|
|
32
|
-
"aria-label":
|
|
33
|
-
children: /* @__PURE__ */
|
|
34
|
-
}), /* @__PURE__ */
|
|
26
|
+
}) : t.type === "select" ? /* @__PURE__ */ s(u, {
|
|
27
|
+
value: i[t.key] ?? "",
|
|
28
|
+
onValueChange: (e) => a(t.key, e),
|
|
29
|
+
disabled: b,
|
|
30
|
+
children: [/* @__PURE__ */ o(p, {
|
|
31
|
+
id: C,
|
|
32
|
+
"aria-label": t.label,
|
|
33
|
+
children: /* @__PURE__ */ o(m, { placeholder: "Select…" })
|
|
34
|
+
}), /* @__PURE__ */ o(d, { children: (t.options ?? []).map((e) => /* @__PURE__ */ o(f, {
|
|
35
35
|
value: e,
|
|
36
36
|
children: e
|
|
37
37
|
}, e)) })]
|
|
38
|
-
}) :
|
|
39
|
-
id:
|
|
40
|
-
label:
|
|
41
|
-
fileName:
|
|
42
|
-
uploading:
|
|
43
|
-
disabled:
|
|
44
|
-
onSelect: (
|
|
45
|
-
}) : /* @__PURE__ */
|
|
46
|
-
id:
|
|
47
|
-
type: e.type
|
|
48
|
-
value:
|
|
49
|
-
onChange: (
|
|
50
|
-
disabled:
|
|
38
|
+
}) : t.type === "file" ? /* @__PURE__ */ o(_, {
|
|
39
|
+
id: C,
|
|
40
|
+
label: t.label,
|
|
41
|
+
fileName: g[t.key],
|
|
42
|
+
uploading: v === t.key,
|
|
43
|
+
disabled: b || x,
|
|
44
|
+
onSelect: (e) => y?.(t.key, e)
|
|
45
|
+
}) : /* @__PURE__ */ o(c, {
|
|
46
|
+
id: C,
|
|
47
|
+
type: e(t.type),
|
|
48
|
+
value: i[t.key] ?? "",
|
|
49
|
+
onChange: (e) => a(t.key, e.target.value),
|
|
50
|
+
disabled: b
|
|
51
51
|
})]
|
|
52
|
-
},
|
|
52
|
+
}, t.key);
|
|
53
53
|
};
|
|
54
|
-
return /* @__PURE__ */
|
|
54
|
+
return /* @__PURE__ */ o("div", {
|
|
55
55
|
className: "grid gap-6",
|
|
56
|
-
children:
|
|
57
|
-
let r = /* @__PURE__ */
|
|
56
|
+
children: C.map(({ start: e, label: t, fields: n }) => {
|
|
57
|
+
let r = /* @__PURE__ */ o("div", {
|
|
58
58
|
className: "grid gap-4 sm:grid-cols-2",
|
|
59
|
-
children: n.map(
|
|
59
|
+
children: n.map(w)
|
|
60
60
|
}, e);
|
|
61
|
-
return t ? /* @__PURE__ */
|
|
61
|
+
return t ? /* @__PURE__ */ s("fieldset", {
|
|
62
62
|
className: "min-w-0",
|
|
63
|
-
children: [/* @__PURE__ */
|
|
63
|
+
children: [/* @__PURE__ */ o("legend", {
|
|
64
64
|
className: "mb-3 text-sm font-semibold text-text-primary",
|
|
65
65
|
children: t
|
|
66
66
|
}), r]
|
|
@@ -68,39 +68,39 @@ function h({ fields: n, values: r, onChange: i, fileNames: h = {}, uploadingKey:
|
|
|
68
68
|
})
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
function
|
|
72
|
-
return /* @__PURE__ */
|
|
71
|
+
function _({ id: e, label: t, fileName: c, uploading: l, disabled: u, onSelect: d }) {
|
|
72
|
+
return /* @__PURE__ */ s("label", {
|
|
73
73
|
htmlFor: e,
|
|
74
|
-
className:
|
|
74
|
+
className: 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", u ? "cursor-not-allowed opacity-70" : "cursor-pointer hover:border-border-strong", l && "cursor-wait opacity-70"),
|
|
75
75
|
children: [
|
|
76
|
-
/* @__PURE__ */
|
|
76
|
+
/* @__PURE__ */ o("span", {
|
|
77
77
|
className: "inline-flex size-9 shrink-0 items-center justify-center rounded-full bg-[var(--color-accent-soft)] text-action-primary-text",
|
|
78
|
-
children: l ? /* @__PURE__ */
|
|
78
|
+
children: l ? /* @__PURE__ */ o(i, {
|
|
79
79
|
className: "size-5 animate-spin",
|
|
80
80
|
"aria-hidden": "true"
|
|
81
|
-
}) : c ? /* @__PURE__ */
|
|
81
|
+
}) : c ? /* @__PURE__ */ o(r, {
|
|
82
82
|
className: "size-5 text-status-success-text",
|
|
83
83
|
"aria-hidden": "true"
|
|
84
|
-
}) : /* @__PURE__ */ a
|
|
84
|
+
}) : /* @__PURE__ */ o(a, {
|
|
85
85
|
className: "size-5",
|
|
86
86
|
"aria-hidden": "true"
|
|
87
87
|
})
|
|
88
88
|
}),
|
|
89
|
-
/* @__PURE__ */
|
|
89
|
+
/* @__PURE__ */ s("span", {
|
|
90
90
|
className: "min-w-0 flex-1",
|
|
91
|
-
children: [/* @__PURE__ */
|
|
91
|
+
children: [/* @__PURE__ */ o("span", {
|
|
92
92
|
className: "block truncate text-sm font-medium text-text-primary",
|
|
93
93
|
children: l ? "Uploading…" : c || "Click to upload or drag & drop"
|
|
94
|
-
}), /* @__PURE__ */
|
|
94
|
+
}), /* @__PURE__ */ o("span", {
|
|
95
95
|
className: "mt-0.5 block text-xs text-text-muted",
|
|
96
96
|
children: c ? "Uploaded · click to replace" : "PDF, JPG or PNG"
|
|
97
97
|
})]
|
|
98
98
|
}),
|
|
99
|
-
/* @__PURE__ */
|
|
99
|
+
/* @__PURE__ */ o("input", {
|
|
100
100
|
id: e,
|
|
101
101
|
type: "file",
|
|
102
102
|
className: "sr-only",
|
|
103
|
-
"aria-label": `Upload ${
|
|
103
|
+
"aria-label": `Upload ${t}`,
|
|
104
104
|
disabled: u || l,
|
|
105
105
|
onChange: (e) => {
|
|
106
106
|
d(e.target.files), e.target.value = "";
|
|
@@ -109,6 +109,6 @@ function g({ id: e, label: s, fileName: c, uploading: l, disabled: u, onSelect:
|
|
|
109
109
|
]
|
|
110
110
|
});
|
|
111
111
|
}
|
|
112
|
-
export {
|
|
112
|
+
export { g as DynamicFormFields };
|
|
113
113
|
|
|
114
114
|
//# sourceMappingURL=DynamicFormFields.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DynamicFormFields.js","names":["DynamicFormFields","sections","visibleFormSections","fields","values","renderField","spanFull","field","fieldId","idPrefix","cn","Label","Textarea","onChange","
|
|
1
|
+
{"version":3,"file":"DynamicFormFields.js","names":["DynamicFormFields","sections","visibleFormSections","fields","values","renderField","spanFull","field","fieldId","idPrefix","cn","Label","Textarea","onChange","Select","v","SelectTrigger","SelectValue","SelectContent","SelectItem","opt","FileFieldControl","fileNames","uploadingKey","disabled","previewMode","onFileSelect","list","Input","dynamicInputType","sectionFields","fieldGrid","start","label","id","uploading","Loader2","fileName","CheckCircle2","UploadCloud","onSelect"],"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 { dynamicInputType, visibleFormSections, 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 sections = visibleFormSections(fields, values);\n\n if (sections.length === 0) return null;\n\n const renderField = (field: DynamicFormField) => {\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={dynamicInputType(field.type)}\n value={values[field.key] ?? ''}\n onChange={(e) => onChange(field.key, e.target.value)}\n disabled={disabled}\n />\n )}\n </div>\n );\n };\n\n return (\n <div className=\"grid gap-6\">\n {sections.map(({ start, label, fields: sectionFields }) => {\n const fieldGrid = (\n <div key={start} className=\"grid gap-4 sm:grid-cols-2\">\n {sectionFields.map(renderField)}\n </div>\n );\n return label ? (\n <fieldset key={start} className=\"min-w-0\">\n <legend className=\"mb-3 text-sm font-semibold text-text-primary\">{label}</legend>\n {fieldGrid}\n </fieldset>\n ) : (\n fieldGrid\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,SAAgBA,EAAkB,EAChC,WACA,WACA,aACA,eAAY,CAAC,GACb,kBAAe,MACf,iBACA,cAAW,IACX,iBAAc,IACd,cAAW,OACc;CACzB,IAAMC,IAAWC,EAAoBC,GAAQC,CAAM;CAEnD,IAAIH,EAAS,WAAW,GAAG,OAAO;CAElC,IAAMI,KAAe,MAA4B;EAC/C,IAAMC,IAAWC,EAAM,SAAS,cAAcA,EAAM,SAAS,SAAS,kBAAkB,IAClFC,IAAU,GAAGC,EAAS,GAAGF,EAAM;EACrC,OACE,kBAAC,OAAD;GAAqB,WAAWG,EAAG,gBA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let t = e ?? u, n = { limit: t.limit ?? u.limit };
|
|
65
65
|
return t.offset != null && (n.offset = t.offset), t.cursor != null && (n.cursor = t.cursor), n;
|
|
66
|
-
}, f = "\n id workspaceId code contactEmail contactPhone description isActive jurisdiction\n name tags createdAt updatedAt\n", p = "\n id workspaceId agencyId category currency eligibility feeAmount feeType formSchema\n name publishedAt requiredDocuments slaDays slug status summary tags createdAt updatedAt\n", m = "\n id workspaceId applicationId name status requirement rejectionReason\n file { id } createdAt updatedAt\n", h = "\n id workspaceId applicationId authorId body type createdAt updatedAt\n", g = "\n id workspaceId applicationId serviceId holderId title verificationCode status\n issuedAt expiresAt revokedAt revokeReason file { id } createdAt updatedAt\n", _ = "\n id workspaceId applicationId payerId amount currency status receiptNumber\n providerRef lineItems paidAt refundedAt createdAt updatedAt\n", v = "\n id workspaceId reference serviceId citizenId assignedToId status priority dueDate\n submittedAt decidedAt decisionReason tags createdAt updatedAt\n", ee = "\n id workspaceId applicationId ruleId notifiedSupervisorId reassignedToId breachOffsetHours createdAt\n", y = "\n id workspaceId title description category status priority location latitude longitude\n photoFileIds reporterId agencyId assignedToId resolution resolvedAt tags createdAt updatedAt\n", b = "\n id workspaceId citizenId name category status rejectionReason\n verifiedAt verifiedById expiresAt file { id } createdAt updatedAt\n", x = "current previous changePercent direction", S = () => {
|
|
66
|
+
}, f = "\n id workspaceId code contactEmail contactPhone description isActive jurisdiction\n name tags createdAt updatedAt\n", p = "\n id workspaceId agencyId category currency eligibility feeAmount feeType formSchema\n eligibilityRules { match conditions { fieldKey operator value } }\n name publishedAt requiredDocuments slaDays slug status summary tags createdAt updatedAt\n", m = "\n id workspaceId applicationId name status requirement rejectionReason\n file { id } createdAt updatedAt\n", h = "\n id workspaceId applicationId authorId body type createdAt updatedAt\n", g = "\n id workspaceId applicationId serviceId holderId title verificationCode status\n issuedAt expiresAt revokedAt revokeReason file { id } createdAt updatedAt\n", _ = "\n id workspaceId applicationId payerId amount currency status receiptNumber\n providerRef lineItems paidAt refundedAt createdAt updatedAt\n", v = "\n id workspaceId reference serviceId citizenId assignedToId status priority dueDate\n submittedAt decidedAt decisionReason tags createdAt updatedAt\n", ee = "\n id workspaceId applicationId ruleId notifiedSupervisorId reassignedToId breachOffsetHours createdAt\n", y = "\n id workspaceId title description category status priority location latitude longitude\n photoFileIds reporterId agencyId assignedToId resolution resolvedAt tags createdAt updatedAt\n", b = "\n id workspaceId citizenId name category status rejectionReason\n verifiedAt verifiedById expiresAt file { id } createdAt updatedAt\n", x = "current previous changePercent direction", S = () => {
|
|
67
67
|
let { apiGatewayUrl: t } = e();
|
|
68
68
|
return i({
|
|
69
69
|
queryKey: l.dashboard,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useGovApi.js","names":["isMutation","query","govQuery","mutating","clearGraphqlResponseCache","response","graphqlFetch","data","value","KEY","id","DEFAULT_PAGE","page","base","p","result","AGENCY_FIELDS","SERVICE_FIELDS","DOCUMENT_FIELDS","CASE_NOTE_FIELDS","PERMIT_FIELDS","PAYMENT_FIELDS","APPLICATION_FIELDS","SLA_ESCALATION_FIELDS","GRIEVANCE_FIELDS","WALLET_DOCUMENT_FIELDS","DASHBOARD_TREND_FIELDS","useGovDashboardSummary","useGovCitizenHub","useQuery","apiGatewayUrl","useGovApplicationSlaSummary","useGovApplicationsByService","useGovSlaSummaryByDesk","useGovCaseworkWorkload","serviceId","options","useGovSlaSummaryByRegion","useGovRunSlaEscalationSweep","qc","useQueryClient","useMutation","useGovAgencies","filters","useGovAgency","useGovCreateAgency","useGovUpdateAgency","vars","useGovArchiveAgency","useGovServices","surface","useSurface","useGovService","useGovCreateService","useGovUpdateService","useGovTransitionService","useGovApplications","useGovMyApplications","pagination","useGovApplication","field","useGovCreateApplication","useGovUpdateApplication","useGovSubmitApplication","useGovTransitionApplication","useGovAddDocument","useGovReviewDocument","useGovMyWalletDocuments","useGovAddMyWalletDocument","useGovUpdateMyWalletDocument","useGovDeleteMyWalletDocument","useGovAddMyDocumentFromWallet","useGovAddCaseNote","useGovReplyToMyApplication","useGovPayments","useGovCreatePayment","useGovMarkPaymentPaid","useGovRefundPayment","useGovPermits","useGovIssuePermit","useGovRevokePermit","useGovPermitPdf","useGovAttachPermitFile","useGovVerifyPermit","verificationCode","useGovGrievances","useGovMyGrievances","useGovGrievance","useGovReportGrievance","useGovUpdateGrievance","useGovTransitionGrievance"],"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 { useSurface } from '../surface/SurfaceContext';\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 GovWalletDocument,\n GovWalletDocumentCategory,\n GovWalletDocumentStatus,\n GovAddWalletDocumentInput,\n GovUpdateWalletDocumentInput,\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 GovDeskSlaSummary,\n GovRegionSlaSummary,\n GovDeskWorkload,\n PaginationInput,\n} from '../types';\n\n// ============================================================================\n// Transport\n// ============================================================================\n\nconst isMutation = (query: string): boolean => /^\\s*mutation\\b/.test(query);\n\nexport const 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 slaSummaryByDesk: ['govcitizenhub', 'sla-summary-by-desk'] as const,\n slaSummaryByRegion: ['govcitizenhub', 'sla-summary-by-region'] as const,\n caseworkWorkload: ['govcitizenhub', 'casework-workload'] 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 myApplications: ['govcitizenhub', 'my-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 walletDocuments: ['govcitizenhub', 'wallet-documents'] 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`. */\nexport const 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 SLA_ESCALATION_FIELDS = `\n id workspaceId applicationId ruleId notifiedSupervisorId reassignedToId breachOffsetHours createdAt\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\nconst WALLET_DOCUMENT_FIELDS = `\n id workspaceId citizenId name category status rejectionReason\n verifiedAt verifiedById expiresAt file { id } 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 * Reads `govSlaSummaryByDesk` — SLA compliance per assigned officer across\n * non-terminal applications, with `compliancePercent` withheld (null +\n * `isSuppressed`) below the svc's minimum group size. Officer ids are resolved\n * to names by the desk tile via the shared `useActorProfiles` directory.\n */\nexport const useGovSlaSummaryByDesk = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.slaSummaryByDesk,\n queryFn: async () => {\n const result = await govQuery<{ govSlaSummaryByDesk: GovDeskSlaSummary[] }>(\n `query GovSlaSummaryByDesk {\n govSlaSummaryByDesk {\n assignedToId\n total\n onTrack\n dueSoon\n overdue\n noDueDate\n compliancePercent\n isSuppressed\n }\n }`,\n {},\n apiGatewayUrl\n );\n return result.govSlaSummaryByDesk;\n },\n });\n};\n\n/**\n * Reads `govCaseworkWorkload` (BOFF-5792) — per-officer desk workload:\n * open (SLA-active) cases, cases due within 48 hours, and cases past due.\n * An optional serviceId narrows the snapshot to one service's queue.\n */\nexport const useGovCaseworkWorkload = (serviceId?: string, options: { enabled?: boolean } = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.caseworkWorkload, serviceId ?? null],\n enabled: options.enabled ?? true,\n queryFn: async () => {\n const result = await govQuery<{ govCaseworkWorkload: GovDeskWorkload[] }>(\n `query GovCaseworkWorkload($serviceId: ID) {\n govCaseworkWorkload(serviceId: $serviceId) { assigneeId openCount dueSoonCount overdueCount }\n }`,\n { serviceId },\n apiGatewayUrl\n );\n return result.govCaseworkWorkload;\n },\n });\n};\n\n/**\n * Reads `govSlaSummaryByRegion` — SLA compliance per administrative region\n * (application → service → agency → jurisdiction), with `compliancePercent`\n * withheld (null + `isSuppressed`) below the svc's minimum group size. Rows\n * whose agencies are only free-text-linked carry a null `regionId` and the\n * label in `regionName`.\n */\nexport const useGovSlaSummaryByRegion = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.slaSummaryByRegion,\n queryFn: async () => {\n const result = await govQuery<{ govSlaSummaryByRegion: GovRegionSlaSummary[] }>(\n `query GovSlaSummaryByRegion {\n govSlaSummaryByRegion {\n regionId\n regionName\n total\n onTrack\n dueSoon\n overdue\n noDueDate\n compliancePercent\n isSuppressed\n }\n }`,\n {},\n apiGatewayUrl\n );\n return result.govSlaSummaryByRegion;\n },\n });\n};\n\n/**\n * Runs `govRunSlaEscalationSweep` (BOFF-5792) — fires every active SLA\n * escalation rule once per at-risk case (notify supervisor + auto-reassign),\n * then invalidates casework queries so the UI reflects the reassignments.\n */\nexport const useGovRunSlaEscalationSweep = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async () => {\n const result = await govQuery<{\n govRunSlaEscalationSweep: {\n examinedCount: number;\n escalatedCount: number;\n notifiedCount: number;\n reassignedCount: number;\n };\n }>(\n `mutation GovRunSlaEscalationSweep {\n govRunSlaEscalationSweep { examinedCount escalatedCount notifiedCount reassignedCount }\n }`,\n {},\n apiGatewayUrl\n );\n return result.govRunSlaEscalationSweep;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.applicationSlaSummary });\n qc.invalidateQueries({ queryKey: KEY.caseworkWorkload });\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 // Citizens browse the PUBLISHED catalog through a self-scoped field (no staff\n // permission); officers keep the staff list with its agency/status filters.\n const surface = useSurface();\n return useQuery({\n queryKey: [...KEY.services, surface, filters],\n queryFn: async () => {\n if (surface === 'citizen') {\n const mine = await govQuery<{ govPublishedServices: GovConnection<GovService> }>(\n `query GovPublishedServices($category: GovServiceCategory, $pagination: PaginationInput) {\n govPublishedServices(category: $category, pagination: $pagination) {\n items { ${SERVICE_FIELDS} agency { id name } }\n pageInfo { cursor hasMore }\n }\n }`,\n { category: filters.category, pagination: page(filters.pagination) },\n apiGatewayUrl\n );\n return mine.govPublishedServices;\n }\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 const surface = useSurface();\n return useQuery({\n queryKey: [...KEY.service(id ?? ''), surface],\n enabled: Boolean(id),\n queryFn: async () => {\n if (surface === 'citizen') {\n const mine = await govQuery<{ govPublishedService: GovService }>(\n `query GovPublishedService($id: ID!) {\n govPublishedService(id: $id) { ${SERVICE_FIELDS} agency { ${AGENCY_FIELDS} } }\n }`,\n { id },\n apiGatewayUrl\n );\n return mine.govPublishedService;\n }\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 = (\n filters: ApplicationFilters = {},\n options: { enabled?: boolean } = {}\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.applications, filters],\n enabled: options.enabled ?? true,\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\n/**\n * Reads `govMyApplications` — the citizen's OWN applications.\n *\n * This is the Type-C self-scoped list (`@rbac(scopeType: \"self\")`): it takes no\n * identity argument, and the resolver's `citizenId = authenticated actor` filter\n * IS the access control, so any signed-in actor may call it. The subgraph's own\n * SDL is explicit that citizen-facing \"my requests\" UIs must use this instead of\n * `govListApplications(citizenId:)`, which is restricted to officer/agency roles\n * and therefore denies an ordinary citizen at the gateway.\n */\nexport const useGovMyApplications = (\n pagination?: PaginationInput,\n options: { enabled?: boolean } = {}\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.myApplications, pagination ?? null],\n enabled: options.enabled ?? true,\n queryFn: async () => {\n const result = await govQuery<{ govMyApplications: GovConnection<GovApplication> }>(\n `query GovMyApplications($pagination: PaginationInput) {\n govMyApplications(pagination: $pagination) {\n items { ${APPLICATION_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govMyApplications;\n },\n });\n};\n\nexport const useGovApplication = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n // Citizens read their own application (owner-filtered, internal notes\n // withheld server-side); officers read any application in the workspace.\n const surface = useSurface();\n const field = surface === 'citizen' ? 'govMyApplication' : 'govApplication';\n return useQuery({\n queryKey: [...KEY.application(id ?? ''), surface],\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<Record<string, GovApplication | null>>(\n `query GovApplication($id: ID!) {\n ${field}(id: $id) {\n ${APPLICATION_FIELDS}\n formData\n documents { ${DOCUMENT_FIELDS} }\n notes { ${CASE_NOTE_FIELDS} }\n permits { ${PERMIT_FIELDS} }\n slaEscalations { ${SLA_ESCALATION_FIELDS} }\n }\n }`,\n { id },\n apiGatewayUrl\n );\n return result[field] ?? null;\n },\n });\n};\n\nexport const useGovCreateApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n const field = useSurface() === 'citizen' ? 'govCreateMyApplication' : 'govCreateApplication';\n return useMutation({\n mutationFn: async (input: GovCreateApplicationInput) => {\n const result = await govQuery<Record<string, GovApplication>>(\n `mutation GovCreateApplication($input: GovCreateApplicationInput!) {\n ${field}(input: $input) { ${APPLICATION_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result[field] as GovApplication;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.myApplications });\n },\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.myApplications });\n qc.invalidateQueries({ queryKey: KEY.application(data.id) });\n },\n });\n};\n\nexport const useGovSubmitApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n const field = useSurface() === 'citizen' ? 'govSubmitMyApplication' : 'govSubmitApplication';\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<Record<string, GovApplication>>(\n `mutation GovSubmitApplication($id: ID!) {\n ${field}(id: $id) { ${APPLICATION_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result[field] as GovApplication;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.myApplications });\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.myApplications });\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 const field = useSurface() === 'citizen' ? 'govAddMyDocument' : 'govAddDocument';\n return useMutation({\n mutationFn: async (input: GovAddDocumentInput) => {\n const result = await govQuery<Record<string, GovDocument>>(\n `mutation GovAddDocument($input: GovAddDocumentInput!) {\n ${field}(input: $input) { ${DOCUMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result[field] as GovDocument;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.myApplications });\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// Wallet documents (BOFF-5796) — citizen-owned, reusable across applications\n// ============================================================================\n\n/**\n * The calling citizen's own document wallet (`govMyWalletDocuments`,\n * Type C self-scoped: the svc filters by the authenticated actor, so this\n * hook never takes a citizenId).\n */\nexport const useGovMyWalletDocuments = (\n filters: {\n category?: GovWalletDocumentCategory | null;\n status?: GovWalletDocumentStatus | null;\n pagination?: PaginationInput;\n } = {},\n options: { enabled?: boolean } = {}\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [\n ...KEY.walletDocuments,\n filters.category ?? null,\n filters.status ?? null,\n filters.pagination ?? null,\n ],\n enabled: options.enabled ?? true,\n queryFn: async () => {\n const result = await govQuery<{ govMyWalletDocuments: GovConnection<GovWalletDocument> }>(\n `query GovMyWalletDocuments($category: GovWalletDocumentCategory, $status: GovWalletDocumentStatus, $pagination: PaginationInput) {\n govMyWalletDocuments(category: $category, status: $status, pagination: $pagination) {\n items { ${WALLET_DOCUMENT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n category: filters.category,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govMyWalletDocuments;\n },\n });\n};\n\nexport const useGovAddMyWalletDocument = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovAddWalletDocumentInput) => {\n const result = await govQuery<{ govAddMyWalletDocument: GovWalletDocument }>(\n `mutation GovAddMyWalletDocument($input: GovAddWalletDocumentInput!) {\n govAddMyWalletDocument(input: $input) { ${WALLET_DOCUMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govAddMyWalletDocument;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.walletDocuments }),\n });\n};\n\nexport const useGovUpdateMyWalletDocument = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateWalletDocumentInput }) => {\n const result = await govQuery<{ govUpdateMyWalletDocument: GovWalletDocument }>(\n `mutation GovUpdateMyWalletDocument($id: ID!, $input: GovUpdateWalletDocumentInput!) {\n govUpdateMyWalletDocument(id: $id, input: $input) { ${WALLET_DOCUMENT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateMyWalletDocument;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.walletDocuments }),\n });\n};\n\nexport const useGovDeleteMyWalletDocument = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteMyWalletDocument: boolean }>(\n `mutation GovDeleteMyWalletDocument($id: ID!) {\n govDeleteMyWalletDocument(id: $id)\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteMyWalletDocument;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.walletDocuments }),\n });\n};\n\n/**\n * Pre-fill an application document upload from the caller's own wallet\n * (`govAddMyDocumentFromWallet`, Type B self-scoped): copies the wallet\n * document's file reference onto a new GovDocument on the citizen's own\n * application.\n */\nexport const useGovAddMyDocumentFromWallet = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n applicationId: string;\n walletDocumentId: string;\n requirement?: string | null;\n }) => {\n const result = await govQuery<{ govAddMyDocumentFromWallet: GovDocument }>(\n `mutation GovAddMyDocumentFromWallet($applicationId: ID!, $walletDocumentId: ID!, $requirement: String) {\n govAddMyDocumentFromWallet(\n applicationId: $applicationId\n walletDocumentId: $walletDocumentId\n requirement: $requirement\n ) { ${DOCUMENT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govAddMyDocumentFromWallet;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n qc.invalidateQueries({ queryKey: KEY.myApplications });\n qc.invalidateQueries({ queryKey: KEY.walletDocuments });\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 * Citizen reply on their own application's thread (`govReplyToMyApplication`,\n * stored as a CITIZEN_MESSAGE note). Officers use `useGovAddCaseNote` instead.\n */\nexport const useGovReplyToMyApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { applicationId: string; body: string }) => {\n const result = await govQuery<{ govReplyToMyApplication: GovCaseNote }>(\n `mutation GovReplyToMyApplication($applicationId: ID!, $body: String!) {\n govReplyToMyApplication(applicationId: $applicationId, body: $body) { ${CASE_NOTE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govReplyToMyApplication;\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 = (\n filters: PaymentFilters = {},\n options: { enabled?: boolean } = {}\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.payments, filters],\n enabled: options.enabled ?? true,\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 * Render the permit as a downloadable/printable PDF (BOFF-4060). A mutation\n * (not a query) even though the backend field is a GraphQL Query: it's a\n * client-triggered, non-cached action fired from a \"Download\" / \"Print\"\n * button, exactly like the `getBlob` thunk in the platform's Save-to-Files\n * pattern — the bytes are only assembled when the officer actually clicks.\n */\nexport const useGovPermitPdf = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{\n govPermitPdf: { pdfBase64: string; filename: string; generatedAt: string };\n }>(\n `query GovPermitPdf($id: ID!) {\n govPermitPdf(id: $id) { pdfBase64 filename generatedAt }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govPermitPdf;\n },\n });\n};\n\n/**\n * Persist a `wspace-files-svc` File reference onto an issued permit once the\n * client has saved the rendered PDF via the platform's Save-to-Files flow.\n */\nexport const useGovAttachPermitFile = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; fileId: string }) => {\n const result = await govQuery<{ govAttachPermitFile: GovPermit }>(\n `mutation GovAttachPermitFile($id: ID!, $fileId: ID!) {\n govAttachPermitFile(id: $id, fileId: $fileId) { ${PERMIT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govAttachPermitFile;\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 = (\n filters: GrievanceFilters = {},\n options: { enabled?: boolean } = {}\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.grievances, filters],\n enabled: options.enabled ?? true,\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\n/**\n * Reads `govMyGrievances` — the citizen's OWN grievances (Type-C self scope: no\n * identity argument, the resolver filters by the authenticated actor). The\n * citizen portal uses this instead of `govListGrievances`, which is staff-only.\n */\nexport const useGovMyGrievances = (\n pagination?: PaginationInput,\n options: { enabled?: boolean } = {}\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.grievances, 'mine', pagination ?? null],\n enabled: options.enabled ?? true,\n queryFn: async () => {\n const result = await govQuery<{ govMyGrievances: GovConnection<GovGrievance> }>(\n `query GovMyGrievances($pagination: PaginationInput) {\n govMyGrievances(pagination: $pagination) {\n items { ${GRIEVANCE_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govMyGrievances;\n },\n });\n};\n\nexport const useGovGrievance = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const surface = useSurface();\n const field = surface === 'citizen' ? 'govMyGrievance' : 'govGrievance';\n return useQuery({\n queryKey: [...KEY.grievance(id ?? ''), surface],\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<Record<string, GovGrievance | null>>(\n `query GovGrievance($id: ID!) {\n ${field}(id: $id) { ${GRIEVANCE_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result[field] ?? null;\n },\n });\n};\n\nexport const useGovReportGrievance = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n const field = useSurface() === 'citizen' ? 'govReportMyGrievance' : 'govReportGrievance';\n return useMutation({\n mutationFn: async (input: GovReportGrievanceInput) => {\n const result = await govQuery<Record<string, GovGrievance>>(\n `mutation GovReportGrievance($input: GovReportGrievanceInput!) {\n ${field}(input: $input) { ${GRIEVANCE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result[field] as GovGrievance;\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":";;;;;;;AAsEA,IAAM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AE,CAAC;EAC3D;CACF,CAAC;AACH,GAEamF,WAAkC;CAC7C,IAAM,EAAE,qBAAkB9D,EAAiB,GACrCW,IAAKC,EAAe;CAC1B,OAAOC,EAAY;EACjB,YAAY,OAAO,OAYV,MAPcvC,EACnB;wFACgFsB,EAAiB;YAEjGuB,GACAjB,CACF,EAAA,CACc;EAEhB,YAAY,MAAS;GAEnB,AADAS,EAAG,kBAAkB,EAAE,UAAU9B,EAAI,WAAW,CAAC,GACjD8B,EAAG,kBAAkB,EAAE,UAAU9B,EAAI,UAAUF,EAAK,EAAE,EAAE,CAAC;EAC3D;CACF,CAAC;AACH"}
|
|
1
|
+
{"version":3,"file":"useGovApi.js","names":["isMutation","query","govQuery","mutating","clearGraphqlResponseCache","response","graphqlFetch","data","value","KEY","id","DEFAULT_PAGE","page","base","p","result","AGENCY_FIELDS","SERVICE_FIELDS","DOCUMENT_FIELDS","CASE_NOTE_FIELDS","PERMIT_FIELDS","PAYMENT_FIELDS","APPLICATION_FIELDS","SLA_ESCALATION_FIELDS","GRIEVANCE_FIELDS","WALLET_DOCUMENT_FIELDS","DASHBOARD_TREND_FIELDS","useGovDashboardSummary","useGovCitizenHub","useQuery","apiGatewayUrl","useGovApplicationSlaSummary","useGovApplicationsByService","useGovSlaSummaryByDesk","useGovCaseworkWorkload","serviceId","options","useGovSlaSummaryByRegion","useGovRunSlaEscalationSweep","qc","useQueryClient","useMutation","useGovAgencies","filters","useGovAgency","useGovCreateAgency","useGovUpdateAgency","vars","useGovArchiveAgency","useGovServices","surface","useSurface","useGovService","useGovCreateService","useGovUpdateService","useGovTransitionService","useGovApplications","useGovMyApplications","pagination","useGovApplication","field","useGovCreateApplication","useGovUpdateApplication","useGovSubmitApplication","useGovTransitionApplication","useGovAddDocument","useGovReviewDocument","useGovMyWalletDocuments","useGovAddMyWalletDocument","useGovUpdateMyWalletDocument","useGovDeleteMyWalletDocument","useGovAddMyDocumentFromWallet","useGovAddCaseNote","useGovReplyToMyApplication","useGovPayments","useGovCreatePayment","useGovMarkPaymentPaid","useGovRefundPayment","useGovPermits","useGovIssuePermit","useGovRevokePermit","useGovPermitPdf","useGovAttachPermitFile","useGovVerifyPermit","verificationCode","useGovGrievances","useGovMyGrievances","useGovGrievance","useGovReportGrievance","useGovUpdateGrievance","useGovTransitionGrievance"],"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 { useSurface } from '../surface/SurfaceContext';\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 GovWalletDocument,\n GovWalletDocumentCategory,\n GovWalletDocumentStatus,\n GovAddWalletDocumentInput,\n GovUpdateWalletDocumentInput,\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 GovDeskSlaSummary,\n GovRegionSlaSummary,\n GovDeskWorkload,\n PaginationInput,\n} from '../types';\n\n// ============================================================================\n// Transport\n// ============================================================================\n\nconst isMutation = (query: string): boolean => /^\\s*mutation\\b/.test(query);\n\nexport const 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 slaSummaryByDesk: ['govcitizenhub', 'sla-summary-by-desk'] as const,\n slaSummaryByRegion: ['govcitizenhub', 'sla-summary-by-region'] as const,\n caseworkWorkload: ['govcitizenhub', 'casework-workload'] 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 myApplications: ['govcitizenhub', 'my-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 walletDocuments: ['govcitizenhub', 'wallet-documents'] 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`. */\nexport const 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 eligibilityRules { match conditions { fieldKey operator value } }\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 SLA_ESCALATION_FIELDS = `\n id workspaceId applicationId ruleId notifiedSupervisorId reassignedToId breachOffsetHours createdAt\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\nconst WALLET_DOCUMENT_FIELDS = `\n id workspaceId citizenId name category status rejectionReason\n verifiedAt verifiedById expiresAt file { id } 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 * Reads `govSlaSummaryByDesk` — SLA compliance per assigned officer across\n * non-terminal applications, with `compliancePercent` withheld (null +\n * `isSuppressed`) below the svc's minimum group size. Officer ids are resolved\n * to names by the desk tile via the shared `useActorProfiles` directory.\n */\nexport const useGovSlaSummaryByDesk = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.slaSummaryByDesk,\n queryFn: async () => {\n const result = await govQuery<{ govSlaSummaryByDesk: GovDeskSlaSummary[] }>(\n `query GovSlaSummaryByDesk {\n govSlaSummaryByDesk {\n assignedToId\n total\n onTrack\n dueSoon\n overdue\n noDueDate\n compliancePercent\n isSuppressed\n }\n }`,\n {},\n apiGatewayUrl\n );\n return result.govSlaSummaryByDesk;\n },\n });\n};\n\n/**\n * Reads `govCaseworkWorkload` (BOFF-5792) — per-officer desk workload:\n * open (SLA-active) cases, cases due within 48 hours, and cases past due.\n * An optional serviceId narrows the snapshot to one service's queue.\n */\nexport const useGovCaseworkWorkload = (serviceId?: string, options: { enabled?: boolean } = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.caseworkWorkload, serviceId ?? null],\n enabled: options.enabled ?? true,\n queryFn: async () => {\n const result = await govQuery<{ govCaseworkWorkload: GovDeskWorkload[] }>(\n `query GovCaseworkWorkload($serviceId: ID) {\n govCaseworkWorkload(serviceId: $serviceId) { assigneeId openCount dueSoonCount overdueCount }\n }`,\n { serviceId },\n apiGatewayUrl\n );\n return result.govCaseworkWorkload;\n },\n });\n};\n\n/**\n * Reads `govSlaSummaryByRegion` — SLA compliance per administrative region\n * (application → service → agency → jurisdiction), with `compliancePercent`\n * withheld (null + `isSuppressed`) below the svc's minimum group size. Rows\n * whose agencies are only free-text-linked carry a null `regionId` and the\n * label in `regionName`.\n */\nexport const useGovSlaSummaryByRegion = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.slaSummaryByRegion,\n queryFn: async () => {\n const result = await govQuery<{ govSlaSummaryByRegion: GovRegionSlaSummary[] }>(\n `query GovSlaSummaryByRegion {\n govSlaSummaryByRegion {\n regionId\n regionName\n total\n onTrack\n dueSoon\n overdue\n noDueDate\n compliancePercent\n isSuppressed\n }\n }`,\n {},\n apiGatewayUrl\n );\n return result.govSlaSummaryByRegion;\n },\n });\n};\n\n/**\n * Runs `govRunSlaEscalationSweep` (BOFF-5792) — fires every active SLA\n * escalation rule once per at-risk case (notify supervisor + auto-reassign),\n * then invalidates casework queries so the UI reflects the reassignments.\n */\nexport const useGovRunSlaEscalationSweep = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async () => {\n const result = await govQuery<{\n govRunSlaEscalationSweep: {\n examinedCount: number;\n escalatedCount: number;\n notifiedCount: number;\n reassignedCount: number;\n };\n }>(\n `mutation GovRunSlaEscalationSweep {\n govRunSlaEscalationSweep { examinedCount escalatedCount notifiedCount reassignedCount }\n }`,\n {},\n apiGatewayUrl\n );\n return result.govRunSlaEscalationSweep;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.applicationSlaSummary });\n qc.invalidateQueries({ queryKey: KEY.caseworkWorkload });\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 // Citizens browse the PUBLISHED catalog through a self-scoped field (no staff\n // permission); officers keep the staff list with its agency/status filters.\n const surface = useSurface();\n return useQuery({\n queryKey: [...KEY.services, surface, filters],\n queryFn: async () => {\n if (surface === 'citizen') {\n const mine = await govQuery<{ govPublishedServices: GovConnection<GovService> }>(\n `query GovPublishedServices($category: GovServiceCategory, $pagination: PaginationInput) {\n govPublishedServices(category: $category, pagination: $pagination) {\n items { ${SERVICE_FIELDS} agency { id name } }\n pageInfo { cursor hasMore }\n }\n }`,\n { category: filters.category, pagination: page(filters.pagination) },\n apiGatewayUrl\n );\n return mine.govPublishedServices;\n }\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 const surface = useSurface();\n return useQuery({\n queryKey: [...KEY.service(id ?? ''), surface],\n enabled: Boolean(id),\n queryFn: async () => {\n if (surface === 'citizen') {\n const mine = await govQuery<{ govPublishedService: GovService }>(\n `query GovPublishedService($id: ID!) {\n govPublishedService(id: $id) { ${SERVICE_FIELDS} agency { ${AGENCY_FIELDS} } }\n }`,\n { id },\n apiGatewayUrl\n );\n return mine.govPublishedService;\n }\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 = (\n filters: ApplicationFilters = {},\n options: { enabled?: boolean } = {}\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.applications, filters],\n enabled: options.enabled ?? true,\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\n/**\n * Reads `govMyApplications` — the citizen's OWN applications.\n *\n * This is the Type-C self-scoped list (`@rbac(scopeType: \"self\")`): it takes no\n * identity argument, and the resolver's `citizenId = authenticated actor` filter\n * IS the access control, so any signed-in actor may call it. The subgraph's own\n * SDL is explicit that citizen-facing \"my requests\" UIs must use this instead of\n * `govListApplications(citizenId:)`, which is restricted to officer/agency roles\n * and therefore denies an ordinary citizen at the gateway.\n */\nexport const useGovMyApplications = (\n pagination?: PaginationInput,\n options: { enabled?: boolean } = {}\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.myApplications, pagination ?? null],\n enabled: options.enabled ?? true,\n queryFn: async () => {\n const result = await govQuery<{ govMyApplications: GovConnection<GovApplication> }>(\n `query GovMyApplications($pagination: PaginationInput) {\n govMyApplications(pagination: $pagination) {\n items { ${APPLICATION_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govMyApplications;\n },\n });\n};\n\nexport const useGovApplication = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n // Citizens read their own application (owner-filtered, internal notes\n // withheld server-side); officers read any application in the workspace.\n const surface = useSurface();\n const field = surface === 'citizen' ? 'govMyApplication' : 'govApplication';\n return useQuery({\n queryKey: [...KEY.application(id ?? ''), surface],\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<Record<string, GovApplication | null>>(\n `query GovApplication($id: ID!) {\n ${field}(id: $id) {\n ${APPLICATION_FIELDS}\n formData\n documents { ${DOCUMENT_FIELDS} }\n notes { ${CASE_NOTE_FIELDS} }\n permits { ${PERMIT_FIELDS} }\n slaEscalations { ${SLA_ESCALATION_FIELDS} }\n }\n }`,\n { id },\n apiGatewayUrl\n );\n return result[field] ?? null;\n },\n });\n};\n\nexport const useGovCreateApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n const field = useSurface() === 'citizen' ? 'govCreateMyApplication' : 'govCreateApplication';\n return useMutation({\n mutationFn: async (input: GovCreateApplicationInput) => {\n const result = await govQuery<Record<string, GovApplication>>(\n `mutation GovCreateApplication($input: GovCreateApplicationInput!) {\n ${field}(input: $input) { ${APPLICATION_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result[field] as GovApplication;\n },\n onSuccess: () => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.myApplications });\n },\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.myApplications });\n qc.invalidateQueries({ queryKey: KEY.application(data.id) });\n },\n });\n};\n\nexport const useGovSubmitApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n const field = useSurface() === 'citizen' ? 'govSubmitMyApplication' : 'govSubmitApplication';\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<Record<string, GovApplication>>(\n `mutation GovSubmitApplication($id: ID!) {\n ${field}(id: $id) { ${APPLICATION_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result[field] as GovApplication;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.myApplications });\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.myApplications });\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 const field = useSurface() === 'citizen' ? 'govAddMyDocument' : 'govAddDocument';\n return useMutation({\n mutationFn: async (input: GovAddDocumentInput) => {\n const result = await govQuery<Record<string, GovDocument>>(\n `mutation GovAddDocument($input: GovAddDocumentInput!) {\n ${field}(input: $input) { ${DOCUMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result[field] as GovDocument;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.myApplications });\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// Wallet documents (BOFF-5796) — citizen-owned, reusable across applications\n// ============================================================================\n\n/**\n * The calling citizen's own document wallet (`govMyWalletDocuments`,\n * Type C self-scoped: the svc filters by the authenticated actor, so this\n * hook never takes a citizenId).\n */\nexport const useGovMyWalletDocuments = (\n filters: {\n category?: GovWalletDocumentCategory | null;\n status?: GovWalletDocumentStatus | null;\n pagination?: PaginationInput;\n } = {},\n options: { enabled?: boolean } = {}\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [\n ...KEY.walletDocuments,\n filters.category ?? null,\n filters.status ?? null,\n filters.pagination ?? null,\n ],\n enabled: options.enabled ?? true,\n queryFn: async () => {\n const result = await govQuery<{ govMyWalletDocuments: GovConnection<GovWalletDocument> }>(\n `query GovMyWalletDocuments($category: GovWalletDocumentCategory, $status: GovWalletDocumentStatus, $pagination: PaginationInput) {\n govMyWalletDocuments(category: $category, status: $status, pagination: $pagination) {\n items { ${WALLET_DOCUMENT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n category: filters.category,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govMyWalletDocuments;\n },\n });\n};\n\nexport const useGovAddMyWalletDocument = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovAddWalletDocumentInput) => {\n const result = await govQuery<{ govAddMyWalletDocument: GovWalletDocument }>(\n `mutation GovAddMyWalletDocument($input: GovAddWalletDocumentInput!) {\n govAddMyWalletDocument(input: $input) { ${WALLET_DOCUMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govAddMyWalletDocument;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.walletDocuments }),\n });\n};\n\nexport const useGovUpdateMyWalletDocument = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateWalletDocumentInput }) => {\n const result = await govQuery<{ govUpdateMyWalletDocument: GovWalletDocument }>(\n `mutation GovUpdateMyWalletDocument($id: ID!, $input: GovUpdateWalletDocumentInput!) {\n govUpdateMyWalletDocument(id: $id, input: $input) { ${WALLET_DOCUMENT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateMyWalletDocument;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.walletDocuments }),\n });\n};\n\nexport const useGovDeleteMyWalletDocument = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govDeleteMyWalletDocument: boolean }>(\n `mutation GovDeleteMyWalletDocument($id: ID!) {\n govDeleteMyWalletDocument(id: $id)\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govDeleteMyWalletDocument;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.walletDocuments }),\n });\n};\n\n/**\n * Pre-fill an application document upload from the caller's own wallet\n * (`govAddMyDocumentFromWallet`, Type B self-scoped): copies the wallet\n * document's file reference onto a new GovDocument on the citizen's own\n * application.\n */\nexport const useGovAddMyDocumentFromWallet = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n applicationId: string;\n walletDocumentId: string;\n requirement?: string | null;\n }) => {\n const result = await govQuery<{ govAddMyDocumentFromWallet: GovDocument }>(\n `mutation GovAddMyDocumentFromWallet($applicationId: ID!, $walletDocumentId: ID!, $requirement: String) {\n govAddMyDocumentFromWallet(\n applicationId: $applicationId\n walletDocumentId: $walletDocumentId\n requirement: $requirement\n ) { ${DOCUMENT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govAddMyDocumentFromWallet;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n qc.invalidateQueries({ queryKey: KEY.myApplications });\n qc.invalidateQueries({ queryKey: KEY.walletDocuments });\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 * Citizen reply on their own application's thread (`govReplyToMyApplication`,\n * stored as a CITIZEN_MESSAGE note). Officers use `useGovAddCaseNote` instead.\n */\nexport const useGovReplyToMyApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { applicationId: string; body: string }) => {\n const result = await govQuery<{ govReplyToMyApplication: GovCaseNote }>(\n `mutation GovReplyToMyApplication($applicationId: ID!, $body: String!) {\n govReplyToMyApplication(applicationId: $applicationId, body: $body) { ${CASE_NOTE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govReplyToMyApplication;\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 = (\n filters: PaymentFilters = {},\n options: { enabled?: boolean } = {}\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.payments, filters],\n enabled: options.enabled ?? true,\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 * Render the permit as a downloadable/printable PDF (BOFF-4060). A mutation\n * (not a query) even though the backend field is a GraphQL Query: it's a\n * client-triggered, non-cached action fired from a \"Download\" / \"Print\"\n * button, exactly like the `getBlob` thunk in the platform's Save-to-Files\n * pattern — the bytes are only assembled when the officer actually clicks.\n */\nexport const useGovPermitPdf = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{\n govPermitPdf: { pdfBase64: string; filename: string; generatedAt: string };\n }>(\n `query GovPermitPdf($id: ID!) {\n govPermitPdf(id: $id) { pdfBase64 filename generatedAt }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govPermitPdf;\n },\n });\n};\n\n/**\n * Persist a `wspace-files-svc` File reference onto an issued permit once the\n * client has saved the rendered PDF via the platform's Save-to-Files flow.\n */\nexport const useGovAttachPermitFile = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; fileId: string }) => {\n const result = await govQuery<{ govAttachPermitFile: GovPermit }>(\n `mutation GovAttachPermitFile($id: ID!, $fileId: ID!) {\n govAttachPermitFile(id: $id, fileId: $fileId) { ${PERMIT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govAttachPermitFile;\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 = (\n filters: GrievanceFilters = {},\n options: { enabled?: boolean } = {}\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.grievances, filters],\n enabled: options.enabled ?? true,\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\n/**\n * Reads `govMyGrievances` — the citizen's OWN grievances (Type-C self scope: no\n * identity argument, the resolver filters by the authenticated actor). The\n * citizen portal uses this instead of `govListGrievances`, which is staff-only.\n */\nexport const useGovMyGrievances = (\n pagination?: PaginationInput,\n options: { enabled?: boolean } = {}\n) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.grievances, 'mine', pagination ?? null],\n enabled: options.enabled ?? true,\n queryFn: async () => {\n const result = await govQuery<{ govMyGrievances: GovConnection<GovGrievance> }>(\n `query GovMyGrievances($pagination: PaginationInput) {\n govMyGrievances(pagination: $pagination) {\n items { ${GRIEVANCE_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n { pagination: page(pagination) },\n apiGatewayUrl\n );\n return result.govMyGrievances;\n },\n });\n};\n\nexport const useGovGrievance = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const surface = useSurface();\n const field = surface === 'citizen' ? 'govMyGrievance' : 'govGrievance';\n return useQuery({\n queryKey: [...KEY.grievance(id ?? ''), surface],\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<Record<string, GovGrievance | null>>(\n `query GovGrievance($id: ID!) {\n ${field}(id: $id) { ${GRIEVANCE_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result[field] ?? null;\n },\n });\n};\n\nexport const useGovReportGrievance = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n const field = useSurface() === 'citizen' ? 'govReportMyGrievance' : 'govReportGrievance';\n return useMutation({\n mutationFn: async (input: GovReportGrievanceInput) => {\n const result = await govQuery<Record<string, GovGrievance>>(\n `mutation GovReportGrievance($input: GovReportGrievanceInput!) {\n ${field}(input: $input) { ${GRIEVANCE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result[field] as GovGrievance;\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":";;;;;;;AAsEA,IAAMA,KAAc,M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