@burdenoff/microfe-govcitizenhub 2026.705.1 → 2026.705.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.
Files changed (69) hide show
  1. package/dist/govcitizenhub/components/Avatar.js +55 -0
  2. package/dist/govcitizenhub/components/Avatar.js.map +1 -0
  3. package/dist/govcitizenhub/components/DocumentUploadField.js +95 -45
  4. package/dist/govcitizenhub/components/DocumentUploadField.js.map +1 -1
  5. package/dist/govcitizenhub/components/FilterTabs.js +5 -4
  6. package/dist/govcitizenhub/components/FilterTabs.js.map +1 -1
  7. package/dist/govcitizenhub/components/KeyValueList.js +23 -0
  8. package/dist/govcitizenhub/components/KeyValueList.js.map +1 -0
  9. package/dist/govcitizenhub/components/MetricsCard.js +51 -26
  10. package/dist/govcitizenhub/components/MetricsCard.js.map +1 -1
  11. package/dist/govcitizenhub/components/PageLayout.js +81 -51
  12. package/dist/govcitizenhub/components/PageLayout.js.map +1 -1
  13. package/dist/govcitizenhub/components/Pagination.js +41 -19
  14. package/dist/govcitizenhub/components/Pagination.js.map +1 -1
  15. package/dist/govcitizenhub/components/SectionCard.js +31 -0
  16. package/dist/govcitizenhub/components/SectionCard.js.map +1 -0
  17. package/dist/govcitizenhub/components/SlaBadge.js +71 -0
  18. package/dist/govcitizenhub/components/SlaBadge.js.map +1 -0
  19. package/dist/govcitizenhub/components/StateViews.js +1 -16
  20. package/dist/govcitizenhub/components/StateViews.js.map +1 -1
  21. package/dist/govcitizenhub/components/StatusBadge.js +23 -10
  22. package/dist/govcitizenhub/components/StatusBadge.js.map +1 -1
  23. package/dist/govcitizenhub/components/StatusStepper.js +55 -0
  24. package/dist/govcitizenhub/components/StatusStepper.js.map +1 -0
  25. package/dist/govcitizenhub/components/SummaryStrip.js +54 -0
  26. package/dist/govcitizenhub/components/SummaryStrip.js.map +1 -0
  27. package/dist/govcitizenhub/components/TagInput.js +2 -2
  28. package/dist/govcitizenhub/components/TagInput.js.map +1 -1
  29. package/dist/govcitizenhub/components/Timeline.js +61 -0
  30. package/dist/govcitizenhub/components/Timeline.js.map +1 -0
  31. package/dist/govcitizenhub/hooks/useFiles.js +50 -22
  32. package/dist/govcitizenhub/hooks/useFiles.js.map +1 -1
  33. package/dist/govcitizenhub/hooks/useGovApi.js +40 -31
  34. package/dist/govcitizenhub/hooks/useGovApi.js.map +1 -1
  35. package/dist/govcitizenhub/pages/DashboardPage.js +118 -50
  36. package/dist/govcitizenhub/pages/DashboardPage.js.map +1 -1
  37. package/dist/govcitizenhub/pages/agencies/AgenciesPage.js +258 -137
  38. package/dist/govcitizenhub/pages/agencies/AgenciesPage.js.map +1 -1
  39. package/dist/govcitizenhub/pages/agencies/AgencyFormDialog.js +103 -90
  40. package/dist/govcitizenhub/pages/agencies/AgencyFormDialog.js.map +1 -1
  41. package/dist/govcitizenhub/pages/applications/ApplicationDetailPage.js +493 -397
  42. package/dist/govcitizenhub/pages/applications/ApplicationDetailPage.js.map +1 -1
  43. package/dist/govcitizenhub/pages/applications/ApplicationsPage.js +266 -80
  44. package/dist/govcitizenhub/pages/applications/ApplicationsPage.js.map +1 -1
  45. package/dist/govcitizenhub/pages/applications/NewApplicationPage.js +412 -174
  46. package/dist/govcitizenhub/pages/applications/NewApplicationPage.js.map +1 -1
  47. package/dist/govcitizenhub/pages/documents/DocumentsPage.js +313 -115
  48. package/dist/govcitizenhub/pages/documents/DocumentsPage.js.map +1 -1
  49. package/dist/govcitizenhub/pages/grievances/GrievanceDetailPage.js +379 -176
  50. package/dist/govcitizenhub/pages/grievances/GrievanceDetailPage.js.map +1 -1
  51. package/dist/govcitizenhub/pages/grievances/GrievancesPage.js +275 -184
  52. package/dist/govcitizenhub/pages/grievances/GrievancesPage.js.map +1 -1
  53. package/dist/govcitizenhub/pages/payments/PaymentsPage.js +251 -133
  54. package/dist/govcitizenhub/pages/payments/PaymentsPage.js.map +1 -1
  55. package/dist/govcitizenhub/pages/permits/IssuePermitDialog.js +175 -105
  56. package/dist/govcitizenhub/pages/permits/IssuePermitDialog.js.map +1 -1
  57. package/dist/govcitizenhub/pages/permits/PermitsPage.js +204 -110
  58. package/dist/govcitizenhub/pages/permits/PermitsPage.js.map +1 -1
  59. package/dist/govcitizenhub/pages/permits/VerifyPermitPage.js +290 -113
  60. package/dist/govcitizenhub/pages/permits/VerifyPermitPage.js.map +1 -1
  61. package/dist/govcitizenhub/pages/services/FormFieldBuilder.js +301 -0
  62. package/dist/govcitizenhub/pages/services/FormFieldBuilder.js.map +1 -0
  63. package/dist/govcitizenhub/pages/services/ServiceDetailPage.js +248 -163
  64. package/dist/govcitizenhub/pages/services/ServiceDetailPage.js.map +1 -1
  65. package/dist/govcitizenhub/pages/services/ServiceFormDialog.js +183 -149
  66. package/dist/govcitizenhub/pages/services/ServiceFormDialog.js.map +1 -1
  67. package/dist/govcitizenhub/pages/services/ServicesPage.js +228 -137
  68. package/dist/govcitizenhub/pages/services/ServicesPage.js.map +1 -1
  69. package/package.json +1 -1
@@ -1 +1 @@
1
- {"version":3,"file":"useGovApi.js","names":[],"sources":["../../../src/govcitizenhub/hooks/useGovApi.ts"],"sourcesContent":["/**\n * GovCitizenHub API hooks\n * @module govcitizenhub/hooks\n *\n * React-Query hooks wired DIRECTLY to the real `wspace-govcitizenhub-svc`\n * federated GraphQL contract (the `gov*` operations). Every query/mutation below\n * uses an inline gql string whose fields match the svc `.hive-schema.graphql`\n * exactly. No mock data.\n *\n * Transport: `graphqlFetch({ gateway: 'workspace', workspaceToken: true })` — the\n * host shell supplies the gateway base URL + a workspace-scoped token.\n *\n * IMPORTANT: `User`/`File` are id-only federation stubs in this subgraph. We\n * never select `citizen { firstName }` or `file { url }`.\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useGovCitizenHub } from '../context';\nimport { clearGraphqlResponseCache } from '../lib/graphql-cache';\nimport type {\n GovConnection,\n GovAgency,\n GovService,\n GovServiceCategory,\n GovServiceStatus,\n GovApplication,\n GovApplicationStatus,\n GovDocument,\n GovDocumentStatus,\n GovCaseNote,\n GovPermit,\n GovPermitStatus,\n GovPayment,\n GovPaymentStatus,\n GovGrievance,\n GovGrievanceStatus,\n GovCreateAgencyInput,\n GovUpdateAgencyInput,\n GovCreateServiceInput,\n GovUpdateServiceInput,\n GovCreateApplicationInput,\n GovUpdateApplicationInput,\n GovAddDocumentInput,\n GovAddCaseNoteInput,\n GovCreatePaymentInput,\n GovIssuePermitInput,\n GovReportGrievanceInput,\n GovUpdateGrievanceInput,\n GovDashboardSummary,\n PaginationInput,\n} from '../types';\n\n// ============================================================================\n// Transport\n// ============================================================================\n\nconst isMutation = (query: string): boolean => /^\\s*mutation\\b/.test(query);\n\nconst govQuery = async <TData>(\n query: string,\n variables: Record<string, unknown>,\n baseUrl?: string\n): Promise<TData> => {\n // A mutation must never be served from — or coalesced onto — the read cache,\n // and the resolved read cache must be dropped once it commits so the\n // React-Query refetch that follows sees the new state, not a stale (≤15s)\n // pre-write response. Clear before AND after the write.\n const mutating = isMutation(query);\n if (mutating) clearGraphqlResponseCache();\n\n const response = await graphqlFetch<TData>({\n gateway: 'workspace',\n baseUrl,\n query,\n variables,\n workspaceToken: true,\n });\n\n if (mutating) clearGraphqlResponseCache();\n\n if (response.errors?.length) {\n throw new Error(response.errors[0]?.message ?? 'GraphQL request failed');\n }\n if (!response.data) {\n throw new Error('GraphQL response did not include data');\n }\n return response.data;\n};\n\n// React-Query key roots (one namespace per domain entity).\nconst KEY = {\n dashboard: ['govcitizenhub', 'dashboard-summary'] as const,\n agencies: ['govcitizenhub', 'agencies'] as const,\n agency: (id: string) => ['govcitizenhub', 'agency', id] as const,\n services: ['govcitizenhub', 'services'] as const,\n service: (id: string) => ['govcitizenhub', 'service', id] as const,\n applications: ['govcitizenhub', 'applications'] as const,\n application: (id: string) => ['govcitizenhub', 'application', id] as const,\n payments: ['govcitizenhub', 'payments'] as const,\n payment: (id: string) => ['govcitizenhub', 'payment', id] as const,\n permits: ['govcitizenhub', 'permits'] as const,\n grievances: ['govcitizenhub', 'grievances'] as const,\n grievance: (id: string) => ['govcitizenhub', 'grievance', id] as const,\n};\n\nconst DEFAULT_PAGE: PaginationInput = { limit: 50 };\n\n/** Build a clean PaginationInput, dropping nullish cursor so the svc never sees `cursor: null`. */\nconst page = (p?: PaginationInput): PaginationInput => {\n const base = p ?? DEFAULT_PAGE;\n const result: PaginationInput = { limit: base.limit ?? DEFAULT_PAGE.limit };\n if (base.offset != null) result.offset = base.offset;\n if (base.cursor != null) result.cursor = base.cursor;\n return result;\n};\n\n// ============================================================================\n// Reusable gql field selections (codegen-free strictness)\n// ============================================================================\n\nconst AGENCY_FIELDS = `\n id workspaceId code contactEmail contactPhone description isActive jurisdiction\n name tags createdAt updatedAt\n`;\n\nconst SERVICE_FIELDS = `\n id workspaceId agencyId category currency eligibility feeAmount feeType formSchema\n name publishedAt requiredDocuments slaDays slug status summary tags createdAt updatedAt\n`;\n\nconst DOCUMENT_FIELDS = `\n id workspaceId applicationId name status requirement rejectionReason\n file { id } createdAt updatedAt\n`;\n\nconst CASE_NOTE_FIELDS = `\n id workspaceId applicationId authorId body type createdAt updatedAt\n`;\n\nconst PERMIT_FIELDS = `\n id workspaceId applicationId serviceId holderId title verificationCode status\n issuedAt expiresAt revokedAt revokeReason file { id } createdAt updatedAt\n`;\n\nconst PAYMENT_FIELDS = `\n id workspaceId applicationId payerId amount currency status receiptNumber\n providerRef lineItems paidAt refundedAt createdAt updatedAt\n`;\n\nconst APPLICATION_FIELDS = `\n id workspaceId reference serviceId citizenId assignedToId status priority dueDate\n submittedAt decidedAt decisionReason tags createdAt updatedAt\n`;\n\nconst GRIEVANCE_FIELDS = `\n id workspaceId title description category status priority location latitude longitude\n photoFileIds reporterId agencyId assignedToId resolution resolvedAt tags createdAt updatedAt\n`;\n\n// ============================================================================\n// Dashboard summary (authoritative, backend-computed counts)\n// ============================================================================\n\n/**\n * Reads `govDashboardSummary` — the svc-computed operations totals. These are\n * authoritative (full-corpus counts, not a capped client-side window), so the\n * dashboard tiles and status donut MUST source from here, never from a paged\n * list's `items.length`.\n */\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 }\n }`,\n {},\n apiGatewayUrl\n );\n return result.govDashboardSummary;\n },\n });\n};\n\n// ============================================================================\n// Agencies (list = ARRAY, not a connection)\n// ============================================================================\n\nexport interface AgencyFilters {\n isActive?: boolean;\n pagination?: PaginationInput;\n}\n\nexport const useGovAgencies = (filters: AgencyFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.agencies, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListAgencies: GovAgency[] }>(\n `query GovListAgencies($isActive: Boolean, $pagination: PaginationInput) {\n govListAgencies(isActive: $isActive, pagination: $pagination) { ${AGENCY_FIELDS} }\n }`,\n { isActive: filters.isActive, pagination: page(filters.pagination ?? { limit: 100 }) },\n apiGatewayUrl\n );\n return result.govListAgencies;\n },\n });\n};\n\nexport const useGovAgency = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.agency(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govAgency: GovAgency | null }>(\n `query GovAgency($id: ID!) {\n govAgency(id: $id) { ${AGENCY_FIELDS} services { ${SERVICE_FIELDS} } }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govAgency;\n },\n });\n};\n\nexport const useGovCreateAgency = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateAgencyInput) => {\n const result = await govQuery<{ govCreateAgency: GovAgency }>(\n `mutation GovCreateAgency($input: GovCreateAgencyInput!) {\n govCreateAgency(input: $input) { ${AGENCY_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateAgency;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.agencies }),\n });\n};\n\nexport const useGovUpdateAgency = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateAgencyInput }) => {\n const result = await govQuery<{ govUpdateAgency: GovAgency }>(\n `mutation GovUpdateAgency($id: ID!, $input: GovUpdateAgencyInput!) {\n govUpdateAgency(id: $id, input: $input) { ${AGENCY_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateAgency;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.agencies });\n qc.invalidateQueries({ queryKey: KEY.agency(data.id) });\n },\n });\n};\n\nexport const useGovArchiveAgency = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govArchiveAgency: boolean }>(\n `mutation GovArchiveAgency($id: ID!) { govArchiveAgency(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govArchiveAgency;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.agencies }),\n });\n};\n\n// ============================================================================\n// Services (connection)\n// ============================================================================\n\nexport interface ServiceFilters {\n agencyId?: string;\n category?: GovServiceCategory;\n status?: GovServiceStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovServices = (filters: ServiceFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.services, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListServices: GovConnection<GovService> }>(\n `query GovListServices($agencyId: ID, $category: GovServiceCategory, $status: GovServiceStatus, $pagination: PaginationInput) {\n govListServices(agencyId: $agencyId, category: $category, status: $status, pagination: $pagination) {\n items { ${SERVICE_FIELDS} agency { id name } }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n agencyId: filters.agencyId,\n category: filters.category,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListServices;\n },\n });\n};\n\nexport const useGovService = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.service(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govService: GovService | null }>(\n `query GovService($id: ID!) {\n govService(id: $id) { ${SERVICE_FIELDS} agency { ${AGENCY_FIELDS} } }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govService;\n },\n });\n};\n\nexport const useGovCreateService = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateServiceInput) => {\n const result = await govQuery<{ govCreateService: GovService }>(\n `mutation GovCreateService($input: GovCreateServiceInput!) {\n govCreateService(input: $input) { ${SERVICE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateService;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.services }),\n });\n};\n\nexport const useGovUpdateService = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateServiceInput }) => {\n const result = await govQuery<{ govUpdateService: GovService }>(\n `mutation GovUpdateService($id: ID!, $input: GovUpdateServiceInput!) {\n govUpdateService(id: $id, input: $input) { ${SERVICE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateService;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.services });\n qc.invalidateQueries({ queryKey: KEY.service(data.id) });\n },\n });\n};\n\nexport const useGovTransitionService = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; status: GovServiceStatus }) => {\n const result = await govQuery<{ govTransitionService: GovService }>(\n `mutation GovTransitionService($id: ID!, $status: GovServiceStatus!) {\n govTransitionService(id: $id, status: $status) { ${SERVICE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govTransitionService;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.services });\n qc.invalidateQueries({ queryKey: KEY.service(data.id) });\n },\n });\n};\n\n// ============================================================================\n// Applications (connection)\n// ============================================================================\n\nexport interface ApplicationFilters {\n assignedToId?: string;\n citizenId?: string;\n serviceId?: string;\n status?: GovApplicationStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovApplications = (filters: ApplicationFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.applications, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListApplications: GovConnection<GovApplication> }>(\n `query GovListApplications($assignedToId: ID, $citizenId: ID, $serviceId: ID, $status: GovApplicationStatus, $pagination: PaginationInput) {\n govListApplications(assignedToId: $assignedToId, citizenId: $citizenId, serviceId: $serviceId, status: $status, pagination: $pagination) {\n items { ${APPLICATION_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n assignedToId: filters.assignedToId,\n citizenId: filters.citizenId,\n serviceId: filters.serviceId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListApplications;\n },\n });\n};\n\nexport const useGovApplication = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.application(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govApplication: GovApplication | null }>(\n `query GovApplication($id: ID!) {\n govApplication(id: $id) {\n ${APPLICATION_FIELDS}\n formData\n documents { ${DOCUMENT_FIELDS} }\n notes { ${CASE_NOTE_FIELDS} }\n permits { ${PERMIT_FIELDS} }\n }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govApplication;\n },\n });\n};\n\nexport const useGovCreateApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateApplicationInput) => {\n const result = await govQuery<{ govCreateApplication: GovApplication }>(\n `mutation GovCreateApplication($input: GovCreateApplicationInput!) {\n govCreateApplication(input: $input) { ${APPLICATION_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateApplication;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.applications }),\n });\n};\n\nexport const useGovUpdateApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateApplicationInput }) => {\n const result = await govQuery<{ govUpdateApplication: GovApplication }>(\n `mutation GovUpdateApplication($id: ID!, $input: GovUpdateApplicationInput!) {\n govUpdateApplication(id: $id, input: $input) { ${APPLICATION_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateApplication;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.application(data.id) });\n },\n });\n};\n\nexport const useGovSubmitApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govSubmitApplication: GovApplication }>(\n `mutation GovSubmitApplication($id: ID!) {\n govSubmitApplication(id: $id) { ${APPLICATION_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govSubmitApplication;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.application(data.id) });\n },\n });\n};\n\nexport const useGovTransitionApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n status: GovApplicationStatus;\n reason?: string | null;\n }) => {\n const result = await govQuery<{ govTransitionApplication: GovApplication }>(\n `mutation GovTransitionApplication($id: ID!, $status: GovApplicationStatus!, $reason: String) {\n govTransitionApplication(id: $id, status: $status, reason: $reason) { ${APPLICATION_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govTransitionApplication;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.application(data.id) });\n },\n });\n};\n\n// ============================================================================\n// Documents (attached to an application)\n// ============================================================================\n\nexport const useGovAddDocument = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovAddDocumentInput) => {\n const result = await govQuery<{ govAddDocument: GovDocument }>(\n `mutation GovAddDocument($input: GovAddDocumentInput!) {\n govAddDocument(input: $input) { ${DOCUMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govAddDocument;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n qc.invalidateQueries({ queryKey: KEY.applications });\n },\n });\n};\n\nexport const useGovReviewDocument = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n status: GovDocumentStatus;\n rejectionReason?: string | null;\n applicationId?: string;\n }) => {\n const result = await govQuery<{ govReviewDocument: GovDocument }>(\n `mutation GovReviewDocument($id: ID!, $status: GovDocumentStatus!, $rejectionReason: String) {\n govReviewDocument(id: $id, status: $status, rejectionReason: $rejectionReason) { ${DOCUMENT_FIELDS} }\n }`,\n { id: vars.id, status: vars.status, rejectionReason: vars.rejectionReason },\n apiGatewayUrl\n );\n return result.govReviewDocument;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\n// ============================================================================\n// Case notes (domain-owned casework timeline)\n// ============================================================================\n\nexport const useGovAddCaseNote = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovAddCaseNoteInput) => {\n const result = await govQuery<{ govAddCaseNote: GovCaseNote }>(\n `mutation GovAddCaseNote($input: GovAddCaseNoteInput!) {\n govAddCaseNote(input: $input) { ${CASE_NOTE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govAddCaseNote;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\n// ============================================================================\n// Payments (connection)\n// ============================================================================\n\nexport interface PaymentFilters {\n applicationId?: string;\n payerId?: string;\n status?: GovPaymentStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovPayments = (filters: PaymentFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.payments, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListPayments: GovConnection<GovPayment> }>(\n `query GovListPayments($applicationId: ID, $payerId: ID, $status: GovPaymentStatus, $pagination: PaginationInput) {\n govListPayments(applicationId: $applicationId, payerId: $payerId, status: $status, pagination: $pagination) {\n items { ${PAYMENT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n applicationId: filters.applicationId,\n payerId: filters.payerId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListPayments;\n },\n });\n};\n\nexport const useGovCreatePayment = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreatePaymentInput) => {\n const result = await govQuery<{ govCreatePayment: GovPayment }>(\n `mutation GovCreatePayment($input: GovCreatePaymentInput!) {\n govCreatePayment(input: $input) { ${PAYMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreatePayment;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.payments });\n if (data.applicationId)\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\nexport const useGovMarkPaymentPaid = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; providerRef?: string | null }) => {\n const result = await govQuery<{ govMarkPaymentPaid: GovPayment }>(\n `mutation GovMarkPaymentPaid($id: ID!, $providerRef: String) {\n govMarkPaymentPaid(id: $id, providerRef: $providerRef) { ${PAYMENT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govMarkPaymentPaid;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.payments }),\n });\n};\n\nexport const useGovRefundPayment = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govRefundPayment: GovPayment }>(\n `mutation GovRefundPayment($id: ID!) {\n govRefundPayment(id: $id) { ${PAYMENT_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govRefundPayment;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.payments }),\n });\n};\n\n// ============================================================================\n// Permits (list = ARRAY, no pagination) + public verification\n// ============================================================================\n\nexport interface PermitFilters {\n holderId?: string;\n serviceId?: string;\n status?: GovPermitStatus;\n pagination?: PaginationInput;\n}\n\n/**\n * `govListPermits` returns a bare ARRAY (not a connection), but now accepts an\n * optional offset `pagination` arg (default page size 50). Callers page with\n * `{ limit, offset }`; `hasMore` is inferred from a full-length page since the\n * svc does not return a total.\n */\nexport const useGovPermits = (filters: PermitFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.permits, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListPermits: GovPermit[] }>(\n `query GovListPermits($holderId: ID, $serviceId: ID, $status: GovPermitStatus, $pagination: PaginationInput) {\n govListPermits(holderId: $holderId, serviceId: $serviceId, status: $status, pagination: $pagination) { ${PERMIT_FIELDS} }\n }`,\n {\n holderId: filters.holderId,\n serviceId: filters.serviceId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListPermits;\n },\n });\n};\n\nexport const useGovIssuePermit = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovIssuePermitInput) => {\n const result = await govQuery<{ govIssuePermit: GovPermit }>(\n `mutation GovIssuePermit($input: GovIssuePermitInput!) {\n govIssuePermit(input: $input) { ${PERMIT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govIssuePermit;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.permits });\n if (data.applicationId)\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\nexport const useGovRevokePermit = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; reason?: string | null }) => {\n const result = await govQuery<{ govRevokePermit: GovPermit }>(\n `mutation GovRevokePermit($id: ID!, $reason: String) {\n govRevokePermit(id: $id, reason: $reason) { ${PERMIT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govRevokePermit;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.permits }),\n });\n};\n\n/**\n * Public permit verification by printed code. `govVerifyPermit` is a PUBLIC field\n * (no auth), but we keep the workspace-token transport for a consistent gateway\n * path. `enabled` is false until a code is supplied so the query is manual.\n */\nexport const useGovVerifyPermit = (verificationCode: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: ['govcitizenhub', 'verify-permit', verificationCode ?? ''],\n enabled: Boolean(verificationCode),\n retry: false,\n queryFn: async () => {\n const result = await govQuery<{ govVerifyPermit: GovPermit | null }>(\n `query GovVerifyPermit($verificationCode: String!) {\n govVerifyPermit(verificationCode: $verificationCode) { ${PERMIT_FIELDS} }\n }`,\n { verificationCode },\n apiGatewayUrl\n );\n return result.govVerifyPermit;\n },\n });\n};\n\n// ============================================================================\n// Grievances (connection)\n// ============================================================================\n\nexport interface GrievanceFilters {\n agencyId?: string;\n reporterId?: string;\n status?: GovGrievanceStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovGrievances = (filters: GrievanceFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.grievances, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListGrievances: GovConnection<GovGrievance> }>(\n `query GovListGrievances($agencyId: ID, $reporterId: ID, $status: GovGrievanceStatus, $pagination: PaginationInput) {\n govListGrievances(agencyId: $agencyId, reporterId: $reporterId, status: $status, pagination: $pagination) {\n items { ${GRIEVANCE_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n agencyId: filters.agencyId,\n reporterId: filters.reporterId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListGrievances;\n },\n });\n};\n\nexport const useGovGrievance = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.grievance(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govGrievance: GovGrievance | null }>(\n `query GovGrievance($id: ID!) {\n govGrievance(id: $id) { ${GRIEVANCE_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govGrievance;\n },\n });\n};\n\nexport const useGovReportGrievance = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovReportGrievanceInput) => {\n const result = await govQuery<{ govReportGrievance: GovGrievance }>(\n `mutation GovReportGrievance($input: GovReportGrievanceInput!) {\n govReportGrievance(input: $input) { ${GRIEVANCE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govReportGrievance;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.grievances }),\n });\n};\n\nexport const useGovUpdateGrievance = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateGrievanceInput }) => {\n const result = await govQuery<{ govUpdateGrievance: GovGrievance }>(\n `mutation GovUpdateGrievance($id: ID!, $input: GovUpdateGrievanceInput!) {\n govUpdateGrievance(id: $id, input: $input) { ${GRIEVANCE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateGrievance;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.grievances });\n qc.invalidateQueries({ queryKey: KEY.grievance(data.id) });\n },\n });\n};\n\nexport const useGovTransitionGrievance = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n status: GovGrievanceStatus;\n resolution?: string | null;\n }) => {\n const result = await govQuery<{ govTransitionGrievance: GovGrievance }>(\n `mutation GovTransitionGrievance($id: ID!, $status: GovGrievanceStatus!, $resolution: String) {\n govTransitionGrievance(id: $id, status: $status, resolution: $resolution) { ${GRIEVANCE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govTransitionGrievance;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.grievances });\n qc.invalidateQueries({ queryKey: KEY.grievance(data.id) });\n },\n });\n};\n"],"mappings":";;;;;;AA0DA,IAAM,KAAc,MAA2B,iBAAiB,KAAK,EAAM,EAErE,IAAW,OACf,GACA,GACA,MACmB;CAKnB,IAAM,IAAW,EAAW,EAAM;AAClC,CAAI,KAAU,GAA2B;CAEzC,IAAM,IAAW,MAAM,EAAoB;EACzC,SAAS;EACT;EACA;EACA;EACA,gBAAgB;EACjB,CAAC;AAIF,KAFI,KAAU,GAA2B,EAErC,EAAS,QAAQ,OACnB,OAAU,MAAM,EAAS,OAAO,IAAI,WAAW,yBAAyB;AAE1E,KAAI,CAAC,EAAS,KACZ,OAAU,MAAM,wCAAwC;AAE1D,QAAO,EAAS;GAIZ,IAAM;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esContent":["/**\n * GovCitizenHub API hooks\n * @module govcitizenhub/hooks\n *\n * React-Query hooks wired DIRECTLY to the real `wspace-govcitizenhub-svc`\n * federated GraphQL contract (the `gov*` operations). Every query/mutation below\n * uses an inline gql string whose fields match the svc `.hive-schema.graphql`\n * exactly. No mock data.\n *\n * Transport: `graphqlFetch({ gateway: 'workspace', workspaceToken: true })` — the\n * host shell supplies the gateway base URL + a workspace-scoped token.\n *\n * IMPORTANT: `User`/`File` are id-only federation stubs in this subgraph. We\n * never select `citizen { firstName }` or `file { url }`.\n */\n\nimport { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';\nimport { graphqlFetch } from '@burdenoff/fe-libs/shared/graphql';\n\nimport { useGovCitizenHub } from '../context';\nimport { clearGraphqlResponseCache } from '../lib/graphql-cache';\nimport type {\n GovConnection,\n GovAgency,\n GovService,\n GovServiceCategory,\n GovServiceStatus,\n GovApplication,\n GovApplicationStatus,\n GovDocument,\n GovDocumentStatus,\n GovCaseNote,\n GovPermit,\n GovPermitStatus,\n GovPayment,\n GovPaymentStatus,\n GovGrievance,\n GovGrievanceStatus,\n GovCreateAgencyInput,\n GovUpdateAgencyInput,\n GovCreateServiceInput,\n GovUpdateServiceInput,\n GovCreateApplicationInput,\n GovUpdateApplicationInput,\n GovAddDocumentInput,\n GovAddCaseNoteInput,\n GovCreatePaymentInput,\n GovIssuePermitInput,\n GovReportGrievanceInput,\n GovUpdateGrievanceInput,\n GovDashboardSummary,\n PaginationInput,\n} from '../types';\n\n// ============================================================================\n// Transport\n// ============================================================================\n\nconst isMutation = (query: string): boolean => /^\\s*mutation\\b/.test(query);\n\nconst govQuery = async <TData>(\n query: string,\n variables: Record<string, unknown>,\n baseUrl?: string\n): Promise<TData> => {\n // A mutation must never be served from — or coalesced onto — the read cache,\n // and the resolved read cache must be dropped once it commits so the\n // React-Query refetch that follows sees the new state, not a stale (≤15s)\n // pre-write response. Clear before AND after the write.\n const mutating = isMutation(query);\n if (mutating) clearGraphqlResponseCache();\n\n const response = await graphqlFetch<TData>({\n gateway: 'workspace',\n baseUrl,\n query,\n variables,\n workspaceToken: true,\n });\n\n if (mutating) clearGraphqlResponseCache();\n\n if (response.errors?.length) {\n throw new Error(response.errors[0]?.message ?? 'GraphQL request failed');\n }\n if (!response.data) {\n throw new Error('GraphQL response did not include data');\n }\n return response.data;\n};\n\n// React-Query key roots (one namespace per domain entity).\nconst KEY = {\n dashboard: ['govcitizenhub', 'dashboard-summary'] as const,\n agencies: ['govcitizenhub', 'agencies'] as const,\n agency: (id: string) => ['govcitizenhub', 'agency', id] as const,\n services: ['govcitizenhub', 'services'] as const,\n service: (id: string) => ['govcitizenhub', 'service', id] as const,\n applications: ['govcitizenhub', 'applications'] as const,\n application: (id: string) => ['govcitizenhub', 'application', id] as const,\n payments: ['govcitizenhub', 'payments'] as const,\n payment: (id: string) => ['govcitizenhub', 'payment', id] as const,\n permits: ['govcitizenhub', 'permits'] as const,\n grievances: ['govcitizenhub', 'grievances'] as const,\n grievance: (id: string) => ['govcitizenhub', 'grievance', id] as const,\n};\n\nconst DEFAULT_PAGE: PaginationInput = { limit: 50 };\n\n/** Build a clean PaginationInput, dropping nullish cursor so the svc never sees `cursor: null`. */\nconst page = (p?: PaginationInput): PaginationInput => {\n const base = p ?? DEFAULT_PAGE;\n const result: PaginationInput = { limit: base.limit ?? DEFAULT_PAGE.limit };\n if (base.offset != null) result.offset = base.offset;\n if (base.cursor != null) result.cursor = base.cursor;\n return result;\n};\n\n// ============================================================================\n// Reusable gql field selections (codegen-free strictness)\n// ============================================================================\n\nconst AGENCY_FIELDS = `\n id workspaceId code contactEmail contactPhone description isActive jurisdiction\n name tags createdAt updatedAt\n`;\n\nconst SERVICE_FIELDS = `\n id workspaceId agencyId category currency eligibility feeAmount feeType formSchema\n name publishedAt requiredDocuments slaDays slug status summary tags createdAt updatedAt\n`;\n\nconst DOCUMENT_FIELDS = `\n id workspaceId applicationId name status requirement rejectionReason\n file { id } createdAt updatedAt\n`;\n\nconst CASE_NOTE_FIELDS = `\n id workspaceId applicationId authorId body type createdAt updatedAt\n`;\n\nconst PERMIT_FIELDS = `\n id workspaceId applicationId serviceId holderId title verificationCode status\n issuedAt expiresAt revokedAt revokeReason file { id } createdAt updatedAt\n`;\n\nconst PAYMENT_FIELDS = `\n id workspaceId applicationId payerId amount currency status receiptNumber\n providerRef lineItems paidAt refundedAt createdAt updatedAt\n`;\n\nconst APPLICATION_FIELDS = `\n id workspaceId reference serviceId citizenId assignedToId status priority dueDate\n submittedAt decidedAt decisionReason tags createdAt updatedAt\n`;\n\nconst GRIEVANCE_FIELDS = `\n id workspaceId title description category status priority location latitude longitude\n photoFileIds reporterId agencyId assignedToId resolution resolvedAt tags createdAt updatedAt\n`;\n\n// ============================================================================\n// Dashboard summary (authoritative, backend-computed counts)\n// ============================================================================\n\n/**\n * Reads `govDashboardSummary` — the svc-computed operations totals. These are\n * authoritative (full-corpus counts, not a capped client-side window), so the\n * dashboard tiles and status donut MUST source from here, never from a paged\n * list's `items.length`.\n */\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 }\n }`,\n {},\n apiGatewayUrl\n );\n return result.govDashboardSummary;\n },\n });\n};\n\n// ============================================================================\n// Agencies (list = ARRAY, not a connection)\n// ============================================================================\n\nexport interface AgencyFilters {\n isActive?: boolean;\n pagination?: PaginationInput;\n}\n\nexport const useGovAgencies = (filters: AgencyFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.agencies, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListAgencies: GovAgency[] }>(\n `query GovListAgencies($isActive: Boolean, $pagination: PaginationInput) {\n govListAgencies(isActive: $isActive, pagination: $pagination) { ${AGENCY_FIELDS} }\n }`,\n { isActive: filters.isActive, pagination: page(filters.pagination ?? { limit: 100 }) },\n apiGatewayUrl\n );\n return result.govListAgencies;\n },\n });\n};\n\nexport const useGovAgency = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.agency(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govAgency: GovAgency | null }>(\n `query GovAgency($id: ID!) {\n govAgency(id: $id) { ${AGENCY_FIELDS} services { ${SERVICE_FIELDS} } }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govAgency;\n },\n });\n};\n\nexport const useGovCreateAgency = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateAgencyInput) => {\n const result = await govQuery<{ govCreateAgency: GovAgency }>(\n `mutation GovCreateAgency($input: GovCreateAgencyInput!) {\n govCreateAgency(input: $input) { ${AGENCY_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateAgency;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.agencies }),\n });\n};\n\nexport const useGovUpdateAgency = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateAgencyInput }) => {\n const result = await govQuery<{ govUpdateAgency: GovAgency }>(\n `mutation GovUpdateAgency($id: ID!, $input: GovUpdateAgencyInput!) {\n govUpdateAgency(id: $id, input: $input) { ${AGENCY_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateAgency;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.agencies });\n qc.invalidateQueries({ queryKey: KEY.agency(data.id) });\n },\n });\n};\n\nexport const useGovArchiveAgency = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govArchiveAgency: boolean }>(\n `mutation GovArchiveAgency($id: ID!) { govArchiveAgency(id: $id) }`,\n { id },\n apiGatewayUrl\n );\n return result.govArchiveAgency;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.agencies }),\n });\n};\n\n// ============================================================================\n// Services (connection)\n// ============================================================================\n\nexport interface ServiceFilters {\n agencyId?: string;\n category?: GovServiceCategory;\n status?: GovServiceStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovServices = (filters: ServiceFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.services, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListServices: GovConnection<GovService> }>(\n `query GovListServices($agencyId: ID, $category: GovServiceCategory, $status: GovServiceStatus, $pagination: PaginationInput) {\n govListServices(agencyId: $agencyId, category: $category, status: $status, pagination: $pagination) {\n items { ${SERVICE_FIELDS} agency { id name } }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n agencyId: filters.agencyId,\n category: filters.category,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListServices;\n },\n });\n};\n\nexport const useGovService = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.service(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govService: GovService | null }>(\n `query GovService($id: ID!) {\n govService(id: $id) { ${SERVICE_FIELDS} agency { ${AGENCY_FIELDS} } }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govService;\n },\n });\n};\n\nexport const useGovCreateService = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateServiceInput) => {\n const result = await govQuery<{ govCreateService: GovService }>(\n `mutation GovCreateService($input: GovCreateServiceInput!) {\n govCreateService(input: $input) { ${SERVICE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateService;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.services }),\n });\n};\n\nexport const useGovUpdateService = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateServiceInput }) => {\n const result = await govQuery<{ govUpdateService: GovService }>(\n `mutation GovUpdateService($id: ID!, $input: GovUpdateServiceInput!) {\n govUpdateService(id: $id, input: $input) { ${SERVICE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateService;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.services });\n qc.invalidateQueries({ queryKey: KEY.service(data.id) });\n },\n });\n};\n\nexport const useGovTransitionService = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; status: GovServiceStatus }) => {\n const result = await govQuery<{ govTransitionService: GovService }>(\n `mutation GovTransitionService($id: ID!, $status: GovServiceStatus!) {\n govTransitionService(id: $id, status: $status) { ${SERVICE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govTransitionService;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.services });\n qc.invalidateQueries({ queryKey: KEY.service(data.id) });\n },\n });\n};\n\n// ============================================================================\n// Applications (connection)\n// ============================================================================\n\nexport interface ApplicationFilters {\n assignedToId?: string;\n citizenId?: string;\n serviceId?: string;\n status?: GovApplicationStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovApplications = (filters: ApplicationFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.applications, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListApplications: GovConnection<GovApplication> }>(\n `query GovListApplications($assignedToId: ID, $citizenId: ID, $serviceId: ID, $status: GovApplicationStatus, $pagination: PaginationInput) {\n govListApplications(assignedToId: $assignedToId, citizenId: $citizenId, serviceId: $serviceId, status: $status, pagination: $pagination) {\n items { ${APPLICATION_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n assignedToId: filters.assignedToId,\n citizenId: filters.citizenId,\n serviceId: filters.serviceId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListApplications;\n },\n });\n};\n\nexport const useGovApplication = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.application(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govApplication: GovApplication | null }>(\n `query GovApplication($id: ID!) {\n govApplication(id: $id) {\n ${APPLICATION_FIELDS}\n formData\n documents { ${DOCUMENT_FIELDS} }\n notes { ${CASE_NOTE_FIELDS} }\n permits { ${PERMIT_FIELDS} }\n }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govApplication;\n },\n });\n};\n\nexport const useGovCreateApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreateApplicationInput) => {\n const result = await govQuery<{ govCreateApplication: GovApplication }>(\n `mutation GovCreateApplication($input: GovCreateApplicationInput!) {\n govCreateApplication(input: $input) { ${APPLICATION_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreateApplication;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.applications }),\n });\n};\n\nexport const useGovUpdateApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateApplicationInput }) => {\n const result = await govQuery<{ govUpdateApplication: GovApplication }>(\n `mutation GovUpdateApplication($id: ID!, $input: GovUpdateApplicationInput!) {\n govUpdateApplication(id: $id, input: $input) { ${APPLICATION_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateApplication;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.application(data.id) });\n },\n });\n};\n\nexport const useGovSubmitApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govSubmitApplication: GovApplication }>(\n `mutation GovSubmitApplication($id: ID!) {\n govSubmitApplication(id: $id) { ${APPLICATION_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govSubmitApplication;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.application(data.id) });\n },\n });\n};\n\nexport const useGovTransitionApplication = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n status: GovApplicationStatus;\n reason?: string | null;\n }) => {\n const result = await govQuery<{ govTransitionApplication: GovApplication }>(\n `mutation GovTransitionApplication($id: ID!, $status: GovApplicationStatus!, $reason: String) {\n govTransitionApplication(id: $id, status: $status, reason: $reason) { ${APPLICATION_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govTransitionApplication;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.applications });\n qc.invalidateQueries({ queryKey: KEY.application(data.id) });\n },\n });\n};\n\n// ============================================================================\n// Documents (attached to an application)\n// ============================================================================\n\nexport const useGovAddDocument = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovAddDocumentInput) => {\n const result = await govQuery<{ govAddDocument: GovDocument }>(\n `mutation GovAddDocument($input: GovAddDocumentInput!) {\n govAddDocument(input: $input) { ${DOCUMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govAddDocument;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n qc.invalidateQueries({ queryKey: KEY.applications });\n },\n });\n};\n\nexport const useGovReviewDocument = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n status: GovDocumentStatus;\n rejectionReason?: string | null;\n applicationId?: string;\n }) => {\n const result = await govQuery<{ govReviewDocument: GovDocument }>(\n `mutation GovReviewDocument($id: ID!, $status: GovDocumentStatus!, $rejectionReason: String) {\n govReviewDocument(id: $id, status: $status, rejectionReason: $rejectionReason) { ${DOCUMENT_FIELDS} }\n }`,\n { id: vars.id, status: vars.status, rejectionReason: vars.rejectionReason },\n apiGatewayUrl\n );\n return result.govReviewDocument;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\n// ============================================================================\n// Case notes (domain-owned casework timeline)\n// ============================================================================\n\nexport const useGovAddCaseNote = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovAddCaseNoteInput) => {\n const result = await govQuery<{ govAddCaseNote: GovCaseNote }>(\n `mutation GovAddCaseNote($input: GovAddCaseNoteInput!) {\n govAddCaseNote(input: $input) { ${CASE_NOTE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govAddCaseNote;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\n// ============================================================================\n// Payments (connection)\n// ============================================================================\n\nexport interface PaymentFilters {\n applicationId?: string;\n payerId?: string;\n status?: GovPaymentStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovPayments = (filters: PaymentFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.payments, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListPayments: GovConnection<GovPayment> }>(\n `query GovListPayments($applicationId: ID, $payerId: ID, $status: GovPaymentStatus, $pagination: PaginationInput) {\n govListPayments(applicationId: $applicationId, payerId: $payerId, status: $status, pagination: $pagination) {\n items { ${PAYMENT_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n applicationId: filters.applicationId,\n payerId: filters.payerId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListPayments;\n },\n });\n};\n\nexport const useGovCreatePayment = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovCreatePaymentInput) => {\n const result = await govQuery<{ govCreatePayment: GovPayment }>(\n `mutation GovCreatePayment($input: GovCreatePaymentInput!) {\n govCreatePayment(input: $input) { ${PAYMENT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govCreatePayment;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.payments });\n if (data.applicationId)\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\nexport const useGovMarkPaymentPaid = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; providerRef?: string | null }) => {\n const result = await govQuery<{ govMarkPaymentPaid: GovPayment }>(\n `mutation GovMarkPaymentPaid($id: ID!, $providerRef: String) {\n govMarkPaymentPaid(id: $id, providerRef: $providerRef) { ${PAYMENT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govMarkPaymentPaid;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.payments }),\n });\n};\n\nexport const useGovRefundPayment = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (id: string) => {\n const result = await govQuery<{ govRefundPayment: GovPayment }>(\n `mutation GovRefundPayment($id: ID!) {\n govRefundPayment(id: $id) { ${PAYMENT_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govRefundPayment;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.payments }),\n });\n};\n\n// ============================================================================\n// Permits (list = ARRAY, no pagination) + public verification\n// ============================================================================\n\nexport interface PermitFilters {\n holderId?: string;\n serviceId?: string;\n status?: GovPermitStatus;\n pagination?: PaginationInput;\n}\n\n/**\n * `govListPermits` returns a bare ARRAY (not a connection), but now accepts an\n * optional offset `pagination` arg (default page size 50). Callers page with\n * `{ limit, offset }`; `hasMore` is inferred from a full-length page since the\n * svc does not return a total.\n */\nexport const useGovPermits = (filters: PermitFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.permits, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListPermits: GovPermit[] }>(\n `query GovListPermits($holderId: ID, $serviceId: ID, $status: GovPermitStatus, $pagination: PaginationInput) {\n govListPermits(holderId: $holderId, serviceId: $serviceId, status: $status, pagination: $pagination) { ${PERMIT_FIELDS} }\n }`,\n {\n holderId: filters.holderId,\n serviceId: filters.serviceId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListPermits;\n },\n });\n};\n\nexport const useGovIssuePermit = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovIssuePermitInput) => {\n const result = await govQuery<{ govIssuePermit: GovPermit }>(\n `mutation GovIssuePermit($input: GovIssuePermitInput!) {\n govIssuePermit(input: $input) { ${PERMIT_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govIssuePermit;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.permits });\n if (data.applicationId)\n qc.invalidateQueries({ queryKey: KEY.application(data.applicationId) });\n },\n });\n};\n\nexport const useGovRevokePermit = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; reason?: string | null }) => {\n const result = await govQuery<{ govRevokePermit: GovPermit }>(\n `mutation GovRevokePermit($id: ID!, $reason: String) {\n govRevokePermit(id: $id, reason: $reason) { ${PERMIT_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govRevokePermit;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.permits }),\n });\n};\n\n/**\n * Public permit verification by printed code. `govVerifyPermit` is a PUBLIC field\n * (no auth), but we keep the workspace-token transport for a consistent gateway\n * path. `enabled` is false until a code is supplied so the query is manual.\n */\nexport const useGovVerifyPermit = (verificationCode: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: ['govcitizenhub', 'verify-permit', verificationCode ?? ''],\n enabled: Boolean(verificationCode),\n retry: false,\n queryFn: async () => {\n const result = await govQuery<{ govVerifyPermit: GovPermit | null }>(\n `query GovVerifyPermit($verificationCode: String!) {\n govVerifyPermit(verificationCode: $verificationCode) { ${PERMIT_FIELDS} }\n }`,\n { verificationCode },\n apiGatewayUrl\n );\n return result.govVerifyPermit;\n },\n });\n};\n\n// ============================================================================\n// Grievances (connection)\n// ============================================================================\n\nexport interface GrievanceFilters {\n agencyId?: string;\n reporterId?: string;\n status?: GovGrievanceStatus;\n pagination?: PaginationInput;\n}\n\nexport const useGovGrievances = (filters: GrievanceFilters = {}) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: [...KEY.grievances, filters],\n queryFn: async () => {\n const result = await govQuery<{ govListGrievances: GovConnection<GovGrievance> }>(\n `query GovListGrievances($agencyId: ID, $reporterId: ID, $status: GovGrievanceStatus, $pagination: PaginationInput) {\n govListGrievances(agencyId: $agencyId, reporterId: $reporterId, status: $status, pagination: $pagination) {\n items { ${GRIEVANCE_FIELDS} }\n pageInfo { cursor hasMore }\n }\n }`,\n {\n agencyId: filters.agencyId,\n reporterId: filters.reporterId,\n status: filters.status,\n pagination: page(filters.pagination),\n },\n apiGatewayUrl\n );\n return result.govListGrievances;\n },\n });\n};\n\nexport const useGovGrievance = (id: string | undefined) => {\n const { apiGatewayUrl } = useGovCitizenHub();\n return useQuery({\n queryKey: KEY.grievance(id ?? ''),\n enabled: Boolean(id),\n queryFn: async () => {\n const result = await govQuery<{ govGrievance: GovGrievance | null }>(\n `query GovGrievance($id: ID!) {\n govGrievance(id: $id) { ${GRIEVANCE_FIELDS} }\n }`,\n { id },\n apiGatewayUrl\n );\n return result.govGrievance;\n },\n });\n};\n\nexport const useGovReportGrievance = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (input: GovReportGrievanceInput) => {\n const result = await govQuery<{ govReportGrievance: GovGrievance }>(\n `mutation GovReportGrievance($input: GovReportGrievanceInput!) {\n govReportGrievance(input: $input) { ${GRIEVANCE_FIELDS} }\n }`,\n { input },\n apiGatewayUrl\n );\n return result.govReportGrievance;\n },\n onSuccess: () => qc.invalidateQueries({ queryKey: KEY.grievances }),\n });\n};\n\nexport const useGovUpdateGrievance = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: { id: string; input: GovUpdateGrievanceInput }) => {\n const result = await govQuery<{ govUpdateGrievance: GovGrievance }>(\n `mutation GovUpdateGrievance($id: ID!, $input: GovUpdateGrievanceInput!) {\n govUpdateGrievance(id: $id, input: $input) { ${GRIEVANCE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govUpdateGrievance;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.grievances });\n qc.invalidateQueries({ queryKey: KEY.grievance(data.id) });\n },\n });\n};\n\nexport const useGovTransitionGrievance = () => {\n const { apiGatewayUrl } = useGovCitizenHub();\n const qc = useQueryClient();\n return useMutation({\n mutationFn: async (vars: {\n id: string;\n status: GovGrievanceStatus;\n resolution?: string | null;\n }) => {\n const result = await govQuery<{ govTransitionGrievance: GovGrievance }>(\n `mutation GovTransitionGrievance($id: ID!, $status: GovGrievanceStatus!, $resolution: String) {\n govTransitionGrievance(id: $id, status: $status, resolution: $resolution) { ${GRIEVANCE_FIELDS} }\n }`,\n vars,\n apiGatewayUrl\n );\n return result.govTransitionGrievance;\n },\n onSuccess: (data) => {\n qc.invalidateQueries({ queryKey: KEY.grievances });\n qc.invalidateQueries({ queryKey: KEY.grievance(data.id) });\n },\n });\n};\n"],"mappings":";;;;;;AA0DA,IAAM,KAAc,MAA2B,iBAAiB,KAAK,EAAM,EAErE,IAAW,OACf,GACA,GACA,MACmB;CAKnB,IAAM,IAAW,EAAW,EAAM;AAClC,CAAI,KAAU,GAA2B;CAEzC,IAAM,IAAW,MAAM,EAAoB;EACzC,SAAS;EACT;EACA;EACA;EACA,gBAAgB;EACjB,CAAC;AAIF,KAFI,KAAU,GAA2B,EAErC,EAAS,QAAQ,OACnB,OAAU,MAAM,EAAS,OAAO,IAAI,WAAW,yBAAyB;AAE1E,KAAI,CAAC,EAAS,KACZ,OAAU,MAAM,wCAAwC;AAE1D,QAAO,EAAS;GAIZ,IAAM;CACV,WAAW,CAAC,iBAAiB,oBAAoB;CACjD,UAAU,CAAC,iBAAiB,WAAW;CACvC,SAAS,MAAe;EAAC;EAAiB;EAAU;EAAG;CACvD,UAAU,CAAC,iBAAiB,WAAW;CACvC,UAAU,MAAe;EAAC;EAAiB;EAAW;EAAG;CACzD,cAAc,CAAC,iBAAiB,eAAe;CAC/C,cAAc,MAAe;EAAC;EAAiB;EAAe;EAAG;CACjE,UAAU,CAAC,iBAAiB,WAAW;CACvC,UAAU,MAAe;EAAC;EAAiB;EAAW;EAAG;CACzD,SAAS,CAAC,iBAAiB,UAAU;CACrC,YAAY,CAAC,iBAAiB,aAAa;CAC3C,YAAY,MAAe;EAAC;EAAiB;EAAa;EAAG;CAC9D,EAEK,IAAgC,EAAE,OAAO,IAAI,EAG7C,KAAQ,MAAyC;CACrD,IAAM,IAAO,KAAK,GACZ,IAA0B,EAAE,OAAO,EAAK,SAAS,EAAa,OAAO;AAG3E,QAFI,EAAK,UAAU,SAAM,EAAO,SAAS,EAAK,SAC1C,EAAK,UAAU,SAAM,EAAO,SAAS,EAAK,SACvC;GAOH,IAAgB,0HAK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AAG,kBAAkB,EAAE,UAAU,EAAI,YAAY,CAAC;EACpE,CAAC;GAGS,UAA8B;CACzC,IAAM,EAAE,qBAAkB,GAAkB,EACtC,IAAK,GAAgB;AAC3B,QAAO,EAAY;EACjB,YAAY,OAAO,OACF,MAAM,EACnB;yDACiD,EAAiB;YAElE,GACA,EACD,EACa;EAEhB,YAAY,MAAS;AAEnB,GADA,EAAG,kBAAkB,EAAE,UAAU,EAAI,YAAY,CAAC,EAClD,EAAG,kBAAkB,EAAE,UAAU,EAAI,UAAU,EAAK,GAAG,EAAE,CAAC;;EAE7D,CAAC;GAGS,UAAkC;CAC7C,IAAM,EAAE,qBAAkB,GAAkB,EACtC,IAAK,GAAgB;AAC3B,QAAO,EAAY;EACjB,YAAY,OAAO,OAKF,MAAM,EACnB;wFACgF,EAAiB;YAEjG,GACA,EACD,EACa;EAEhB,YAAY,MAAS;AAEnB,GADA,EAAG,kBAAkB,EAAE,UAAU,EAAI,YAAY,CAAC,EAClD,EAAG,kBAAkB,EAAE,UAAU,EAAI,UAAU,EAAK,GAAG,EAAE,CAAC;;EAE7D,CAAC"}
@@ -49,7 +49,7 @@ function F() {
49
49
  value: e.count,
50
50
  color: r[n % r.length]
51
51
  };
52
- }).filter((e) => e.value > 0), [F.data]), B = h(() => [...L].sort((e, t) => new Date(t.createdAt).getTime() - new Date(e.createdAt).getTime()).slice(0, 6), [L]), V = F.isLoading, H = I.isLoading, U = F.data?.applicationsTotal ?? 0, W = F.data?.pendingPaymentsAmount ?? 0;
52
+ }).filter((e) => e.value > 0), [F.data]), B = h(() => z.reduce((e, t) => e + t.value, 0), [z]), V = h(() => [...L].sort((e, t) => new Date(t.createdAt).getTime() - new Date(e.createdAt).getTime()).slice(0, 6), [L]), H = F.isLoading, U = I.isLoading, W = F.data?.applicationsTotal ?? 0, G = F.data?.pendingPaymentsAmount ?? 0;
53
53
  return /* @__PURE__ */ E(t, {
54
54
  title: "GovCitizenHub",
55
55
  titleGradient: !0,
@@ -61,7 +61,7 @@ function F() {
61
61
  children: [
62
62
  {
63
63
  label: "Applications",
64
- value: l(U),
64
+ value: l(W),
65
65
  sublabel: "filed to date",
66
66
  icon: /* @__PURE__ */ T(S, { className: "h-5 w-5" }),
67
67
  path: "applications",
@@ -70,7 +70,7 @@ function F() {
70
70
  {
71
71
  label: "Pending payments",
72
72
  value: l(F.data?.pendingPayments ?? 0),
73
- sublabel: W > 0 ? `${s(W, j)} due` : "all settled",
73
+ sublabel: G > 0 ? `${s(G, j)} due` : "all settled",
74
74
  icon: /* @__PURE__ */ T(x, { className: "h-5 w-5" }),
75
75
  path: "payments",
76
76
  accent: "warning"
@@ -80,7 +80,8 @@ function F() {
80
80
  value: l(F.data?.openGrievances ?? 0),
81
81
  sublabel: "awaiting acknowledgement",
82
82
  icon: /* @__PURE__ */ T(C, { className: "h-5 w-5" }),
83
- path: "grievances"
83
+ path: "grievances",
84
+ accent: "error"
84
85
  },
85
86
  {
86
87
  label: "Active permits",
@@ -106,7 +107,7 @@ function F() {
106
107
  }
107
108
  ].map((e) => /* @__PURE__ */ T(n, {
108
109
  icon: e.icon,
109
- value: V ? "—" : e.value,
110
+ value: H ? "—" : e.value,
110
111
  label: e.label,
111
112
  sublabel: e.sublabel,
112
113
  featured: e.featured,
@@ -119,18 +120,21 @@ function F() {
119
120
  children: [/* @__PURE__ */ E(D, {
120
121
  treatment: "glass",
121
122
  className: "p-5 lg:col-span-3",
122
- children: [/* @__PURE__ */ T("div", {
123
+ children: [/* @__PURE__ */ E("div", {
123
124
  className: "flex items-start justify-between gap-4",
124
- children: /* @__PURE__ */ E("div", { children: [/* @__PURE__ */ T("h2", {
125
+ children: [/* @__PURE__ */ E("div", { children: [/* @__PURE__ */ T("h2", {
125
126
  className: "text-lg font-semibold text-text-primary",
126
- children: "Recent applications"
127
+ children: "Applications over time"
127
128
  }), /* @__PURE__ */ T("p", {
128
129
  className: "mt-0.5 text-xs text-text-muted",
129
- children: "Last 30 days (recent sample, not a total)"
130
- })] })
130
+ children: "Cumulative filings (recent sample, not a total)"
131
+ })] }), /* @__PURE__ */ T("span", {
132
+ className: "shrink-0 rounded-full border border-border-seam bg-bg-surface px-3 py-1 text-xs font-medium text-text-secondary",
133
+ children: "Last 30 days"
134
+ })]
131
135
  }), /* @__PURE__ */ T("div", {
132
136
  className: "mt-4",
133
- children: H ? /* @__PURE__ */ T(O, { className: "h-[260px] w-full rounded-card" }) : /* @__PURE__ */ T(a, {
137
+ children: U ? /* @__PURE__ */ T(O, { className: "h-[260px] w-full rounded-card" }) : /* @__PURE__ */ T(a, {
134
138
  data: R,
135
139
  emptyLabel: "No applications filed recently."
136
140
  })
@@ -143,20 +147,23 @@ function F() {
143
147
  children: "Applications by status"
144
148
  }), /* @__PURE__ */ T("div", {
145
149
  className: "mt-3",
146
- children: V ? /* @__PURE__ */ T(O, { className: "h-[240px] w-full rounded-card" }) : z.length === 0 ? /* @__PURE__ */ T(f, {
150
+ children: H ? /* @__PURE__ */ T(O, { className: "h-[240px] w-full rounded-card" }) : z.length === 0 ? /* @__PURE__ */ T(f, {
147
151
  title: "No applications yet",
148
152
  description: "Filed applications will break down here by status."
149
153
  }) : /* @__PURE__ */ E(w, { children: [/* @__PURE__ */ T(o, {
150
154
  data: z,
151
- centerValue: l(U),
152
- centerLabel: "total"
155
+ centerValue: l(W),
156
+ centerLabel: "Total"
153
157
  }), /* @__PURE__ */ T(i, {
154
158
  className: "mt-4",
155
- items: z.map((e) => ({
156
- label: e.name,
157
- color: e.color,
158
- value: e.value
159
- }))
159
+ items: z.map((e) => {
160
+ let t = B || 1, n = Math.round(e.value / t * 100);
161
+ return {
162
+ label: e.name,
163
+ color: e.color,
164
+ value: `${l(e.value)} (${n}%)`
165
+ };
166
+ })
160
167
  })] })
161
168
  })]
162
169
  })]
@@ -164,43 +171,104 @@ function F() {
164
171
  /* @__PURE__ */ E(D, {
165
172
  treatment: "plain",
166
173
  className: "mt-6 border-border-seam p-5",
167
- children: [/* @__PURE__ */ T("h2", {
168
- className: "text-lg font-semibold text-text-primary",
169
- children: "Recent activity"
174
+ children: [/* @__PURE__ */ E("div", {
175
+ className: "flex items-center justify-between gap-4",
176
+ children: [/* @__PURE__ */ E("div", { children: [/* @__PURE__ */ T("h2", {
177
+ className: "text-lg font-semibold text-text-primary",
178
+ children: "Recent applications"
179
+ }), /* @__PURE__ */ T("p", {
180
+ className: "mt-0.5 text-xs text-text-muted",
181
+ children: "Latest filings (recent sample)"
182
+ })] }), /* @__PURE__ */ E("button", {
183
+ type: "button",
184
+ onClick: () => k("applications"),
185
+ className: "inline-flex items-center gap-1 text-sm font-medium text-action-primary-text outline-none transition-opacity hover:opacity-80 focus-visible:ring-1 focus-visible:ring-[var(--color-focus-ring)]",
186
+ children: ["View all ", /* @__PURE__ */ T(b, { className: "h-4 w-4" })]
187
+ })]
170
188
  }), /* @__PURE__ */ T("div", {
171
189
  className: "mt-3",
172
- children: H ? /* @__PURE__ */ T("div", {
190
+ children: U ? /* @__PURE__ */ T("div", {
173
191
  className: "space-y-3",
174
- children: Array.from({ length: 4 }, (e, t) => /* @__PURE__ */ T(O, { className: "h-14 w-full rounded-card" }, t))
175
- }) : B.length === 0 ? /* @__PURE__ */ T(f, {
192
+ children: Array.from({ length: 4 }, (e, t) => /* @__PURE__ */ T(O, { className: "h-12 w-full rounded-card" }, t))
193
+ }) : V.length === 0 ? /* @__PURE__ */ T(f, {
176
194
  illustration: "empty-data",
177
195
  title: "No applications yet",
178
196
  description: "Citizen applications will appear here as they are filed."
179
- }) : /* @__PURE__ */ T("ul", {
180
- className: "divide-y divide-border-subtle",
181
- children: B.map((e) => /* @__PURE__ */ T("li", { children: /* @__PURE__ */ E("button", {
182
- type: "button",
183
- onClick: () => k(`applications/${e.id}`),
184
- className: "group flex w-full items-center gap-3 py-3 text-left outline-none focus-visible:ring-1 focus-visible:ring-[var(--color-focus-ring)]",
185
- children: [
186
- /* @__PURE__ */ T("span", {
187
- className: "flex h-8 w-8 shrink-0 items-center justify-center rounded-button bg-accent-wash text-action-primary-bg",
188
- children: /* @__PURE__ */ T(S, { className: "h-4 w-4" })
189
- }),
190
- /* @__PURE__ */ E("span", {
191
- className: "min-w-0 flex-1",
192
- children: [/* @__PURE__ */ T("span", {
193
- className: "block truncate text-sm font-medium text-text-primary",
194
- children: e.reference
195
- }), /* @__PURE__ */ E("span", {
196
- className: "mt-0.5 block truncate text-xs text-text-muted",
197
- children: ["Filed ", u(e.createdAt)]
198
- })]
199
- }),
200
- /* @__PURE__ */ T(d, { status: e.status }),
201
- /* @__PURE__ */ T(b, { className: "h-4 w-4 shrink-0 text-text-muted transition-transform group-hover:translate-x-0.5" })
202
- ]
203
- }) }, e.id))
197
+ }) : /* @__PURE__ */ T("div", {
198
+ className: "overflow-x-auto",
199
+ children: /* @__PURE__ */ E("table", {
200
+ className: "w-full min-w-[34rem] border-collapse text-left",
201
+ children: [/* @__PURE__ */ T("thead", { children: /* @__PURE__ */ E("tr", {
202
+ className: "border-b border-border-seam text-xs font-medium uppercase tracking-wide text-text-muted",
203
+ children: [
204
+ /* @__PURE__ */ T("th", {
205
+ scope: "col",
206
+ className: "py-2.5 pr-3 font-medium",
207
+ children: "Reference No."
208
+ }),
209
+ /* @__PURE__ */ T("th", {
210
+ scope: "col",
211
+ className: "px-3 py-2.5 font-medium",
212
+ children: "Status"
213
+ }),
214
+ /* @__PURE__ */ T("th", {
215
+ scope: "col",
216
+ className: "px-3 py-2.5 font-medium",
217
+ children: "Priority"
218
+ }),
219
+ /* @__PURE__ */ T("th", {
220
+ scope: "col",
221
+ className: "px-3 py-2.5 font-medium",
222
+ children: "Submitted on"
223
+ }),
224
+ /* @__PURE__ */ T("th", {
225
+ scope: "col",
226
+ className: "w-8",
227
+ "aria-label": "Open"
228
+ })
229
+ ]
230
+ }) }), /* @__PURE__ */ T("tbody", { children: V.map((e) => /* @__PURE__ */ E("tr", {
231
+ tabIndex: 0,
232
+ role: "button",
233
+ "aria-label": `Open application ${e.reference}`,
234
+ onClick: () => k(`applications/${e.id}`),
235
+ onKeyDown: (t) => {
236
+ (t.key === "Enter" || t.key === " ") && (t.preventDefault(), k(`applications/${e.id}`));
237
+ },
238
+ className: "group cursor-pointer border-b border-border-subtle outline-none transition-colors last:border-0 hover:bg-bg-sunken/60 focus-visible:bg-bg-sunken/60",
239
+ children: [
240
+ /* @__PURE__ */ T("td", {
241
+ className: "py-3 pr-3",
242
+ children: /* @__PURE__ */ E("span", {
243
+ className: "flex items-center gap-2.5",
244
+ children: [/* @__PURE__ */ T("span", {
245
+ className: "flex size-8 shrink-0 items-center justify-center rounded-button bg-[var(--color-accent-soft)] text-action-primary-text",
246
+ children: /* @__PURE__ */ T(S, { className: "h-4 w-4" })
247
+ }), /* @__PURE__ */ T("span", {
248
+ className: "truncate text-sm font-medium text-text-primary",
249
+ children: e.reference
250
+ })]
251
+ })
252
+ }),
253
+ /* @__PURE__ */ T("td", {
254
+ className: "px-3 py-3",
255
+ children: /* @__PURE__ */ T(d, { status: e.status })
256
+ }),
257
+ /* @__PURE__ */ T("td", {
258
+ className: "px-3 py-3",
259
+ children: /* @__PURE__ */ T(d, { status: e.priority })
260
+ }),
261
+ /* @__PURE__ */ T("td", {
262
+ className: "px-3 py-3 text-sm text-text-secondary",
263
+ children: u(e.submittedAt ?? e.createdAt)
264
+ }),
265
+ /* @__PURE__ */ T("td", {
266
+ className: "pr-1",
267
+ children: /* @__PURE__ */ T(b, { className: "h-4 w-4 text-text-muted transition-transform group-hover:translate-x-0.5" })
268
+ })
269
+ ]
270
+ }, e.id)) })]
271
+ })
204
272
  })
205
273
  })]
206
274
  })
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardPage.js","names":[],"sources":["../../../src/govcitizenhub/pages/DashboardPage.tsx"],"sourcesContent":["/**\n * DashboardPage — the GovCitizenHub operations control center.\n * @module govcitizenhub/pages\n *\n * The six metric tiles and the \"Applications by status\" donut read from\n * `govDashboardSummary` — svc-computed, full-corpus AUTHORITATIVE counts, never\n * a capped client-side window. The \"Recent applications\" area trend and the\n * recent-activity list are the ONLY surfaces sourced from a paged read of the\n * latest applications, and are labelled as a recent sample so they never imply\n * a total.\n */\n\nimport { useMemo, useState } from 'react';\nimport {\n FileText,\n CreditCard,\n MessageSquareWarning,\n BadgeCheck,\n Briefcase,\n Building2,\n ChevronRight,\n} from 'lucide-react';\nimport { GlassCard, Skeleton } from '@burdenoff/fe-libs/ui';\n\nimport { PageLayout } from '../components/PageLayout';\nimport { MetricsCard } from '../components/MetricsCard';\nimport {\n GovAreaChart,\n GovDonutChart,\n ChartLegend,\n CHART_SERIES_COLORS,\n type AreaPoint,\n} from '../components/GovCharts';\nimport { StatusBadge } from '../components/StatusBadge';\nimport { EmptyState } from '../components/EmptyState';\nimport { useGovApplications, useGovDashboardSummary } from '../hooks';\nimport { useGovCitizenHub } from '../context';\nimport {\n formatNumber,\n formatCurrency,\n formatRelativeTime,\n formatEnumLabel,\n} from '../utils/formatters';\nimport type { GovApplicationStatus } from '../types';\n\nconst DAY_MS = 24 * 60 * 60 * 1000;\nconst TREND_DAYS = 30;\n/** Default currency for the aggregate pending-payments amount (svc summary has no currency). */\nconst DEFAULT_CURRENCY = 'INR';\n/** Size of the recent-applications window used for the trend + activity list only. */\nconst RECENT_WINDOW = 100;\n\n// Stable donut colour order — index into CHART_SERIES_COLORS by status.\nconst APP_STATUSES: GovApplicationStatus[] = [\n 'DRAFT',\n 'SUBMITTED',\n 'IN_REVIEW',\n 'INFO_REQUESTED',\n 'APPROVED',\n 'REJECTED',\n 'WITHDRAWN',\n];\n\nfunction buildTrendSeries(dates: string[], nowMs: number): AreaPoint[] {\n const now = new Date(nowMs);\n const start = new Date(now.getFullYear(), now.getMonth(), now.getDate());\n start.setTime(start.getTime() - (TREND_DAYS - 1) * DAY_MS);\n\n const perDay = new Array<number>(TREND_DAYS).fill(0);\n let baseline = 0;\n\n for (const iso of dates) {\n const when = new Date(iso);\n if (Number.isNaN(when.getTime())) continue;\n const dayIndex = Math.floor((when.getTime() - start.getTime()) / DAY_MS);\n if (dayIndex < 0) baseline += 1;\n else if (dayIndex < TREND_DAYS) perDay[dayIndex] += 1;\n }\n\n let running = baseline;\n return perDay.map((count, index) => {\n running += count;\n const day = new Date(start.getTime() + index * DAY_MS);\n return {\n label: day.toLocaleDateString(undefined, { month: 'short', day: 'numeric' }),\n value: running,\n };\n });\n}\n\nexport function DashboardPage() {\n const { navigateTo } = useGovCitizenHub();\n const [nowMs] = useState(() => Date.now());\n\n // Authoritative, backend-computed totals for every tile + the status donut.\n const summary = useGovDashboardSummary();\n // A recent window — ONLY drives the trend chart + recent-activity list.\n const applications = useGovApplications({ pagination: { limit: RECENT_WINDOW } });\n\n const appItems = useMemo(() => applications.data?.items ?? [], [applications.data]);\n\n const trend = useMemo(\n () =>\n buildTrendSeries(\n appItems.map((a) => a.createdAt),\n nowMs\n ),\n [appItems, nowMs]\n );\n\n const statusBuckets = useMemo(() => {\n const byStatus = summary.data?.applicationsByStatus ?? [];\n return byStatus\n .map((bucket) => {\n const orderIndex = APP_STATUSES.indexOf(bucket.status);\n const colorIndex = orderIndex >= 0 ? orderIndex : 0;\n return {\n name: formatEnumLabel(bucket.status),\n value: bucket.count,\n color: CHART_SERIES_COLORS[colorIndex % CHART_SERIES_COLORS.length],\n };\n })\n .filter((slice) => slice.value > 0);\n }, [summary.data]);\n\n const recent = useMemo(\n () =>\n [...appItems]\n .sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())\n .slice(0, 6),\n [appItems]\n );\n\n const metricsLoading = summary.isLoading;\n const trendLoading = applications.isLoading;\n const applicationsTotal = summary.data?.applicationsTotal ?? 0;\n const pendingAmount = summary.data?.pendingPaymentsAmount ?? 0;\n\n const cards = [\n {\n label: 'Applications',\n value: formatNumber(applicationsTotal),\n sublabel: 'filed to date',\n icon: <FileText className=\"h-5 w-5\" />,\n path: 'applications',\n featured: true,\n },\n {\n label: 'Pending payments',\n value: formatNumber(summary.data?.pendingPayments ?? 0),\n sublabel:\n pendingAmount > 0\n ? `${formatCurrency(pendingAmount, DEFAULT_CURRENCY)} due`\n : 'all settled',\n icon: <CreditCard className=\"h-5 w-5\" />,\n path: 'payments',\n accent: 'warning' as const,\n },\n {\n label: 'Open grievances',\n value: formatNumber(summary.data?.openGrievances ?? 0),\n sublabel: 'awaiting acknowledgement',\n icon: <MessageSquareWarning className=\"h-5 w-5\" />,\n path: 'grievances',\n },\n {\n label: 'Active permits',\n value: formatNumber(summary.data?.activePermits ?? 0),\n sublabel: 'currently valid',\n icon: <BadgeCheck className=\"h-5 w-5\" />,\n path: 'permits',\n accent: 'success' as const,\n },\n {\n label: 'Published services',\n value: formatNumber(summary.data?.publishedServices ?? 0),\n sublabel: 'available to citizens',\n icon: <Briefcase className=\"h-5 w-5\" />,\n path: 'services',\n },\n {\n label: 'Active agencies',\n value: formatNumber(summary.data?.activeAgencies ?? 0),\n sublabel: 'delivering services',\n icon: <Building2 className=\"h-5 w-5\" />,\n path: 'agencies',\n },\n ];\n\n return (\n <PageLayout\n title=\"GovCitizenHub\"\n titleGradient\n aurora\n description=\"Your live government service-delivery operations, at a glance.\"\n >\n <div className=\"grid grid-cols-2 gap-4 sm:grid-cols-3 xl:grid-cols-6\">\n {cards.map((card) => (\n <MetricsCard\n key={card.label}\n icon={card.icon}\n value={metricsLoading ? '—' : card.value}\n label={card.label}\n sublabel={card.sublabel}\n featured={card.featured}\n accent={card.accent}\n onClick={() => navigateTo(card.path)}\n />\n ))}\n </div>\n\n <div className=\"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-5\">\n <GlassCard treatment=\"glass\" className=\"p-5 lg:col-span-3\">\n <div className=\"flex items-start justify-between gap-4\">\n <div>\n <h2 className=\"text-lg font-semibold text-text-primary\">Recent applications</h2>\n <p className=\"mt-0.5 text-xs text-text-muted\">\n Last 30 days (recent sample, not a total)\n </p>\n </div>\n </div>\n <div className=\"mt-4\">\n {trendLoading ? (\n <Skeleton className=\"h-[260px] w-full rounded-card\" />\n ) : (\n <GovAreaChart data={trend} emptyLabel=\"No applications filed recently.\" />\n )}\n </div>\n </GlassCard>\n\n <GlassCard treatment=\"plain\" className=\"border-border-seam p-5 lg:col-span-2\">\n <h2 className=\"text-lg font-semibold text-text-primary\">Applications by status</h2>\n <div className=\"mt-3\">\n {metricsLoading ? (\n <Skeleton className=\"h-[240px] w-full rounded-card\" />\n ) : statusBuckets.length === 0 ? (\n <EmptyState\n title=\"No applications yet\"\n description=\"Filed applications will break down here by status.\"\n />\n ) : (\n <>\n <GovDonutChart\n data={statusBuckets}\n centerValue={formatNumber(applicationsTotal)}\n centerLabel=\"total\"\n />\n <ChartLegend\n className=\"mt-4\"\n items={statusBuckets.map((slice) => ({\n label: slice.name,\n color: slice.color,\n value: slice.value,\n }))}\n />\n </>\n )}\n </div>\n </GlassCard>\n </div>\n\n <GlassCard treatment=\"plain\" className=\"mt-6 border-border-seam p-5\">\n <h2 className=\"text-lg font-semibold text-text-primary\">Recent activity</h2>\n <div className=\"mt-3\">\n {trendLoading ? (\n <div className=\"space-y-3\">\n {Array.from({ length: 4 }, (_, i) => (\n <Skeleton key={i} className=\"h-14 w-full rounded-card\" />\n ))}\n </div>\n ) : recent.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title=\"No applications yet\"\n description=\"Citizen applications will appear here as they are filed.\"\n />\n ) : (\n <ul className=\"divide-y divide-border-subtle\">\n {recent.map((app) => (\n <li key={app.id}>\n <button\n type=\"button\"\n onClick={() => navigateTo(`applications/${app.id}`)}\n className=\"group flex w-full items-center gap-3 py-3 text-left outline-none focus-visible:ring-1 focus-visible:ring-[var(--color-focus-ring)]\"\n >\n <span className=\"flex h-8 w-8 shrink-0 items-center justify-center rounded-button bg-accent-wash text-action-primary-bg\">\n <FileText className=\"h-4 w-4\" />\n </span>\n <span className=\"min-w-0 flex-1\">\n <span className=\"block truncate text-sm font-medium text-text-primary\">\n {app.reference}\n </span>\n <span className=\"mt-0.5 block truncate text-xs text-text-muted\">\n Filed {formatRelativeTime(app.createdAt)}\n </span>\n </span>\n <StatusBadge status={app.status} />\n <ChevronRight className=\"h-4 w-4 shrink-0 text-text-muted transition-transform group-hover:translate-x-0.5\" />\n </button>\n </li>\n ))}\n </ul>\n )}\n </div>\n </GlassCard>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AA6CA,IAAM,IAAS,OAAU,KAAK,KACxB,IAAa,IAEb,IAAmB,OAEnB,IAAgB,KAGhB,IAAuC;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,SAAS,EAAiB,GAAiB,GAA4B;CACrE,IAAM,IAAM,IAAI,KAAK,EAAM,EACrB,IAAQ,IAAI,KAAK,EAAI,aAAa,EAAE,EAAI,UAAU,EAAE,EAAI,SAAS,CAAC;AACxE,GAAM,QAAQ,EAAM,SAAS,IAAI,IAAa,KAAK,EAAO;CAE1D,IAAM,IAAa,MAAc,EAAW,CAAC,KAAK,EAAE,EAChD,IAAW;AAEf,MAAK,IAAM,KAAO,GAAO;EACvB,IAAM,IAAO,IAAI,KAAK,EAAI;AAC1B,MAAI,OAAO,MAAM,EAAK,SAAS,CAAC,CAAE;EAClC,IAAM,IAAW,KAAK,OAAO,EAAK,SAAS,GAAG,EAAM,SAAS,IAAI,EAAO;AACxE,EAAI,IAAW,IAAG,KAAY,IACrB,IAAW,MAAY,EAAO,MAAa;;CAGtD,IAAI,IAAU;AACd,QAAO,EAAO,KAAK,GAAO,OACxB,KAAW,GAEJ;EACL,OAFU,IAAI,KAAK,EAAM,SAAS,GAAG,IAAQ,EAAO,CAEzC,mBAAmB,KAAA,GAAW;GAAE,OAAO;GAAS,KAAK;GAAW,CAAC;EAC5E,OAAO;EACR,EACD;;AAGJ,SAAgB,IAAgB;CAC9B,IAAM,EAAE,kBAAe,GAAkB,EACnC,CAAC,KAAS,QAAe,KAAK,KAAK,CAAC,EAGpC,IAAU,GAAwB,EAElC,IAAe,EAAmB,EAAE,YAAY,EAAE,OAAO,GAAe,EAAE,CAAC,EAE3E,IAAW,QAAc,EAAa,MAAM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BAAhB,CAAgE,UACvD,EAAmB,EAAI,UAAU,CACnC;YACF;;QACP,kBAAC,GAAD,EAAa,QAAQ,EAAI,QAAU,CAAA;QACnC,kBAAC,GAAD,EAAc,WAAU,qFAAsF,CAAA;QACvG;UACN,EApBI,EAAI,GAoBR,CACL;MACC,CAAA;KAEH,CAAA,CACI;;GACD"}
1
+ {"version":3,"file":"DashboardPage.js","names":[],"sources":["../../../src/govcitizenhub/pages/DashboardPage.tsx"],"sourcesContent":["/**\n * DashboardPage — the GovCitizenHub operations control center.\n * @module govcitizenhub/pages\n *\n * The six metric tiles and the \"Applications by status\" donut read from\n * `govDashboardSummary` — svc-computed, full-corpus AUTHORITATIVE counts, never\n * a capped client-side window. The \"Recent applications\" area trend and the\n * recent-activity list are the ONLY surfaces sourced from a paged read of the\n * latest applications, and are labelled as a recent sample so they never imply\n * a total.\n */\n\nimport { useMemo, useState } from 'react';\nimport {\n FileText,\n CreditCard,\n MessageSquareWarning,\n BadgeCheck,\n Briefcase,\n Building2,\n ChevronRight,\n} from 'lucide-react';\nimport { GlassCard, Skeleton } from '@burdenoff/fe-libs/ui';\n\nimport { PageLayout } from '../components/PageLayout';\nimport { MetricsCard } from '../components/MetricsCard';\nimport {\n GovAreaChart,\n GovDonutChart,\n ChartLegend,\n CHART_SERIES_COLORS,\n type AreaPoint,\n} from '../components/GovCharts';\nimport { StatusBadge } from '../components/StatusBadge';\nimport { EmptyState } from '../components/EmptyState';\nimport { useGovApplications, useGovDashboardSummary } from '../hooks';\nimport { useGovCitizenHub } from '../context';\nimport {\n formatNumber,\n formatCurrency,\n formatRelativeTime,\n formatEnumLabel,\n} from '../utils/formatters';\nimport type { GovApplicationStatus } from '../types';\n\nconst DAY_MS = 24 * 60 * 60 * 1000;\nconst TREND_DAYS = 30;\n/** Default currency for the aggregate pending-payments amount (svc summary has no currency). */\nconst DEFAULT_CURRENCY = 'INR';\n/** Size of the recent-applications window used for the trend + activity list only. */\nconst RECENT_WINDOW = 100;\n\n// Stable donut colour order — index into CHART_SERIES_COLORS by status.\nconst APP_STATUSES: GovApplicationStatus[] = [\n 'DRAFT',\n 'SUBMITTED',\n 'IN_REVIEW',\n 'INFO_REQUESTED',\n 'APPROVED',\n 'REJECTED',\n 'WITHDRAWN',\n];\n\nfunction buildTrendSeries(dates: string[], nowMs: number): AreaPoint[] {\n const now = new Date(nowMs);\n const start = new Date(now.getFullYear(), now.getMonth(), now.getDate());\n start.setTime(start.getTime() - (TREND_DAYS - 1) * DAY_MS);\n\n const perDay = new Array<number>(TREND_DAYS).fill(0);\n let baseline = 0;\n\n for (const iso of dates) {\n const when = new Date(iso);\n if (Number.isNaN(when.getTime())) continue;\n const dayIndex = Math.floor((when.getTime() - start.getTime()) / DAY_MS);\n if (dayIndex < 0) baseline += 1;\n else if (dayIndex < TREND_DAYS) perDay[dayIndex] += 1;\n }\n\n let running = baseline;\n return perDay.map((count, index) => {\n running += count;\n const day = new Date(start.getTime() + index * DAY_MS);\n return {\n label: day.toLocaleDateString(undefined, { month: 'short', day: 'numeric' }),\n value: running,\n };\n });\n}\n\nexport function DashboardPage() {\n const { navigateTo } = useGovCitizenHub();\n const [nowMs] = useState(() => Date.now());\n\n // Authoritative, backend-computed totals for every tile + the status donut.\n const summary = useGovDashboardSummary();\n // A recent window — ONLY drives the trend chart + recent-activity list.\n const applications = useGovApplications({ pagination: { limit: RECENT_WINDOW } });\n\n const appItems = useMemo(() => applications.data?.items ?? [], [applications.data]);\n\n const trend = useMemo(\n () =>\n buildTrendSeries(\n appItems.map((a) => a.createdAt),\n nowMs\n ),\n [appItems, nowMs]\n );\n\n const statusBuckets = useMemo(() => {\n const byStatus = summary.data?.applicationsByStatus ?? [];\n return byStatus\n .map((bucket) => {\n const orderIndex = APP_STATUSES.indexOf(bucket.status);\n const colorIndex = orderIndex >= 0 ? orderIndex : 0;\n return {\n name: formatEnumLabel(bucket.status),\n value: bucket.count,\n color: CHART_SERIES_COLORS[colorIndex % CHART_SERIES_COLORS.length],\n };\n })\n .filter((slice) => slice.value > 0);\n }, [summary.data]);\n\n const statusTotal = useMemo(\n () => statusBuckets.reduce((sum, slice) => sum + slice.value, 0),\n [statusBuckets]\n );\n\n const recent = useMemo(\n () =>\n [...appItems]\n .sort((a, b) => new Date(b.createdAt).getTime() - new Date(a.createdAt).getTime())\n .slice(0, 6),\n [appItems]\n );\n\n const metricsLoading = summary.isLoading;\n const trendLoading = applications.isLoading;\n const applicationsTotal = summary.data?.applicationsTotal ?? 0;\n const pendingAmount = summary.data?.pendingPaymentsAmount ?? 0;\n\n const cards = [\n {\n label: 'Applications',\n value: formatNumber(applicationsTotal),\n sublabel: 'filed to date',\n icon: <FileText className=\"h-5 w-5\" />,\n path: 'applications',\n featured: true,\n },\n {\n label: 'Pending payments',\n value: formatNumber(summary.data?.pendingPayments ?? 0),\n sublabel:\n pendingAmount > 0\n ? `${formatCurrency(pendingAmount, DEFAULT_CURRENCY)} due`\n : 'all settled',\n icon: <CreditCard className=\"h-5 w-5\" />,\n path: 'payments',\n accent: 'warning' as const,\n },\n {\n label: 'Open grievances',\n value: formatNumber(summary.data?.openGrievances ?? 0),\n sublabel: 'awaiting acknowledgement',\n icon: <MessageSquareWarning className=\"h-5 w-5\" />,\n path: 'grievances',\n accent: 'error' as const,\n },\n {\n label: 'Active permits',\n value: formatNumber(summary.data?.activePermits ?? 0),\n sublabel: 'currently valid',\n icon: <BadgeCheck className=\"h-5 w-5\" />,\n path: 'permits',\n accent: 'success' as const,\n },\n {\n label: 'Published services',\n value: formatNumber(summary.data?.publishedServices ?? 0),\n sublabel: 'available to citizens',\n icon: <Briefcase className=\"h-5 w-5\" />,\n path: 'services',\n },\n {\n label: 'Active agencies',\n value: formatNumber(summary.data?.activeAgencies ?? 0),\n sublabel: 'delivering services',\n icon: <Building2 className=\"h-5 w-5\" />,\n path: 'agencies',\n },\n ];\n\n return (\n <PageLayout\n title=\"GovCitizenHub\"\n titleGradient\n aurora\n description=\"Your live government service-delivery operations, at a glance.\"\n >\n <div className=\"grid grid-cols-2 gap-4 sm:grid-cols-3 xl:grid-cols-6\">\n {cards.map((card) => (\n <MetricsCard\n key={card.label}\n icon={card.icon}\n value={metricsLoading ? '—' : card.value}\n label={card.label}\n sublabel={card.sublabel}\n featured={card.featured}\n accent={card.accent}\n onClick={() => navigateTo(card.path)}\n />\n ))}\n </div>\n\n <div className=\"mt-6 grid grid-cols-1 gap-4 lg:grid-cols-5\">\n <GlassCard treatment=\"glass\" className=\"p-5 lg:col-span-3\">\n <div className=\"flex items-start justify-between gap-4\">\n <div>\n <h2 className=\"text-lg font-semibold text-text-primary\">Applications over time</h2>\n <p className=\"mt-0.5 text-xs text-text-muted\">\n Cumulative filings (recent sample, not a total)\n </p>\n </div>\n <span className=\"shrink-0 rounded-full border border-border-seam bg-bg-surface px-3 py-1 text-xs font-medium text-text-secondary\">\n Last 30 days\n </span>\n </div>\n <div className=\"mt-4\">\n {trendLoading ? (\n <Skeleton className=\"h-[260px] w-full rounded-card\" />\n ) : (\n <GovAreaChart data={trend} emptyLabel=\"No applications filed recently.\" />\n )}\n </div>\n </GlassCard>\n\n <GlassCard treatment=\"plain\" className=\"border-border-seam p-5 lg:col-span-2\">\n <h2 className=\"text-lg font-semibold text-text-primary\">Applications by status</h2>\n <div className=\"mt-3\">\n {metricsLoading ? (\n <Skeleton className=\"h-[240px] w-full rounded-card\" />\n ) : statusBuckets.length === 0 ? (\n <EmptyState\n title=\"No applications yet\"\n description=\"Filed applications will break down here by status.\"\n />\n ) : (\n <>\n <GovDonutChart\n data={statusBuckets}\n centerValue={formatNumber(applicationsTotal)}\n centerLabel=\"Total\"\n />\n <ChartLegend\n className=\"mt-4\"\n items={statusBuckets.map((slice) => {\n const denom = statusTotal || 1;\n const pct = Math.round((slice.value / denom) * 100);\n return {\n label: slice.name,\n color: slice.color,\n value: `${formatNumber(slice.value)} (${pct}%)`,\n };\n })}\n />\n </>\n )}\n </div>\n </GlassCard>\n </div>\n\n <GlassCard treatment=\"plain\" className=\"mt-6 border-border-seam p-5\">\n <div className=\"flex items-center justify-between gap-4\">\n <div>\n <h2 className=\"text-lg font-semibold text-text-primary\">Recent applications</h2>\n <p className=\"mt-0.5 text-xs text-text-muted\">Latest filings (recent sample)</p>\n </div>\n <button\n type=\"button\"\n onClick={() => navigateTo('applications')}\n className=\"inline-flex items-center gap-1 text-sm font-medium text-action-primary-text outline-none transition-opacity hover:opacity-80 focus-visible:ring-1 focus-visible:ring-[var(--color-focus-ring)]\"\n >\n View all <ChevronRight className=\"h-4 w-4\" />\n </button>\n </div>\n <div className=\"mt-3\">\n {trendLoading ? (\n <div className=\"space-y-3\">\n {Array.from({ length: 4 }, (_, i) => (\n <Skeleton key={i} className=\"h-12 w-full rounded-card\" />\n ))}\n </div>\n ) : recent.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title=\"No applications yet\"\n description=\"Citizen applications will appear here as they are filed.\"\n />\n ) : (\n <div className=\"overflow-x-auto\">\n <table className=\"w-full min-w-[34rem] border-collapse text-left\">\n <thead>\n <tr className=\"border-b border-border-seam text-xs font-medium uppercase tracking-wide text-text-muted\">\n <th scope=\"col\" className=\"py-2.5 pr-3 font-medium\">\n Reference No.\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 font-medium\">\n Status\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 font-medium\">\n Priority\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 font-medium\">\n Submitted on\n </th>\n <th scope=\"col\" className=\"w-8\" aria-label=\"Open\" />\n </tr>\n </thead>\n <tbody>\n {recent.map((app) => (\n <tr\n key={app.id}\n tabIndex={0}\n role=\"button\"\n aria-label={`Open application ${app.reference}`}\n onClick={() => navigateTo(`applications/${app.id}`)}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n navigateTo(`applications/${app.id}`);\n }\n }}\n className=\"group cursor-pointer border-b border-border-subtle outline-none transition-colors last:border-0 hover:bg-bg-sunken/60 focus-visible:bg-bg-sunken/60\"\n >\n <td className=\"py-3 pr-3\">\n <span className=\"flex items-center gap-2.5\">\n <span className=\"flex size-8 shrink-0 items-center justify-center rounded-button bg-[var(--color-accent-soft)] text-action-primary-text\">\n <FileText className=\"h-4 w-4\" />\n </span>\n <span className=\"truncate text-sm font-medium text-text-primary\">\n {app.reference}\n </span>\n </span>\n </td>\n <td className=\"px-3 py-3\">\n <StatusBadge status={app.status} />\n </td>\n <td className=\"px-3 py-3\">\n <StatusBadge status={app.priority} />\n </td>\n <td className=\"px-3 py-3 text-sm text-text-secondary\">\n {formatRelativeTime(app.submittedAt ?? app.createdAt)}\n </td>\n <td className=\"pr-1\">\n <ChevronRight className=\"h-4 w-4 text-text-muted transition-transform group-hover:translate-x-0.5\" />\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )}\n </div>\n </GlassCard>\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;AA6CA,IAAM,IAAS,OAAU,KAAK,KACxB,IAAa,IAEb,IAAmB,OAEnB,IAAgB,KAGhB,IAAuC;CAC3C;CACA;CACA;CACA;CACA;CACA;CACA;CACD;AAED,SAAS,EAAiB,GAAiB,GAA4B;CACrE,IAAM,IAAM,IAAI,KAAK,EAAM,EACrB,IAAQ,IAAI,KAAK,EAAI,aAAa,EAAE,EAAI,UAAU,EAAE,EAAI,SAAS,CAAC;AACxE,GAAM,QAAQ,EAAM,SAAS,IAAI,IAAa,KAAK,EAAO;CAE1D,IAAM,IAAa,MAAc,EAAW,CAAC,KAAK,EAAE,EAChD,IAAW;AAEf,MAAK,IAAM,KAAO,GAAO;EACvB,IAAM,IAAO,IAAI,KAAK,EAAI;AAC1B,MAAI,OAAO,MAAM,EAAK,SAAS,CAAC,CAAE;EAClC,IAAM,IAAW,KAAK,OAAO,EAAK,SAAS,GAAG,EAAM,SAAS,IAAI,EAAO;AACxE,EAAI,IAAW,IAAG,KAAY,IACrB,IAAW,MAAY,EAAO,MAAa;;CAGtD,IAAI,IAAU;AACd,QAAO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