@burdenoff/microfe-govcitizenhub 2026.705.3 → 2026.705.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +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 // GraphQL partial success: the gateway can attach a non-fatal top-level error\n // (e.g. a be-sdk activity/usage tracking side-effect) alongside a fully-resolved\n // payload. Only treat the request as failed when it produced NO usable data —\n // otherwise the operation genuinely succeeded and surfacing the background error\n // as a destructive toast would mislead the user.\n const data = response.data as Record<string, unknown> | null | undefined;\n const hasUsableData =\n data != null && Object.values(data).some((value) => value !== null && value !== undefined);\n\n if (!hasUsableData) {\n throw new Error(\n response.errors?.[0]?.message ?? 'GraphQL response did not include data'\n );\n }\n if (response.errors?.length) {\n // Non-fatal: keep the data, but leave a breadcrumb for diagnostics.\n console.warn('[govcitizenhub] GraphQL partial error (data returned):', response.errors);\n }\n return response.data as TData;\n};\n\n// React-Query key roots (one namespace per domain entity).\nconst KEY = {\n dashboard: ['govcitizenhub', 'dashboard-summary'] as const,\n 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;AAEF,CAAI,KAAU,GAA2B;CAOzC,IAAM,IAAO,EAAS;AAItB,KAAI,EAFF,KAAQ,QAAQ,OAAO,OAAO,EAAK,CAAC,MAAM,MAAU,KAAU,KAA4B,EAG1F,OAAU,MACR,EAAS,SAAS,IAAI,WAAW,wCAClC;AAMH,QAJI,EAAS,QAAQ,UAEnB,QAAQ,KAAK,0DAA0D,EAAS,OAAO,EAElF,EAAS;GAIZ,IAAM;CACV,WAAW,CAAC,iBAAiB,oBAAoB;CACjD,UAAU,CAAC,iBAAiB,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AY,CAAC,EAClD,EAAG,kBAAkB,EAAE,UAAU,EAAI,UAAU,EAAK,GAAG,EAAE,CAAC;;EAE7D,CAAC"}
|
|
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 // GraphQL partial success: the gateway can attach a non-fatal top-level error\n // (e.g. a be-sdk activity/usage tracking side-effect) alongside a fully-resolved\n // payload. Only treat the request as failed when it produced NO usable data —\n // otherwise the operation genuinely succeeded and surfacing the background error\n // as a destructive toast would mislead the user.\n const data = response.data as Record<string, unknown> | null | undefined;\n const hasUsableData =\n data != null && Object.values(data).some((value) => value !== null && value !== undefined);\n\n if (!hasUsableData) {\n throw new Error(response.errors?.[0]?.message ?? 'GraphQL response did not include data');\n }\n if (response.errors?.length) {\n // Non-fatal: keep the data, but leave a breadcrumb for diagnostics.\n console.warn('[govcitizenhub] GraphQL partial error (data returned):', response.errors);\n }\n return response.data as TData;\n};\n\n// React-Query key roots (one namespace per domain entity).\nconst KEY = {\n dashboard: ['govcitizenhub', 'dashboard-summary'] as const,\n 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;AAEF,CAAI,KAAU,GAA2B;CAOzC,IAAM,IAAO,EAAS;AAItB,KAAI,EAFF,KAAQ,QAAQ,OAAO,OAAO,EAAK,CAAC,MAAM,MAAU,KAAU,KAA4B,EAG1F,OAAU,MAAM,EAAS,SAAS,IAAI,WAAW,wCAAwC;AAM3F,QAJI,EAAS,QAAQ,UAEnB,QAAQ,KAAK,0DAA0D,EAAS,OAAO,EAElF,EAAS;GAIZ,IAAM;CACV,WAAW,CAAC,iBAAiB,oBAAoB;CACjD,UAAU,CAAC,iBAAiB,WAAW;CACvC,SAAS,MAAe;EAAC;EAAiB;EAAU;EAAG;CAC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U,EAAK,GAAG,EAAE,CAAC;;EAE7D,CAAC"}
|
|
@@ -86,23 +86,78 @@ function L({ assignedToId: e, currentUser: t }) {
|
|
|
86
86
|
}), "Unassigned"]
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
89
|
+
function R({ app: e, serviceName: t, currentUser: i, onOpen: a }) {
|
|
90
|
+
return /* @__PURE__ */ T("tr", {
|
|
91
|
+
role: "button",
|
|
92
|
+
tabIndex: 0,
|
|
93
|
+
"aria-label": `Open application ${e.reference}`,
|
|
94
|
+
onClick: a,
|
|
95
|
+
onKeyDown: (e) => {
|
|
96
|
+
(e.key === "Enter" || e.key === " ") && (e.preventDefault(), a());
|
|
97
|
+
},
|
|
98
|
+
className: "group cursor-pointer align-middle outline-none transition-colors hover:bg-bg-sunken focus-visible:bg-bg-sunken",
|
|
99
|
+
children: [
|
|
100
|
+
/* @__PURE__ */ T("td", {
|
|
101
|
+
className: "px-4 py-3",
|
|
102
|
+
children: [/* @__PURE__ */ w("span", {
|
|
103
|
+
className: "block truncate font-medium text-action-primary-text",
|
|
104
|
+
children: e.reference
|
|
105
|
+
}), /* @__PURE__ */ T("span", {
|
|
106
|
+
className: "text-xs text-text-muted",
|
|
107
|
+
children: ["Filed ", n(e.createdAt)]
|
|
108
|
+
})]
|
|
109
|
+
}),
|
|
110
|
+
/* @__PURE__ */ w("td", {
|
|
111
|
+
className: "px-4 py-3 text-sm text-text-secondary",
|
|
112
|
+
children: /* @__PURE__ */ w("span", {
|
|
113
|
+
className: "line-clamp-1",
|
|
114
|
+
children: t ?? "—"
|
|
115
|
+
})
|
|
116
|
+
}),
|
|
117
|
+
/* @__PURE__ */ w("td", {
|
|
118
|
+
className: "px-4 py-3",
|
|
119
|
+
children: /* @__PURE__ */ w(r, { status: e.priority })
|
|
120
|
+
}),
|
|
121
|
+
/* @__PURE__ */ w("td", {
|
|
122
|
+
className: "px-4 py-3",
|
|
123
|
+
children: /* @__PURE__ */ w(L, {
|
|
124
|
+
assignedToId: e.assignedToId,
|
|
125
|
+
currentUser: i
|
|
126
|
+
})
|
|
127
|
+
}),
|
|
128
|
+
/* @__PURE__ */ w("td", {
|
|
129
|
+
className: "px-4 py-3",
|
|
130
|
+
children: /* @__PURE__ */ T("div", {
|
|
131
|
+
className: "flex flex-col gap-0.5",
|
|
132
|
+
children: [/* @__PURE__ */ w(d, {
|
|
133
|
+
dueDate: e.dueDate,
|
|
134
|
+
status: e.status
|
|
135
|
+
}), e.dueDate && /* @__PURE__ */ T("span", {
|
|
136
|
+
className: "text-xs text-text-muted",
|
|
137
|
+
children: ["Due ", n(e.dueDate)]
|
|
138
|
+
})]
|
|
139
|
+
})
|
|
140
|
+
}),
|
|
141
|
+
/* @__PURE__ */ w("td", {
|
|
142
|
+
className: "px-4 py-3",
|
|
143
|
+
children: /* @__PURE__ */ w(r, { status: e.status })
|
|
144
|
+
}),
|
|
145
|
+
/* @__PURE__ */ w("td", {
|
|
146
|
+
className: "px-4 py-3 text-right",
|
|
147
|
+
children: /* @__PURE__ */ w(_, { className: "ml-auto size-4 shrink-0 text-text-muted transition-transform group-hover:translate-x-0.5" })
|
|
148
|
+
})
|
|
149
|
+
]
|
|
94
150
|
});
|
|
95
151
|
}
|
|
96
|
-
function
|
|
152
|
+
function z({ app: e, serviceName: t, currentUser: i, onOpen: a }) {
|
|
97
153
|
return /* @__PURE__ */ T("button", {
|
|
98
154
|
type: "button",
|
|
99
155
|
onClick: a,
|
|
100
156
|
"aria-label": `Open application ${e.reference}`,
|
|
101
|
-
|
|
102
|
-
className: `group flex w-full flex-col gap-2 px-5 py-4 text-left outline-none transition-colors hover:bg-bg-sunken focus-visible:bg-bg-sunken md:gap-4 ${R}`,
|
|
157
|
+
className: "flex w-full flex-col gap-2 px-4 py-4 text-left outline-none transition-colors hover:bg-bg-sunken focus-visible:bg-bg-sunken",
|
|
103
158
|
children: [
|
|
104
159
|
/* @__PURE__ */ T("div", {
|
|
105
|
-
className: "flex
|
|
160
|
+
className: "flex items-center justify-between gap-2",
|
|
106
161
|
children: [/* @__PURE__ */ T("span", {
|
|
107
162
|
className: "min-w-0",
|
|
108
163
|
children: [/* @__PURE__ */ w("span", {
|
|
@@ -112,66 +167,48 @@ function V({ app: e, serviceName: t, currentUser: i, onOpen: a }) {
|
|
|
112
167
|
className: "text-xs text-text-muted",
|
|
113
168
|
children: ["Filed ", n(e.createdAt)]
|
|
114
169
|
})]
|
|
115
|
-
}), /* @__PURE__ */ w(
|
|
116
|
-
className: "shrink-0 md:hidden",
|
|
117
|
-
children: /* @__PURE__ */ w(r, { status: e.status })
|
|
118
|
-
})]
|
|
119
|
-
}),
|
|
120
|
-
/* @__PURE__ */ T("div", {
|
|
121
|
-
className: "min-w-0 text-sm text-text-secondary",
|
|
122
|
-
children: [/* @__PURE__ */ w(B, { children: "Service:" }), /* @__PURE__ */ w("span", {
|
|
123
|
-
className: "truncate",
|
|
124
|
-
children: t ?? "—"
|
|
125
|
-
})]
|
|
170
|
+
}), /* @__PURE__ */ w(r, { status: e.status })]
|
|
126
171
|
}),
|
|
127
172
|
/* @__PURE__ */ w("div", {
|
|
128
|
-
className: "
|
|
129
|
-
children:
|
|
130
|
-
}),
|
|
131
|
-
/* @__PURE__ */ w("div", {
|
|
132
|
-
className: "min-w-0",
|
|
133
|
-
children: /* @__PURE__ */ w(L, {
|
|
134
|
-
assignedToId: e.assignedToId,
|
|
135
|
-
currentUser: i
|
|
136
|
-
})
|
|
173
|
+
className: "text-sm text-text-secondary",
|
|
174
|
+
children: t ?? "—"
|
|
137
175
|
}),
|
|
138
176
|
/* @__PURE__ */ T("div", {
|
|
139
|
-
className: "flex flex-wrap items-center gap-
|
|
140
|
-
children: [
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
})
|
|
152
|
-
/* @__PURE__ */ w(_, { className: "hidden size-4 shrink-0 text-text-muted transition-transform group-hover:translate-x-0.5 md:block" })
|
|
177
|
+
className: "flex flex-wrap items-center gap-2",
|
|
178
|
+
children: [
|
|
179
|
+
/* @__PURE__ */ w(r, { status: e.priority }),
|
|
180
|
+
/* @__PURE__ */ w(d, {
|
|
181
|
+
dueDate: e.dueDate,
|
|
182
|
+
status: e.status
|
|
183
|
+
}),
|
|
184
|
+
/* @__PURE__ */ w(L, {
|
|
185
|
+
assignedToId: e.assignedToId,
|
|
186
|
+
currentUser: i
|
|
187
|
+
})
|
|
188
|
+
]
|
|
189
|
+
})
|
|
153
190
|
]
|
|
154
191
|
});
|
|
155
192
|
}
|
|
156
|
-
function
|
|
193
|
+
function B() {
|
|
157
194
|
let { navigateTo: n, currentUser: r } = e(), d = c(), [f, _] = g("ALL"), [j, M] = g(""), { data: P, isLoading: F, isError: L, refetch: B } = a({
|
|
158
195
|
status: f === "ALL" ? void 0 : f,
|
|
159
196
|
pagination: {
|
|
160
197
|
limit: A,
|
|
161
198
|
cursor: d.cursor
|
|
162
199
|
}
|
|
163
|
-
}),
|
|
200
|
+
}), V = s({ pagination: { limit: 100 } }), H = o(), U = h(() => P?.items ?? [], [P]), W = h(() => {
|
|
164
201
|
let e = /* @__PURE__ */ new Map();
|
|
165
|
-
return
|
|
166
|
-
}, [
|
|
202
|
+
return V.data?.items.forEach((t) => e.set(t.id, t.name)), e;
|
|
203
|
+
}, [V.data]), G = h(() => {
|
|
167
204
|
let e = /* @__PURE__ */ new Map();
|
|
168
|
-
return
|
|
169
|
-
}, [
|
|
205
|
+
return H.data?.applicationsByStatus.forEach((t) => e.set(t.status, t.count)), e;
|
|
206
|
+
}, [H.data]), K = N.map((e) => ({
|
|
170
207
|
...e,
|
|
171
|
-
count: e.value === "ALL" ?
|
|
172
|
-
})),
|
|
208
|
+
count: e.value === "ALL" ? H.data?.applicationsTotal : G.get(e.value)
|
|
209
|
+
})), q = h(() => {
|
|
173
210
|
let e = 0, t = 0, n = 0;
|
|
174
|
-
for (let r of
|
|
211
|
+
for (let r of U) {
|
|
175
212
|
let i = I(r);
|
|
176
213
|
i === "ontrack" ? e += 1 : i === "duesoon" ? t += 1 : i === "overdue" && (n += 1);
|
|
177
214
|
}
|
|
@@ -180,35 +217,35 @@ function H() {
|
|
|
180
217
|
duesoon: t,
|
|
181
218
|
overdue: n
|
|
182
219
|
};
|
|
183
|
-
}, [
|
|
220
|
+
}, [U]), J = [
|
|
184
221
|
{
|
|
185
222
|
label: "On track",
|
|
186
|
-
value:
|
|
223
|
+
value: q.ontrack,
|
|
187
224
|
icon: /* @__PURE__ */ w(v, {}),
|
|
188
225
|
tone: "success"
|
|
189
226
|
},
|
|
190
227
|
{
|
|
191
228
|
label: "Due soon",
|
|
192
|
-
value:
|
|
229
|
+
value: q.duesoon,
|
|
193
230
|
icon: /* @__PURE__ */ w(y, {}),
|
|
194
231
|
tone: "warning"
|
|
195
232
|
},
|
|
196
233
|
{
|
|
197
234
|
label: "Overdue",
|
|
198
|
-
value:
|
|
235
|
+
value: q.overdue,
|
|
199
236
|
icon: /* @__PURE__ */ w(S, {}),
|
|
200
237
|
tone: "error"
|
|
201
238
|
}
|
|
202
|
-
],
|
|
239
|
+
], Y = h(() => {
|
|
203
240
|
let e = j.trim().toLowerCase();
|
|
204
|
-
return e ?
|
|
205
|
-
let n =
|
|
241
|
+
return e ? U.filter((t) => {
|
|
242
|
+
let n = W.get(t.serviceId) ?? "";
|
|
206
243
|
return t.reference.toLowerCase().includes(e) || n.toLowerCase().includes(e) || t.status.toLowerCase().includes(e);
|
|
207
|
-
}) :
|
|
244
|
+
}) : U;
|
|
208
245
|
}, [
|
|
209
|
-
|
|
246
|
+
U,
|
|
210
247
|
j,
|
|
211
|
-
|
|
248
|
+
W
|
|
212
249
|
]);
|
|
213
250
|
return /* @__PURE__ */ T(t, {
|
|
214
251
|
title: "Applications",
|
|
@@ -221,7 +258,7 @@ function H() {
|
|
|
221
258
|
children: [/* @__PURE__ */ T("div", {
|
|
222
259
|
className: "mb-5 flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between",
|
|
223
260
|
children: [/* @__PURE__ */ w(l, {
|
|
224
|
-
options:
|
|
261
|
+
options: K,
|
|
225
262
|
value: f,
|
|
226
263
|
onChange: (e) => {
|
|
227
264
|
_(e), M(""), d.reset();
|
|
@@ -245,7 +282,7 @@ function H() {
|
|
|
245
282
|
}) : L ? /* @__PURE__ */ w(u, {
|
|
246
283
|
message: "We couldn't load applications.",
|
|
247
284
|
onRetry: () => B()
|
|
248
|
-
}) :
|
|
285
|
+
}) : U.length === 0 && d.page === 0 ? /* @__PURE__ */ w(i, {
|
|
249
286
|
illustration: "empty-data",
|
|
250
287
|
title: "No applications found",
|
|
251
288
|
description: f === "ALL" ? "File the first application from a published service." : "No applications match this status.",
|
|
@@ -265,48 +302,82 @@ function H() {
|
|
|
265
302
|
className: "text-xs text-text-muted",
|
|
266
303
|
children: [
|
|
267
304
|
"Based on due date · ",
|
|
268
|
-
|
|
305
|
+
U.length,
|
|
269
306
|
" shown"
|
|
270
307
|
]
|
|
271
308
|
})]
|
|
272
|
-
}), /* @__PURE__ */ w(p, { stats:
|
|
309
|
+
}), /* @__PURE__ */ w(p, { stats: J })]
|
|
273
310
|
}),
|
|
274
|
-
/* @__PURE__ */
|
|
311
|
+
/* @__PURE__ */ w(D, {
|
|
275
312
|
treatment: "plain",
|
|
276
313
|
className: "overflow-hidden border-border-seam p-0",
|
|
277
|
-
children:
|
|
278
|
-
|
|
279
|
-
className: `hidden border-b border-border-seam px-5 py-2.5 text-xs font-medium uppercase tracking-wide text-text-muted ${R}`,
|
|
314
|
+
children: Y.length === 0 ? /* @__PURE__ */ T("p", {
|
|
315
|
+
className: "px-5 py-10 text-center text-sm text-text-secondary",
|
|
280
316
|
children: [
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
/* @__PURE__ */ w("span", { children: "Assigned officer" }),
|
|
285
|
-
/* @__PURE__ */ w("span", { children: "Due date (SLA)" }),
|
|
286
|
-
/* @__PURE__ */ w("span", { children: "Status" }),
|
|
287
|
-
/* @__PURE__ */ w("span", { "aria-hidden": "true" })
|
|
317
|
+
"No applications on this page match “",
|
|
318
|
+
j,
|
|
319
|
+
"”."
|
|
288
320
|
]
|
|
289
|
-
}), /* @__PURE__ */ w("div", {
|
|
290
|
-
className: "
|
|
291
|
-
children:
|
|
292
|
-
className: "
|
|
293
|
-
children: [
|
|
294
|
-
"
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
321
|
+
}) : /* @__PURE__ */ T(C, { children: [/* @__PURE__ */ w("div", {
|
|
322
|
+
className: "hidden overflow-x-auto md:block",
|
|
323
|
+
children: /* @__PURE__ */ T("table", {
|
|
324
|
+
className: "w-full text-left text-sm",
|
|
325
|
+
children: [/* @__PURE__ */ w("thead", { children: /* @__PURE__ */ T("tr", {
|
|
326
|
+
className: "border-b border-border-seam text-xs font-medium uppercase tracking-wide text-text-muted",
|
|
327
|
+
children: [
|
|
328
|
+
/* @__PURE__ */ w("th", {
|
|
329
|
+
className: "px-4 py-2.5 font-medium",
|
|
330
|
+
children: "Reference"
|
|
331
|
+
}),
|
|
332
|
+
/* @__PURE__ */ w("th", {
|
|
333
|
+
className: "px-4 py-2.5 font-medium",
|
|
334
|
+
children: "Service"
|
|
335
|
+
}),
|
|
336
|
+
/* @__PURE__ */ w("th", {
|
|
337
|
+
className: "px-4 py-2.5 font-medium",
|
|
338
|
+
children: "Priority"
|
|
339
|
+
}),
|
|
340
|
+
/* @__PURE__ */ w("th", {
|
|
341
|
+
className: "px-4 py-2.5 font-medium",
|
|
342
|
+
children: "Assigned officer"
|
|
343
|
+
}),
|
|
344
|
+
/* @__PURE__ */ w("th", {
|
|
345
|
+
className: "px-4 py-2.5 font-medium",
|
|
346
|
+
children: "Due date (SLA)"
|
|
347
|
+
}),
|
|
348
|
+
/* @__PURE__ */ w("th", {
|
|
349
|
+
className: "px-4 py-2.5 font-medium",
|
|
350
|
+
children: "Status"
|
|
351
|
+
}),
|
|
352
|
+
/* @__PURE__ */ w("th", {
|
|
353
|
+
className: "px-4 py-2.5",
|
|
354
|
+
"aria-hidden": "true"
|
|
355
|
+
})
|
|
356
|
+
]
|
|
357
|
+
}) }), /* @__PURE__ */ w("tbody", {
|
|
358
|
+
className: "divide-y divide-border-subtle",
|
|
359
|
+
children: Y.map((e) => /* @__PURE__ */ w(R, {
|
|
360
|
+
app: e,
|
|
361
|
+
serviceName: W.get(e.serviceId),
|
|
362
|
+
currentUser: r,
|
|
363
|
+
onOpen: () => n(`applications/${e.id}`)
|
|
364
|
+
}, e.id))
|
|
365
|
+
})]
|
|
366
|
+
})
|
|
367
|
+
}), /* @__PURE__ */ w("ul", {
|
|
368
|
+
className: "divide-y divide-border-subtle md:hidden",
|
|
369
|
+
children: Y.map((e) => /* @__PURE__ */ w("li", { children: /* @__PURE__ */ w(z, {
|
|
299
370
|
app: e,
|
|
300
|
-
serviceName:
|
|
371
|
+
serviceName: W.get(e.serviceId),
|
|
301
372
|
currentUser: r,
|
|
302
373
|
onOpen: () => n(`applications/${e.id}`)
|
|
303
|
-
}, e.id))
|
|
304
|
-
})]
|
|
374
|
+
}) }, e.id))
|
|
375
|
+
})] })
|
|
305
376
|
}),
|
|
306
377
|
/* @__PURE__ */ w(m, {
|
|
307
378
|
page: d.page,
|
|
308
379
|
pageSize: A,
|
|
309
|
-
itemCount:
|
|
380
|
+
itemCount: U.length,
|
|
310
381
|
hasMore: P?.pageInfo.hasMore ?? !1,
|
|
311
382
|
onPageChange: (e) => d.onPageChange(e, P?.pageInfo.cursor)
|
|
312
383
|
})
|
|
@@ -314,6 +385,6 @@ function H() {
|
|
|
314
385
|
});
|
|
315
386
|
}
|
|
316
387
|
//#endregion
|
|
317
|
-
export {
|
|
388
|
+
export { B as ApplicationsPage };
|
|
318
389
|
|
|
319
390
|
//# sourceMappingURL=ApplicationsPage.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApplicationsPage.js","names":[],"sources":["../../../../src/govcitizenhub/pages/applications/ApplicationsPage.tsx"],"sourcesContent":["/**\n * ApplicationsPage — the casework queue (citizen filings + officer review).\n * @module govcitizenhub/pages/applications\n *\n * Reads `govListApplications` filtered by status with cursor pagination, and joins\n * `govListServices` for the service name column and `govDashboardSummary` for the\n * authoritative per-status tab counts. Each row surfaces reference + filed date,\n * service, a priority chip, an SLA badge computed from dueDate + status, the\n * assigned officer (real identity only — self shows you, others show a neutral id\n * chip, unassigned is explicit), and the status pill. A SummaryStrip above the\n * list reports On-track / Due-soon / Overdue for the CURRENT page (honest window).\n * Rows link to the casework workspace where the full lifecycle is managed.\n */\n\nimport { useMemo, useState, type ReactNode } from 'react';\nimport { Plus, ChevronRight, Search, CircleCheck, Clock, TriangleAlert } from 'lucide-react';\nimport { Button, GlassCard, Skeleton, Input } from '@burdenoff/fe-libs/ui';\n\nimport { PageLayout } from '../../components/PageLayout';\nimport { FilterTabs, type FilterOption } from '../../components/FilterTabs';\nimport { StatusBadge } from '../../components/StatusBadge';\nimport { SlaBadge } from '../../components/SlaBadge';\nimport { AssigneeChip } from '../../components/Avatar';\nimport { SummaryStrip, type SummaryStat } from '../../components/SummaryStrip';\nimport { EmptyState } from '../../components/EmptyState';\nimport { ErrorView } from '../../components/StateViews';\nimport { Pagination } from '../../components/Pagination';\nimport {\n useGovApplications,\n useGovServices,\n useGovDashboardSummary,\n useCursorPager,\n} from '../../hooks';\nimport { useGovCitizenHub } from '../../context';\nimport { formatDate } from '../../utils/formatters';\nimport type { GovApplication, GovApplicationStatus, CurrentUser } from '../../types';\n\nconst PAGE_SIZE = 15;\n\n/** Best available display name for the signed-in officer (never fabricated for others). */\nfunction userDisplayName(user?: CurrentUser | null): string | undefined {\n if (!user) return undefined;\n const full = [user.firstName, user.lastName].filter(Boolean).join(' ').trim();\n return user.name?.trim() || full || user.username?.trim() || user.email;\n}\n\n/** First 8 chars of an opaque actor id — an honest reference, not a name. */\nconst shortId = (id: string): string => id.slice(0, 8);\n\ntype StatusFilter = 'ALL' | GovApplicationStatus;\n\nconst STATUS_OPTIONS: { value: StatusFilter; label: string }[] = [\n { value: 'ALL', label: 'All' },\n { value: 'SUBMITTED', label: 'Submitted' },\n { value: 'IN_REVIEW', label: 'In review' },\n { value: 'INFO_REQUESTED', label: 'Info requested' },\n { value: 'APPROVED', label: 'Approved' },\n { value: 'REJECTED', label: 'Rejected' },\n { value: 'DRAFT', label: 'Draft' },\n];\n\n/** Statuses whose SLA clock has stopped — excluded from the page SLA summary. */\nconst TERMINAL = new Set<GovApplicationStatus>(['APPROVED', 'REJECTED', 'WITHDRAWN']);\n\n/** Whole calendar days until `due` (>0 future, 0 today, <0 overdue). */\nfunction daysUntilDue(due: Date): number {\n const startOfDay = (d: Date) => new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();\n return Math.round((startOfDay(due) - startOfDay(new Date())) / 86_400_000);\n}\n\ntype SlaBucket = 'ontrack' | 'duesoon' | 'overdue' | 'none';\n\nfunction slaBucketOf(app: GovApplication): SlaBucket {\n if (TERMINAL.has(app.status) || !app.dueDate) return 'none';\n const due = new Date(app.dueDate);\n if (Number.isNaN(due.getTime())) return 'none';\n const days = daysUntilDue(due);\n if (days < 0) return 'overdue';\n if (days <= 2) return 'duesoon';\n return 'ontrack';\n}\n\n// ---------------------------------------------------------------------------\n// Assigned-officer cell — real identity only, never a fabricated name.\n// ---------------------------------------------------------------------------\n\nfunction AssignedCell({\n assignedToId,\n currentUser,\n}: {\n assignedToId?: string | null;\n currentUser?: CurrentUser | null;\n}) {\n if (!assignedToId) {\n return (\n <span className=\"inline-flex items-center gap-2 text-sm text-text-muted\">\n <span\n aria-hidden=\"true\"\n className=\"inline-flex size-8 items-center justify-center rounded-full border border-dashed border-border-seam text-text-muted\"\n >\n <Plus className=\"size-3.5\" />\n </span>\n Unassigned\n </span>\n );\n }\n if (currentUser?.id && assignedToId === currentUser.id) {\n return (\n <AssigneeChip\n name={userDisplayName(currentUser) ?? 'You'}\n src={currentUser.avatar}\n subtitle=\"You\"\n />\n );\n }\n return <AssigneeChip name=\"Assigned officer\" subtitle={`#${shortId(assignedToId)}`} />;\n}\n\n// ---------------------------------------------------------------------------\n// Queue row — responsive: card on mobile, grid row on md+.\n// ---------------------------------------------------------------------------\n\n// Shared 7-column template so the header row and every data row align exactly.\n// The column widths are applied via an inline `gridTemplateColumns` style (not an\n// arbitrary Tailwind class) so they survive build-time MFE composition, where the\n// host shell's Tailwind pass does not emit the MFE's arbitrary `grid-cols-[…]`\n// utilities. Only the standard `md:grid` display toggle comes from Tailwind.\nconst GRID_COLS = 'md:grid md:items-center md:gap-4';\nconst GRID_TEMPLATE = '1.6fr 1.2fr 0.9fr 1.4fr 1.1fr 1fr auto';\n\n/** A mobile-only inline field label (hidden once the grid columns take over). */\nfunction MobileLabel({ children }: { children: ReactNode }) {\n return <span className=\"mr-1 text-text-muted md:hidden\">{children}</span>;\n}\n\nfunction QueueRow({\n app,\n serviceName,\n currentUser,\n onOpen,\n}: {\n app: GovApplication;\n serviceName?: string;\n currentUser?: CurrentUser | null;\n onOpen: () => void;\n}) {\n return (\n <button\n type=\"button\"\n onClick={onOpen}\n aria-label={`Open application ${app.reference}`}\n style={{ gridTemplateColumns: GRID_TEMPLATE }}\n className={`group flex w-full flex-col gap-2 px-5 py-4 text-left outline-none transition-colors hover:bg-bg-sunken focus-visible:bg-bg-sunken md:gap-4 ${GRID_COLS}`}\n >\n {/* 1 · Reference + filed */}\n <div className=\"flex min-w-0 items-center justify-between gap-2 md:block\">\n <span className=\"min-w-0\">\n <span className=\"block truncate font-medium text-action-primary-text\">\n {app.reference}\n </span>\n <span className=\"text-xs text-text-muted\">Filed {formatDate(app.createdAt)}</span>\n </span>\n {/* Status echoes at the top on mobile for a scannable card header */}\n <span className=\"shrink-0 md:hidden\">\n <StatusBadge status={app.status} />\n </span>\n </div>\n\n {/* 2 · Service */}\n <div className=\"min-w-0 text-sm text-text-secondary\">\n <MobileLabel>Service:</MobileLabel>\n <span className=\"truncate\">{serviceName ?? '—'}</span>\n </div>\n\n {/* 3 · Priority */}\n <div className=\"min-w-0\">\n <StatusBadge status={app.priority} />\n </div>\n\n {/* 4 · Assigned officer */}\n <div className=\"min-w-0\">\n <AssignedCell assignedToId={app.assignedToId} currentUser={currentUser} />\n </div>\n\n {/* 5 · Due date (SLA) */}\n <div className=\"flex flex-wrap items-center gap-x-2 gap-y-0.5 md:flex-col md:items-start\">\n <SlaBadge dueDate={app.dueDate} status={app.status} />\n {app.dueDate && (\n <span className=\"text-xs text-text-muted\">Due {formatDate(app.dueDate)}</span>\n )}\n </div>\n\n {/* 6 · Status (desktop column; hidden on mobile where it sits in the header) */}\n <div className=\"hidden md:block\">\n <StatusBadge status={app.status} />\n </div>\n\n {/* 7 · Chevron (desktop) */}\n <ChevronRight className=\"hidden size-4 shrink-0 text-text-muted transition-transform group-hover:translate-x-0.5 md:block\" />\n </button>\n );\n}\n\nexport function ApplicationsPage() {\n const { navigateTo, currentUser } = useGovCitizenHub();\n const pager = useCursorPager();\n const [status, setStatus] = useState<StatusFilter>('ALL');\n const [search, setSearch] = useState('');\n\n const { data, isLoading, isError, refetch } = useGovApplications({\n status: status === 'ALL' ? undefined : status,\n pagination: { limit: PAGE_SIZE, cursor: pager.cursor },\n });\n const servicesQuery = useGovServices({ pagination: { limit: 100 } });\n const summary = useGovDashboardSummary();\n\n const applications = useMemo(() => data?.items ?? [], [data]);\n\n const serviceName = useMemo(() => {\n const map = new Map<string, string>();\n servicesQuery.data?.items.forEach((svc) => map.set(svc.id, svc.name));\n return map;\n }, [servicesQuery.data]);\n\n // Authoritative per-status tab counts from the backend-computed dashboard.\n const statusCount = useMemo(() => {\n const map = new Map<GovApplicationStatus, number>();\n summary.data?.applicationsByStatus.forEach((entry) => map.set(entry.status, entry.count));\n return map;\n }, [summary.data]);\n\n const tabs: FilterOption<StatusFilter>[] = STATUS_OPTIONS.map((opt) => ({\n ...opt,\n count:\n opt.value === 'ALL'\n ? summary.data?.applicationsTotal\n : statusCount.get(opt.value as GovApplicationStatus),\n }));\n\n // SLA summary over the CURRENT page (honest window — not the whole corpus).\n const sla = useMemo(() => {\n let ontrack = 0;\n let duesoon = 0;\n let overdue = 0;\n for (const app of applications) {\n const bucket = slaBucketOf(app);\n if (bucket === 'ontrack') ontrack += 1;\n else if (bucket === 'duesoon') duesoon += 1;\n else if (bucket === 'overdue') overdue += 1;\n }\n return { ontrack, duesoon, overdue };\n }, [applications]);\n\n const slaStats: SummaryStat[] = [\n { label: 'On track', value: sla.ontrack, icon: <CircleCheck />, tone: 'success' },\n { label: 'Due soon', value: sla.duesoon, icon: <Clock />, tone: 'warning' },\n { label: 'Overdue', value: sla.overdue, icon: <TriangleAlert />, tone: 'error' },\n ];\n\n const visible = useMemo(() => {\n const term = search.trim().toLowerCase();\n if (!term) return applications;\n return applications.filter((app) => {\n const svc = serviceName.get(app.serviceId) ?? '';\n return (\n app.reference.toLowerCase().includes(term) ||\n svc.toLowerCase().includes(term) ||\n app.status.toLowerCase().includes(term)\n );\n });\n }, [applications, search, serviceName]);\n\n const changeStatus = (next: StatusFilter) => {\n setStatus(next);\n setSearch('');\n pager.reset();\n };\n\n return (\n <PageLayout\n title=\"Applications\"\n titleGradient\n description=\"Citizen applications moving through review, decision, and fulfilment.\"\n actions={\n <Button onClick={() => navigateTo('applications/new')}>\n <Plus className=\"mr-1.5 h-4 w-4\" /> New application\n </Button>\n }\n >\n {/* Toolbar: status tabs + search */}\n <div className=\"mb-5 flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between\">\n <FilterTabs options={tabs} value={status} onChange={changeStatus} />\n <div className=\"relative lg:w-80\">\n <Search\n className=\"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-text-muted\"\n aria-hidden=\"true\"\n />\n <Input\n value={search}\n onChange={(e) => setSearch(e.target.value)}\n placeholder=\"Search by reference or service…\"\n aria-label=\"Search applications on this page\"\n className=\"pl-9\"\n />\n </div>\n </div>\n\n {isLoading ? (\n <div className=\"space-y-3\">\n {Array.from({ length: 6 }, (_, i) => (\n <Skeleton key={i} className=\"h-16 w-full rounded-card\" />\n ))}\n </div>\n ) : isError ? (\n <ErrorView message=\"We couldn't load applications.\" onRetry={() => refetch()} />\n ) : applications.length === 0 && pager.page === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title=\"No applications found\"\n description={\n status === 'ALL'\n ? 'File the first application from a published service.'\n : 'No applications match this status.'\n }\n action={\n <Button onClick={() => navigateTo('applications/new')}>\n <Plus className=\"mr-1.5 h-4 w-4\" /> New application\n </Button>\n }\n />\n ) : (\n <>\n {/* SLA summary for the current page */}\n <div className=\"mb-4\">\n <div className=\"mb-2 flex items-center gap-2\">\n <h2 className=\"text-sm font-semibold text-text-primary\">SLA on this page</h2>\n <span className=\"text-xs text-text-muted\">\n Based on due date · {applications.length} shown\n </span>\n </div>\n <SummaryStrip stats={slaStats} />\n </div>\n\n {/* Queue list */}\n <GlassCard treatment=\"plain\" className=\"overflow-hidden border-border-seam p-0\">\n {/* Column header (desktop) */}\n <div\n style={{ gridTemplateColumns: GRID_TEMPLATE }}\n className={`hidden border-b border-border-seam px-5 py-2.5 text-xs font-medium uppercase tracking-wide text-text-muted ${GRID_COLS}`}\n >\n <span>Reference</span>\n <span>Service</span>\n <span>Priority</span>\n <span>Assigned officer</span>\n <span>Due date (SLA)</span>\n <span>Status</span>\n <span aria-hidden=\"true\" />\n </div>\n\n <div className=\"divide-y divide-border-subtle\">\n {visible.length === 0 ? (\n <p className=\"px-5 py-10 text-center text-sm text-text-secondary\">\n No applications on this page match “{search}”.\n </p>\n ) : (\n visible.map((app) => (\n <QueueRow\n key={app.id}\n app={app}\n serviceName={serviceName.get(app.serviceId)}\n currentUser={currentUser}\n onOpen={() => navigateTo(`applications/${app.id}`)}\n />\n ))\n )}\n </div>\n </GlassCard>\n\n <Pagination\n page={pager.page}\n pageSize={PAGE_SIZE}\n itemCount={applications.length}\n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E,qBAAqB,GAAe;KAC7C,WAAW,8GAA8G;eAF3H;MAIE,kBAAC,QAAD,EAAA,UAAM,aAAgB,CAAA;MACtB,kBAAC,QAAD,EAAA,UAAM,WAAc,CAAA;MACpB,kBAAC,QAAD,EAAA,UAAM,YAAe,CAAA;MACrB,kBAAC,QAAD,EAAA,UAAM,oBAAuB,CAAA;MAC7B,kBAAC,QAAD,EAAA,UAAM,kBAAqB,CAAA;MAC3B,kBAAC,QAAD,EAAA,UAAM,UAAa,CAAA;MACnB,kBAAC,QAAD,EAAM,eAAY,QAAS,CAAA;MACvB;QAEN,kBAAC,OAAD;KAAK,WAAU;eACZ,EAAQ,WAAW,IAClB,kBAAC,KAAD;MAAG,WAAU;gBAAb;OAAkE;OAC3B;OAAO;OAC1C;UAEJ,EAAQ,KAAK,MACX,kBAAC,GAAD;MAEO;MACL,aAAa,EAAY,IAAI,EAAI,UAAU;MAC9B;MACb,cAAc,EAAW,gBAAgB,EAAI,KAAK;MAClD,EALK,EAAI,GAKT,CACF;KAEA,CAAA,CACI;;GAEZ,kBAAC,GAAD;IACE,MAAM,EAAM;IACZ,UAAU;IACV,WAAW,EAAa;IACxB,SAAS,GAAM,SAAS,WAAW;IACnC,eAAe,MAAW,EAAM,aAAa,GAAQ,GAAM,SAAS,OAAO;IAC3E,CAAA;GACD,EAAA,CAAA,CAEM"}
|
|
1
|
+
{"version":3,"file":"ApplicationsPage.js","names":[],"sources":["../../../../src/govcitizenhub/pages/applications/ApplicationsPage.tsx"],"sourcesContent":["/**\n * ApplicationsPage — the casework queue (citizen filings + officer review).\n * @module govcitizenhub/pages/applications\n *\n * Reads `govListApplications` filtered by status with cursor pagination, and joins\n * `govListServices` for the service name column and `govDashboardSummary` for the\n * authoritative per-status tab counts. Each row surfaces reference + filed date,\n * service, a priority chip, an SLA badge computed from dueDate + status, the\n * assigned officer (real identity only — self shows you, others show a neutral id\n * chip, unassigned is explicit), and the status pill. A SummaryStrip above the\n * list reports On-track / Due-soon / Overdue for the CURRENT page (honest window).\n * Rows link to the casework workspace where the full lifecycle is managed.\n */\n\nimport { useMemo, useState } from 'react';\nimport { Plus, ChevronRight, Search, CircleCheck, Clock, TriangleAlert } from 'lucide-react';\nimport { Button, GlassCard, Skeleton, Input } from '@burdenoff/fe-libs/ui';\n\nimport { PageLayout } from '../../components/PageLayout';\nimport { FilterTabs, type FilterOption } from '../../components/FilterTabs';\nimport { StatusBadge } from '../../components/StatusBadge';\nimport { SlaBadge } from '../../components/SlaBadge';\nimport { AssigneeChip } from '../../components/Avatar';\nimport { SummaryStrip, type SummaryStat } from '../../components/SummaryStrip';\nimport { EmptyState } from '../../components/EmptyState';\nimport { ErrorView } from '../../components/StateViews';\nimport { Pagination } from '../../components/Pagination';\nimport {\n useGovApplications,\n useGovServices,\n useGovDashboardSummary,\n useCursorPager,\n} from '../../hooks';\nimport { useGovCitizenHub } from '../../context';\nimport { formatDate } from '../../utils/formatters';\nimport type { GovApplication, GovApplicationStatus, CurrentUser } from '../../types';\n\nconst PAGE_SIZE = 15;\n\n/** Best available display name for the signed-in officer (never fabricated for others). */\nfunction userDisplayName(user?: CurrentUser | null): string | undefined {\n if (!user) return undefined;\n const full = [user.firstName, user.lastName].filter(Boolean).join(' ').trim();\n return user.name?.trim() || full || user.username?.trim() || user.email;\n}\n\n/** First 8 chars of an opaque actor id — an honest reference, not a name. */\nconst shortId = (id: string): string => id.slice(0, 8);\n\ntype StatusFilter = 'ALL' | GovApplicationStatus;\n\nconst STATUS_OPTIONS: { value: StatusFilter; label: string }[] = [\n { value: 'ALL', label: 'All' },\n { value: 'SUBMITTED', label: 'Submitted' },\n { value: 'IN_REVIEW', label: 'In review' },\n { value: 'INFO_REQUESTED', label: 'Info requested' },\n { value: 'APPROVED', label: 'Approved' },\n { value: 'REJECTED', label: 'Rejected' },\n { value: 'DRAFT', label: 'Draft' },\n];\n\n/** Statuses whose SLA clock has stopped — excluded from the page SLA summary. */\nconst TERMINAL = new Set<GovApplicationStatus>(['APPROVED', 'REJECTED', 'WITHDRAWN']);\n\n/** Whole calendar days until `due` (>0 future, 0 today, <0 overdue). */\nfunction daysUntilDue(due: Date): number {\n const startOfDay = (d: Date) => new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();\n return Math.round((startOfDay(due) - startOfDay(new Date())) / 86_400_000);\n}\n\ntype SlaBucket = 'ontrack' | 'duesoon' | 'overdue' | 'none';\n\nfunction slaBucketOf(app: GovApplication): SlaBucket {\n if (TERMINAL.has(app.status) || !app.dueDate) return 'none';\n const due = new Date(app.dueDate);\n if (Number.isNaN(due.getTime())) return 'none';\n const days = daysUntilDue(due);\n if (days < 0) return 'overdue';\n if (days <= 2) return 'duesoon';\n return 'ontrack';\n}\n\n// ---------------------------------------------------------------------------\n// Assigned-officer cell — real identity only, never a fabricated name.\n// ---------------------------------------------------------------------------\n\nfunction AssignedCell({\n assignedToId,\n currentUser,\n}: {\n assignedToId?: string | null;\n currentUser?: CurrentUser | null;\n}) {\n if (!assignedToId) {\n return (\n <span className=\"inline-flex items-center gap-2 text-sm text-text-muted\">\n <span\n aria-hidden=\"true\"\n className=\"inline-flex size-8 items-center justify-center rounded-full border border-dashed border-border-seam text-text-muted\"\n >\n <Plus className=\"size-3.5\" />\n </span>\n Unassigned\n </span>\n );\n }\n if (currentUser?.id && assignedToId === currentUser.id) {\n return (\n <AssigneeChip\n name={userDisplayName(currentUser) ?? 'You'}\n src={currentUser.avatar}\n subtitle=\"You\"\n />\n );\n }\n return <AssigneeChip name=\"Assigned officer\" subtitle={`#${shortId(assignedToId)}`} />;\n}\n\n// ---------------------------------------------------------------------------\n// Queue rows — desktop <table> + mobile stacked cards.\n//\n// We use a NATIVE <table> (display:table) gated by `hidden md:block`, NOT a\n// Tailwind grid. Build-time MFE composition means only the utility classes the\n// host shell itself emits are available to this MFE, and `md:grid` / `md:table`\n// are not among them (verified: they fall back to `display:block`), whereas\n// `md:block` / `md:hidden` / `md:flex` are. A grid-based responsive row would\n// therefore silently collapse to the mobile layout at desktop width.\n// ---------------------------------------------------------------------------\n\nfunction QueueTableRow({\n app,\n serviceName,\n currentUser,\n onOpen,\n}: {\n app: GovApplication;\n serviceName?: string;\n currentUser?: CurrentUser | null;\n onOpen: () => void;\n}) {\n return (\n <tr\n role=\"button\"\n tabIndex={0}\n aria-label={`Open application ${app.reference}`}\n onClick={onOpen}\n onKeyDown={(e) => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault();\n onOpen();\n }\n }}\n className=\"group cursor-pointer align-middle outline-none transition-colors hover:bg-bg-sunken focus-visible:bg-bg-sunken\"\n >\n <td className=\"px-4 py-3\">\n <span className=\"block truncate font-medium text-action-primary-text\">{app.reference}</span>\n <span className=\"text-xs text-text-muted\">Filed {formatDate(app.createdAt)}</span>\n </td>\n <td className=\"px-4 py-3 text-sm text-text-secondary\">\n <span className=\"line-clamp-1\">{serviceName ?? '—'}</span>\n </td>\n <td className=\"px-4 py-3\">\n <StatusBadge status={app.priority} />\n </td>\n <td className=\"px-4 py-3\">\n <AssignedCell assignedToId={app.assignedToId} currentUser={currentUser} />\n </td>\n <td className=\"px-4 py-3\">\n <div className=\"flex flex-col gap-0.5\">\n <SlaBadge dueDate={app.dueDate} status={app.status} />\n {app.dueDate && (\n <span className=\"text-xs text-text-muted\">Due {formatDate(app.dueDate)}</span>\n )}\n </div>\n </td>\n <td className=\"px-4 py-3\">\n <StatusBadge status={app.status} />\n </td>\n <td className=\"px-4 py-3 text-right\">\n <ChevronRight className=\"ml-auto size-4 shrink-0 text-text-muted transition-transform group-hover:translate-x-0.5\" />\n </td>\n </tr>\n );\n}\n\nfunction QueueCard({\n app,\n serviceName,\n currentUser,\n onOpen,\n}: {\n app: GovApplication;\n serviceName?: string;\n currentUser?: CurrentUser | null;\n onOpen: () => void;\n}) {\n return (\n <button\n type=\"button\"\n onClick={onOpen}\n aria-label={`Open application ${app.reference}`}\n className=\"flex w-full flex-col gap-2 px-4 py-4 text-left outline-none transition-colors hover:bg-bg-sunken focus-visible:bg-bg-sunken\"\n >\n <div className=\"flex items-center justify-between gap-2\">\n <span className=\"min-w-0\">\n <span className=\"block truncate font-medium text-action-primary-text\">\n {app.reference}\n </span>\n <span className=\"text-xs text-text-muted\">Filed {formatDate(app.createdAt)}</span>\n </span>\n <StatusBadge status={app.status} />\n </div>\n <div className=\"text-sm text-text-secondary\">{serviceName ?? '—'}</div>\n <div className=\"flex flex-wrap items-center gap-2\">\n <StatusBadge status={app.priority} />\n <SlaBadge dueDate={app.dueDate} status={app.status} />\n <AssignedCell assignedToId={app.assignedToId} currentUser={currentUser} />\n </div>\n </button>\n );\n}\n\nexport function ApplicationsPage() {\n const { navigateTo, currentUser } = useGovCitizenHub();\n const pager = useCursorPager();\n const [status, setStatus] = useState<StatusFilter>('ALL');\n const [search, setSearch] = useState('');\n\n const { data, isLoading, isError, refetch } = useGovApplications({\n status: status === 'ALL' ? undefined : status,\n pagination: { limit: PAGE_SIZE, cursor: pager.cursor },\n });\n const servicesQuery = useGovServices({ pagination: { limit: 100 } });\n const summary = useGovDashboardSummary();\n\n const applications = useMemo(() => data?.items ?? [], [data]);\n\n const serviceName = useMemo(() => {\n const map = new Map<string, string>();\n servicesQuery.data?.items.forEach((svc) => map.set(svc.id, svc.name));\n return map;\n }, [servicesQuery.data]);\n\n // Authoritative per-status tab counts from the backend-computed dashboard.\n const statusCount = useMemo(() => {\n const map = new Map<GovApplicationStatus, number>();\n summary.data?.applicationsByStatus.forEach((entry) => map.set(entry.status, entry.count));\n return map;\n }, [summary.data]);\n\n const tabs: FilterOption<StatusFilter>[] = STATUS_OPTIONS.map((opt) => ({\n ...opt,\n count:\n opt.value === 'ALL'\n ? summary.data?.applicationsTotal\n : statusCount.get(opt.value as GovApplicationStatus),\n }));\n\n // SLA summary over the CURRENT page (honest window — not the whole corpus).\n const sla = useMemo(() => {\n let ontrack = 0;\n let duesoon = 0;\n let overdue = 0;\n for (const app of applications) {\n const bucket = slaBucketOf(app);\n if (bucket === 'ontrack') ontrack += 1;\n else if (bucket === 'duesoon') duesoon += 1;\n else if (bucket === 'overdue') overdue += 1;\n }\n return { ontrack, duesoon, overdue };\n }, [applications]);\n\n const slaStats: SummaryStat[] = [\n { label: 'On track', value: sla.ontrack, icon: <CircleCheck />, tone: 'success' },\n { label: 'Due soon', value: sla.duesoon, icon: <Clock />, tone: 'warning' },\n { label: 'Overdue', value: sla.overdue, icon: <TriangleAlert />, tone: 'error' },\n ];\n\n const visible = useMemo(() => {\n const term = search.trim().toLowerCase();\n if (!term) return applications;\n return applications.filter((app) => {\n const svc = serviceName.get(app.serviceId) ?? '';\n return (\n app.reference.toLowerCase().includes(term) ||\n svc.toLowerCase().includes(term) ||\n app.status.toLowerCase().includes(term)\n );\n });\n }, [applications, search, serviceName]);\n\n const changeStatus = (next: StatusFilter) => {\n setStatus(next);\n setSearch('');\n pager.reset();\n };\n\n return (\n <PageLayout\n title=\"Applications\"\n titleGradient\n description=\"Citizen applications moving through review, decision, and fulfilment.\"\n actions={\n <Button onClick={() => navigateTo('applications/new')}>\n <Plus className=\"mr-1.5 h-4 w-4\" /> New application\n </Button>\n }\n >\n {/* Toolbar: status tabs + search */}\n <div className=\"mb-5 flex flex-col gap-3 lg:flex-row lg:items-center lg:justify-between\">\n <FilterTabs options={tabs} value={status} onChange={changeStatus} />\n <div className=\"relative lg:w-80\">\n <Search\n className=\"pointer-events-none absolute left-3 top-1/2 size-4 -translate-y-1/2 text-text-muted\"\n aria-hidden=\"true\"\n />\n <Input\n value={search}\n onChange={(e) => setSearch(e.target.value)}\n placeholder=\"Search by reference or service…\"\n aria-label=\"Search applications on this page\"\n className=\"pl-9\"\n />\n </div>\n </div>\n\n {isLoading ? (\n <div className=\"space-y-3\">\n {Array.from({ length: 6 }, (_, i) => (\n <Skeleton key={i} className=\"h-16 w-full rounded-card\" />\n ))}\n </div>\n ) : isError ? (\n <ErrorView message=\"We couldn't load applications.\" onRetry={() => refetch()} />\n ) : applications.length === 0 && pager.page === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title=\"No applications found\"\n description={\n status === 'ALL'\n ? 'File the first application from a published service.'\n : 'No applications match this status.'\n }\n action={\n <Button onClick={() => navigateTo('applications/new')}>\n <Plus className=\"mr-1.5 h-4 w-4\" /> New application\n </Button>\n }\n />\n ) : (\n <>\n {/* SLA summary for the current page */}\n <div className=\"mb-4\">\n <div className=\"mb-2 flex items-center gap-2\">\n <h2 className=\"text-sm font-semibold text-text-primary\">SLA on this page</h2>\n <span className=\"text-xs text-text-muted\">\n Based on due date · {applications.length} shown\n </span>\n </div>\n <SummaryStrip stats={slaStats} />\n </div>\n\n {/* Queue list */}\n <GlassCard treatment=\"plain\" className=\"overflow-hidden border-border-seam p-0\">\n {visible.length === 0 ? (\n <p className=\"px-5 py-10 text-center text-sm text-text-secondary\">\n No applications on this page match “{search}”.\n </p>\n ) : (\n <>\n {/* Desktop table */}\n <div className=\"hidden overflow-x-auto md:block\">\n <table className=\"w-full text-left text-sm\">\n <thead>\n <tr className=\"border-b border-border-seam text-xs font-medium uppercase tracking-wide text-text-muted\">\n <th className=\"px-4 py-2.5 font-medium\">Reference</th>\n <th className=\"px-4 py-2.5 font-medium\">Service</th>\n <th className=\"px-4 py-2.5 font-medium\">Priority</th>\n <th className=\"px-4 py-2.5 font-medium\">Assigned officer</th>\n <th className=\"px-4 py-2.5 font-medium\">Due date (SLA)</th>\n <th className=\"px-4 py-2.5 font-medium\">Status</th>\n <th className=\"px-4 py-2.5\" aria-hidden=\"true\" />\n </tr>\n </thead>\n <tbody className=\"divide-y divide-border-subtle\">\n {visible.map((app) => (\n <QueueTableRow\n key={app.id}\n app={app}\n serviceName={serviceName.get(app.serviceId)}\n currentUser={currentUser}\n onOpen={() => navigateTo(`applications/${app.id}`)}\n />\n ))}\n </tbody>\n </table>\n </div>\n\n {/* Mobile stacked cards */}\n <ul className=\"divide-y divide-border-subtle md:hidden\">\n {visible.map((app) => (\n <li key={app.id}>\n <QueueCard\n app={app}\n serviceName={serviceName.get(app.serviceId)}\n currentUser={currentUser}\n onOpen={() => navigateTo(`applications/${app.id}`)}\n />\n </li>\n ))}\n </ul>\n </>\n )}\n </GlassCard>\n\n <Pagination\n page={pager.page}\n pageSize={PAGE_SIZE}\n itemCount={applications.length}\n hasMore={data?.pageInfo.hasMore ?? false}\n onPageChange={(target) => pager.onPageChange(target, data?.pageInfo.cursor)}\n />\n </>\n )}\n </PageLayout>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAqCA,IAAM,IAAY;AAGlB,SAAS,EAAgB,GAA+C;AACtE,KAAI,CAAC,EAAM;CACX,IAAM,IAAO,CAAC,EAAK,WAAW,EAAK,SAAS,CAAC,OAAO,QAAQ,CAAC,KAAK,IAAI,CAAC,MAAM;AAC7E,QAAO,EAAK,MAAM,MAAM,IAAI,KAAQ,EAAK,UAAU,MAAM,IAAI,EAAK;;AAIpE,IAAM,KAAW,MAAuB,EAAG,MAAM,GAAG,EAAE,EAIhD,IAA2D;CAC/D;EAAE,OAAO;EAAO,OAAO;EAAO;CAC9B;EAAE,OAAO;EAAa,OAAO;EAAa;CAC1C;EAAE,OAAO;EAAa,OAAO;EAAa;CAC1C;EAAE,OAAO;EAAkB,OAAO;EAAkB;CACpD;EAAE,OAAO;EAAY,OAAO;EAAY;CACxC;EAAE,OAAO;EAAY,OAAO;EAAY;CACxC;EAAE,OAAO;EAAS,OAAO;EAAS;CACnC,EAGK,IAAW,IAAI,IAA0B;CAAC;CAAY;CAAY;CAAY,CAAC;AAGrF,SAAS,EAAa,GAAmB;CACvC,IAAM,KAAc,MAAY,IAAI,KAAK,EAAE,aAAa,EAAE,EAAE,UAAU,EAAE,EAAE,SAAS,CAAC,CAAC,SAAS;AAC9F,QAAO,KAAK,OAAO,EAAW,EAAI,GAAG,kBAAW,IAAI,MAAM,CAAC,IAAI,MAAW;;AAK5E,SAAS,EAAY,GAAgC;AACnD,KAAI,EAAS,IAAI,EAAI,OAAO,IAAI,CAAC,EAAI,QAAS,QAAO;CACrD,IAAM,IAAM,IAA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