@burdenoff/microfe-govcitizenhub 2026.730.1 → 2026.730.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/govcitizenhub/components/DocumentUploadField.d.ts.map +1 -1
- package/dist/govcitizenhub/components/DocumentUploadField.js.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/AdminLevelsPage.d.ts.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/AdminLevelsPage.js.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/AssetFormDialog.d.ts.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/AssetFormDialog.js.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/AssetMapPanel.d.ts.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/AssetMapPanel.js.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/BenchmarkPage.d.ts.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/BenchmarkPage.js.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/BudgetPage.d.ts.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/BudgetPage.js.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/ConsultationFormDialog.d.ts.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/ConsultationFormDialog.js.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/ConsultationParticipateDialog.d.ts.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/ConsultationParticipateDialog.js.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/ConsultationResultsPanel.d.ts.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/ConsultationResultsPanel.js.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/ConsultationsPage.d.ts.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/ConsultationsPage.js.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/CorrectionsPage.js.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/IndicatorCatalogPage.js.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/JurisdictionDirectoryPage.d.ts.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/JurisdictionDirectoryPage.js.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/JurisdictionLayout.d.ts.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/JurisdictionLayout.js.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/JurisdictionProfilePage.d.ts.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/JurisdictionProfilePage.js.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/OpenDataPage.d.ts.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/OpenDataPage.js +2 -1
- package/dist/govcitizenhub/pages/intelligence/OpenDataPage.js.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/ProjectsPage.js.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/PublicAssetsPage.d.ts.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/PublicAssetsPage.js.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/ServicePerformancePage.js.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/consultationQuestions.d.ts.map +1 -1
- package/dist/govcitizenhub/pages/intelligence/consultationQuestions.js.map +1 -1
- package/dist/govcitizenhub/types/intelligence.d.ts.map +1 -1
- package/dist/govcitizenhub/types/intelligence.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PublicAssetsPage.js","names":[],"sources":["../../../../src/govcitizenhub/pages/intelligence/PublicAssetsPage.tsx"],"sourcesContent":["/**\n * PublicAssetsPage — the mappable public-asset registry for one jurisdiction.\n * @module govcitizenhub/pages/intelligence\n *\n * Route: `/govcitizenhub/intelligence/:jurisdictionId/assets`.\n *\n * Reads `govPublicAssets` (server-side category / operator / status /\n * accessibility / text filters, cursor-paginated) and `govPublicAssetSummary`\n * (a `groupBy` over the WHOLE registry, so the legend counts are authoritative\n * rather than derived from the loaded page — the connection carries no\n * `totalCount` and `items.length` is never presented as one).\n *\n * The map panel is a self-contained inline SVG scatter: no tile service, no map\n * library, no network image, so it renders offline and under a strict CSP. See\n * `AssetMapPanel` for the projection.\n *\n * Cache: the shared create/update/delete hooks already invalidate the asset\n * list, the category summary and the jurisdiction overview (and `govQuery`\n * clears the 15s response cache around every write), so a save is visible on the\n * next read instead of serving a stale pre-write page.\n */\n\nimport { useMemo, useState, type ReactElement } from 'react';\nimport { useParams } from 'react-router-dom';\nimport {\n Accessibility,\n Building2,\n Clock,\n Globe,\n Mail,\n MapPin,\n MoreVertical,\n Pencil,\n Phone,\n Plus,\n Search,\n Trash2,\n X,\n} from 'lucide-react';\nimport {\n Button,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n GlassCard,\n Input,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@burdenoff/fe-libs/ui';\n\nimport { SectionCard } from '../../components/SectionCard';\nimport { EmptyState } from '../../components/EmptyState';\nimport { ErrorView, LoadingView } from '../../components/StateViews';\nimport { Pagination } from '../../components/Pagination';\nimport { ConfirmDialog } from '../../components/ConfirmDialog';\nimport { CHART_SERIES_COLORS } from '../../components/GovCharts';\nimport { JurisdictionLayout, VerificationChip } from './JurisdictionLayout';\nimport { AssetMapPanel } from './AssetMapPanel';\nimport { AssetImage } from './AssetImage';\nimport {\n ASSET_CATEGORIES,\n ASSET_OPERATORS,\n ASSET_STATUSES,\n AssetFormDialog,\n} from './AssetFormDialog';\nimport {\n useCursorPager,\n useGovDeletePublicAsset,\n useGovPublicAssetSummary,\n useGovPublicAssets,\n} from '../../hooks';\nimport { describeError, notify } from '../../lib/toast';\nimport { formatDate, formatEnumLabel, formatNumber } from '../../utils/formatters';\nimport { cn } from '../../utils/cn';\nimport {\n GOV_ASSET_CATEGORY_LABELS,\n type GovAssetCategory,\n type GovAssetOperator,\n type GovAssetStatus,\n type GovPublicAsset,\n type GovPublicAssetFilterInput,\n} from '../../types';\n\nconst PAGE_SIZE = 12;\n\ntype CategoryFilter = 'ALL' | GovAssetCategory;\ntype OperatorFilter = 'ALL' | GovAssetOperator;\ntype StatusFilter = 'ALL' | GovAssetStatus;\ntype AccessibilityFilter = 'ALL' | 'YES' | 'NO';\n\n/** Operational state → the same semantic status tokens the rest of the MFE uses. */\nconst ASSET_STATUS_TONE: Record<GovAssetStatus, string> = {\n OPERATIONAL: 'bg-status-success-bg-subtle text-status-success-text',\n UNDER_CONSTRUCTION: 'bg-status-warning-bg-subtle text-status-warning-text',\n UNDER_MAINTENANCE: 'bg-status-warning-bg-subtle text-status-warning-text',\n CLOSED: 'bg-status-error-bg-subtle text-status-error-text',\n PLANNED: 'bg-bg-sunken text-text-secondary',\n};\n\nexport function PublicAssetsPage(): ReactElement {\n const { jurisdictionId } = useParams<{ jurisdictionId: string }>();\n const pager = useCursorPager();\n\n const [category, setCategory] = useState<CategoryFilter>('ALL');\n const [operator, setOperator] = useState<OperatorFilter>('ALL');\n const [status, setStatus] = useState<StatusFilter>('ALL');\n const [accessibility, setAccessibility] = useState<AccessibilityFilter>('ALL');\n const [searchDraft, setSearchDraft] = useState('');\n const [search, setSearch] = useState('');\n\n const [formOpen, setFormOpen] = useState(false);\n const [editing, setEditing] = useState<GovPublicAsset | null>(null);\n const [pendingDelete, setPendingDelete] = useState<GovPublicAsset | null>(null);\n const [selectedId, setSelectedId] = useState<string | null>(null);\n\n const deleteAsset = useGovDeletePublicAsset();\n\n const filter = useMemo<GovPublicAssetFilterInput>(\n () => ({\n jurisdictionId,\n category: category === 'ALL' ? undefined : category,\n operator: operator === 'ALL' ? undefined : operator,\n status: status === 'ALL' ? undefined : status,\n isAccessible: accessibility === 'ALL' ? undefined : accessibility === 'YES',\n search: search.length > 0 ? search : undefined,\n }),\n [jurisdictionId, category, operator, status, accessibility, search]\n );\n\n const { data, isLoading, isError, refetch } = useGovPublicAssets(filter, {\n limit: PAGE_SIZE,\n cursor: pager.cursor,\n });\n const { data: summary } = useGovPublicAssetSummary(jurisdictionId);\n\n const assets = useMemo(() => data?.items ?? [], [data]);\n const registryTotal = useMemo(\n () => (summary ?? []).reduce((total, row) => total + row.count, 0),\n [summary]\n );\n\n /**\n * Category → chart-token colour. Ordered by the authoritative registry summary\n * first so a category keeps the same swatch as the page filters change, then\n * extended with anything on the current page the summary has not caught up to.\n */\n const categoryColor = useMemo(() => {\n const ordered: GovAssetCategory[] = [];\n for (const row of summary ?? []) {\n if (!ordered.includes(row.category)) ordered.push(row.category);\n }\n for (const asset of assets) {\n if (!ordered.includes(asset.category)) ordered.push(asset.category);\n }\n const palette = new Map<GovAssetCategory, string>();\n ordered.forEach((entry, index) => {\n palette.set(entry, CHART_SERIES_COLORS[index % CHART_SERIES_COLORS.length]);\n });\n return (entry: GovAssetCategory): string => palette.get(entry) ?? CHART_SERIES_COLORS[0];\n }, [summary, assets]);\n\n const resetPaging = (): void => {\n pager.reset();\n setSelectedId(null);\n };\n\n const changeCategory = (next: CategoryFilter): void => {\n setCategory((current) => (current === next ? 'ALL' : next));\n resetPaging();\n };\n\n const filtersApplied =\n category !== 'ALL' ||\n operator !== 'ALL' ||\n status !== 'ALL' ||\n accessibility !== 'ALL' ||\n search.length > 0;\n\n const clearFilters = (): void => {\n setCategory('ALL');\n setOperator('ALL');\n setStatus('ALL');\n setAccessibility('ALL');\n setSearch('');\n setSearchDraft('');\n resetPaging();\n };\n\n const openCreate = (): void => {\n setEditing(null);\n setFormOpen(true);\n };\n\n const openEdit = (asset: GovPublicAsset): void => {\n setEditing(asset);\n setFormOpen(true);\n };\n\n const confirmDelete = async (): Promise<void> => {\n if (!pendingDelete) return;\n try {\n await deleteAsset.mutateAsync(pendingDelete.id);\n notify.success('Asset removed', `${pendingDelete.name} is no longer in the registry.`);\n if (selectedId === pendingDelete.id) setSelectedId(null);\n setPendingDelete(null);\n } catch (err) {\n notify.error('Could not remove the asset', describeError(err));\n }\n };\n\n return (\n <JurisdictionLayout\n actions={\n <Button onClick={openCreate}>\n <Plus className=\"mr-1.5 h-4 w-4\" aria-hidden=\"true\" /> Add asset\n </Button>\n }\n >\n <div className=\"flex flex-col gap-6\">\n {/* Filters */}\n <SectionCard title=\"Filter the registry\" icon={<Search />}>\n <div className=\"flex flex-col gap-4\">\n <form\n className=\"relative\"\n onSubmit={(event) => {\n event.preventDefault();\n setSearch(searchDraft.trim());\n resetPaging();\n }}\n >\n <Search\n className=\"pointer-events-none absolute left-3.5 top-1/2 size-4 -translate-y-1/2 text-text-muted\"\n aria-hidden=\"true\"\n />\n <Input\n value={searchDraft}\n onChange={(event) => setSearchDraft(event.target.value)}\n placeholder=\"Search assets by name or description…\"\n aria-label=\"Search public assets\"\n className=\"h-11 pl-10 pr-24\"\n />\n <div className=\"absolute right-1.5 top-1/2 flex -translate-y-1/2 items-center gap-1\">\n {search.length > 0 && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n aria-label=\"Clear search\"\n onClick={() => {\n setSearch('');\n setSearchDraft('');\n resetPaging();\n }}\n >\n <X className=\"size-4\" aria-hidden=\"true\" />\n </Button>\n )}\n <Button type=\"submit\" size=\"sm\">\n Search\n </Button>\n </div>\n </form>\n\n <div className=\"grid gap-3 sm:grid-cols-2 xl:grid-cols-4\">\n <div className=\"grid gap-1.5\">\n <span className=\"text-xs font-medium text-text-muted\">Category</span>\n <Select\n value={category}\n onValueChange={(value) => {\n setCategory(value as CategoryFilter);\n resetPaging();\n }}\n >\n <SelectTrigger aria-label=\"Filter by category\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"ALL\">All categories</SelectItem>\n {ASSET_CATEGORIES.map((entry) => (\n <SelectItem key={entry} value={entry}>\n {GOV_ASSET_CATEGORY_LABELS[entry]}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n\n <div className=\"grid gap-1.5\">\n <span className=\"text-xs font-medium text-text-muted\">Operator</span>\n <Select\n value={operator}\n onValueChange={(value) => {\n setOperator(value as OperatorFilter);\n resetPaging();\n }}\n >\n <SelectTrigger aria-label=\"Filter by operator\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"ALL\">Any operator</SelectItem>\n {ASSET_OPERATORS.map((entry) => (\n <SelectItem key={entry} value={entry}>\n {formatEnumLabel(entry)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n\n <div className=\"grid gap-1.5\">\n <span className=\"text-xs font-medium text-text-muted\">Status</span>\n <Select\n value={status}\n onValueChange={(value) => {\n setStatus(value as StatusFilter);\n resetPaging();\n }}\n >\n <SelectTrigger aria-label=\"Filter by status\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"ALL\">Any status</SelectItem>\n {ASSET_STATUSES.map((entry) => (\n <SelectItem key={entry} value={entry}>\n {formatEnumLabel(entry)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n\n <div className=\"grid gap-1.5\">\n <span className=\"text-xs font-medium text-text-muted\">Accessibility</span>\n <Select\n value={accessibility}\n onValueChange={(value) => {\n setAccessibility(value as AccessibilityFilter);\n resetPaging();\n }}\n >\n <SelectTrigger aria-label=\"Filter by disability accessibility\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"ALL\">Any accessibility</SelectItem>\n <SelectItem value=\"YES\">Accessible</SelectItem>\n <SelectItem value=\"NO\">Not accessible</SelectItem>\n </SelectContent>\n </Select>\n </div>\n </div>\n\n {filtersApplied && (\n <div>\n <Button variant=\"ghost\" size=\"sm\" onClick={clearFilters}>\n <X className=\"mr-1.5 size-4\" aria-hidden=\"true\" /> Clear filters\n </Button>\n </div>\n )}\n </div>\n </SectionCard>\n\n {/* Category legend — authoritative counts across the whole registry */}\n <SectionCard\n title=\"Registry by category\"\n icon={<Building2 />}\n actions={\n summary && summary.length > 0 ? (\n <span className=\"text-sm text-text-secondary tabular-nums\">\n {formatNumber(registryTotal)} recorded\n </span>\n ) : undefined\n }\n >\n {summary === undefined ? (\n <p className=\"text-sm text-text-muted\">Loading the category breakdown…</p>\n ) : summary.length === 0 ? (\n <p className=\"text-sm text-text-muted\">\n No assets have been recorded for this jurisdiction yet.\n </p>\n ) : (\n <ul className=\"flex flex-wrap gap-2\">\n {summary.map((row) => {\n const active = category === row.category;\n return (\n <li key={row.category}>\n <button\n type=\"button\"\n aria-pressed={active}\n onClick={() => changeCategory(row.category)}\n className={cn(\n 'inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-sm font-medium transition-colors',\n active\n ? 'border-transparent bg-action-primary-bg text-action-primary-text'\n : 'border-border-seam bg-bg-surface text-text-secondary hover:bg-bg-sunken hover:text-text-primary'\n )}\n >\n <span\n aria-hidden=\"true\"\n className=\"size-2.5 shrink-0 rounded-full\"\n style={{ backgroundColor: categoryColor(row.category) }}\n />\n {GOV_ASSET_CATEGORY_LABELS[row.category]}\n <span className=\"tabular-nums opacity-80\">{formatNumber(row.count)}</span>\n </button>\n </li>\n );\n })}\n </ul>\n )}\n </SectionCard>\n\n {/* Map */}\n <SectionCard title=\"Map\" icon={<MapPin />}>\n {isLoading ? (\n <LoadingView label=\"Loading the registry map…\" className=\"min-h-[16rem]\" />\n ) : isError ? (\n <ErrorView\n className=\"min-h-[16rem]\"\n message=\"We couldn't load the assets to map.\"\n onRetry={() => {\n void refetch();\n }}\n />\n ) : (\n <AssetMapPanel\n assets={assets}\n categoryColor={categoryColor}\n selectedId={selectedId}\n onSelect={setSelectedId}\n />\n )}\n </SectionCard>\n\n {/* Registry list */}\n {isLoading ? (\n <LoadingView label=\"Loading public assets…\" />\n ) : isError ? (\n <ErrorView\n message=\"We couldn't load the public-asset registry.\"\n onRetry={() => {\n void refetch();\n }}\n />\n ) : assets.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={filtersApplied ? 'No assets match these filters' : 'No public assets recorded yet'}\n description={\n filtersApplied\n ? 'Nothing in the registry matches the current filters. Try widening them.'\n : 'Add the schools, clinics, stations, parks and offices that serve this jurisdiction so citizens can find them.'\n }\n action={\n filtersApplied ? (\n <Button variant=\"outline\" onClick={clearFilters}>\n Clear filters\n </Button>\n ) : (\n <Button onClick={openCreate}>\n <Plus className=\"mr-1.5 h-4 w-4\" aria-hidden=\"true\" /> Add asset\n </Button>\n )\n }\n />\n ) : (\n <>\n <div className=\"grid gap-4 md:grid-cols-2 xl:grid-cols-3\">\n {assets.map((asset) => (\n <AssetCard\n key={asset.id}\n asset={asset}\n color={categoryColor(asset.category)}\n selected={asset.id === selectedId}\n onSelect={() => setSelectedId(asset.id === selectedId ? null : asset.id)}\n onEdit={() => openEdit(asset)}\n onDelete={() => setPendingDelete(asset)}\n />\n ))}\n </div>\n <Pagination\n page={pager.page}\n pageSize={PAGE_SIZE}\n itemCount={assets.length}\n hasMore={data?.pageInfo.hasMore ?? false}\n onPageChange={(target) => {\n pager.onPageChange(target, data?.pageInfo.cursor);\n setSelectedId(null);\n }}\n />\n </>\n )}\n </div>\n\n {formOpen && jurisdictionId && (\n <AssetFormDialog\n jurisdictionId={jurisdictionId}\n asset={editing}\n onClose={() => {\n setFormOpen(false);\n setEditing(null);\n }}\n />\n )}\n\n <ConfirmDialog\n open={pendingDelete !== null}\n onOpenChange={(next) => {\n if (!next) setPendingDelete(null);\n }}\n title=\"Remove this asset?\"\n description={\n pendingDelete\n ? `${pendingDelete.name} will be removed from the public registry and will no longer appear on the map.`\n : undefined\n }\n confirmLabel=\"Remove asset\"\n destructive\n onConfirm={confirmDelete}\n />\n </JurisdictionLayout>\n );\n}\n\ninterface AssetCardProps {\n asset: GovPublicAsset;\n /** Chart-token colour for the asset's category, shared with the map marker. */\n color: string;\n selected: boolean;\n onSelect: () => void;\n onEdit: () => void;\n onDelete: () => void;\n}\n\nfunction AssetCard({\n asset,\n color,\n selected,\n onSelect,\n onEdit,\n onDelete,\n}: AssetCardProps): ReactElement {\n const hasContact = Boolean(asset.contactPhone || asset.contactEmail || asset.website);\n\n return (\n <GlassCard\n treatment=\"plain\"\n className={cn(\n 'flex flex-col overflow-hidden border-border-seam transition-shadow duration-200 hover:shadow-elevation-1',\n selected && 'ring-1 ring-border-focus'\n )}\n >\n <button\n type=\"button\"\n onClick={onSelect}\n aria-pressed={selected}\n aria-label={`Highlight ${asset.name} on the map`}\n className=\"h-32 w-full overflow-hidden outline-none focus-visible:ring-1 focus-visible:ring-border-focus\"\n >\n <AssetImage fileId={asset.imageFileId} alt={asset.name} />\n </button>\n\n <div className=\"flex flex-1 flex-col gap-3 p-5\">\n <div className=\"flex items-start gap-3\">\n <div className=\"min-w-0 flex-1\">\n <h3 className=\"truncate text-base font-semibold text-text-primary\">{asset.name}</h3>\n {asset.subCategory && (\n <p className=\"truncate text-sm text-text-muted\">{asset.subCategory}</p>\n )}\n </div>\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button variant=\"ghost\" size=\"sm\" aria-label={`Actions for ${asset.name}`}>\n <MoreVertical className=\"size-4\" aria-hidden=\"true\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n <DropdownMenuItem onSelect={onEdit}>\n <Pencil className=\"mr-2 size-4\" aria-hidden=\"true\" /> Edit asset\n </DropdownMenuItem>\n <DropdownMenuItem onSelect={onDelete}>\n <Trash2 className=\"mr-2 size-4\" aria-hidden=\"true\" /> Remove asset\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n\n <div className=\"flex flex-wrap items-center gap-2\">\n <span className=\"inline-flex items-center gap-1.5 rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs font-medium text-text-secondary\">\n <span\n aria-hidden=\"true\"\n className=\"size-2 shrink-0 rounded-full\"\n style={{ backgroundColor: color }}\n />\n {GOV_ASSET_CATEGORY_LABELS[asset.category]}\n </span>\n <span className=\"rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs font-medium text-text-secondary\">\n {formatEnumLabel(asset.operator)}\n </span>\n <span\n className={cn(\n 'rounded-full px-2.5 py-0.5 text-xs font-medium',\n ASSET_STATUS_TONE[asset.status]\n )}\n >\n {formatEnumLabel(asset.status)}\n </span>\n <VerificationChip status={asset.verification} />\n </div>\n\n {asset.description && (\n <p className=\"line-clamp-2 text-sm text-text-secondary\">{asset.description}</p>\n )}\n\n <dl className=\"flex flex-col gap-1.5 text-sm text-text-secondary\">\n {asset.capacity != null && (\n <div className=\"flex items-center gap-2\">\n <dt className=\"sr-only\">Capacity</dt>\n <Building2 className=\"size-4 shrink-0 text-text-muted\" aria-hidden=\"true\" />\n <dd className=\"tabular-nums\">\n {formatNumber(asset.capacity)}\n {asset.capacityUnit ? ` ${asset.capacityUnit}` : ''}\n </dd>\n </div>\n )}\n {asset.isAccessible != null && (\n <div className=\"flex items-center gap-2\">\n <dt className=\"sr-only\">Disability accessibility</dt>\n <Accessibility\n className={cn(\n 'size-4 shrink-0',\n asset.isAccessible ? 'text-status-success-text' : 'text-text-muted'\n )}\n aria-hidden=\"true\"\n />\n <dd>{asset.isAccessible ? 'Accessible' : 'Not accessible'}</dd>\n </div>\n )}\n {asset.openingHours && (\n <div className=\"flex items-center gap-2\">\n <dt className=\"sr-only\">Opening hours</dt>\n <Clock className=\"size-4 shrink-0 text-text-muted\" aria-hidden=\"true\" />\n <dd className=\"truncate\">{asset.openingHours}</dd>\n </div>\n )}\n {asset.address && (\n <div className=\"flex items-start gap-2\">\n <dt className=\"sr-only\">Address</dt>\n <MapPin className=\"mt-0.5 size-4 shrink-0 text-text-muted\" aria-hidden=\"true\" />\n <dd className=\"line-clamp-2\">{asset.address}</dd>\n </div>\n )}\n {asset.establishedOn && (\n <div className=\"flex items-center gap-2\">\n <dt className=\"sr-only\">Established</dt>\n <span className=\"text-xs text-text-muted\">\n Established {formatDate(asset.establishedOn)}\n </span>\n </div>\n )}\n </dl>\n\n {asset.tags.length > 0 && (\n <ul className=\"flex flex-wrap gap-1.5\">\n {asset.tags.map((tag) => (\n <li\n key={tag}\n className=\"rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-text-secondary\"\n >\n {tag}\n </li>\n ))}\n </ul>\n )}\n\n {hasContact && (\n <div className=\"mt-auto flex flex-wrap items-center gap-3 border-t border-border-seam pt-3 text-sm\">\n {asset.contactPhone && (\n <a\n href={`tel:${asset.contactPhone}`}\n className=\"inline-flex items-center gap-1.5 text-text-secondary transition-colors hover:text-text-primary\"\n >\n <Phone className=\"size-4\" aria-hidden=\"true\" /> {asset.contactPhone}\n </a>\n )}\n {asset.contactEmail && (\n <a\n href={`mailto:${asset.contactEmail}`}\n className=\"inline-flex items-center gap-1.5 truncate text-text-secondary transition-colors hover:text-text-primary\"\n >\n <Mail className=\"size-4 shrink-0\" aria-hidden=\"true\" />\n <span className=\"truncate\">{asset.contactEmail}</span>\n </a>\n )}\n {asset.website && (\n <a\n href={asset.website}\n target=\"_blank\"\n rel=\"noreferrer noopener\"\n className=\"inline-flex items-center gap-1.5 text-text-secondary transition-colors hover:text-text-primary\"\n >\n <Globe className=\"size-4\" aria-hidden=\"true\" /> Website\n </a>\n )}\n </div>\n )}\n </div>\n </GlassCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuFA,IAAM,IAAY,IAQZ,IAAoD;CACxD,aAAa;CACb,oBAAoB;CACpB,mBAAmB;CACnB,QAAQ;CACR,SAAS;AACX;AAEA,SAAgB,IAAiC;CAC/C,IAAM,EAAE,sBAAmB,GAAsC,GAC3D,IAAQ,EAAe,GAEvB,CAAC,GAAU,KAAe,EAAyB,KAAK,GACxD,CAAC,GAAU,KAAe,EAAyB,KAAK,GACxD,CAAC,GAAQ,KAAa,EAAuB,KAAK,GAClD,CAAC,GAAe,KAAoB,EAA8B,KAAK,GACvE,CAAC,GAAa,KAAkB,EAAS,EAAE,GAC3C,CAAC,GAAQ,KAAa,EAAS,EAAE,GAEjC,CAAC,GAAU,KAAe,EAAS,EAAK,GACxC,CAAC,GAAS,KAAc,EAAgC,IAAI,GAC5D,CAAC,GAAe,KAAoB,EAAgC,IAAI,GACxE,CAAC,GAAY,KAAiB,EAAwB,IAAI,GAE1D,KAAc,EAA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;iBAAf,CACE,kBAAC,MAAD;QAAI,WAAU;kBAAU;OAAe,CAAA,GACvC,kBAAC,QAAD;QAAM,WAAU;kBAAhB,CAA0C,gBAC3B,EAAW,EAAM,aAAa,CACvC;SACH;;KAEL;;IAEH,EAAM,KAAK,SAAS,KACnB,kBAAC,MAAD;KAAI,WAAU;eACX,EAAM,KAAK,KAAK,MACf,kBAAC,MAAD;MAEE,WAAU;gBAET;KACC,GAJG,CAIH,CACL;IACC,CAAA;IAGL,KACC,kBAAC,OAAD;KAAK,WAAU;eAAf;MACG,EAAM,gBACL,kBAAC,KAAD;OACE,MAAM,OAAO,EAAM;OACnB,WAAU;iBAFZ;QAIE,kBAAC,GAAD;SAAO,WAAU;SAAS,eAAY;QAAQ,CAAA;QAAC;QAAE,EAAM;OACtD;;MAEJ,EAAM,gBACL,kBAAC,KAAD;OACE,MAAM,UAAU,EAAM;OACtB,WAAU;iBAFZ,CAIE,kBAAC,GAAD;QAAM,WAAU;QAAkB,eAAY;OAAQ,CAAA,GACtD,kBAAC,QAAD;QAAM,WAAU;kBAAY,EAAM;OAAmB,CAAA,CACpD;;MAEJ,EAAM,WACL,kBAAC,KAAD;OACE,MAAM,EAAM;OACZ,QAAO;OACP,KAAI;OACJ,WAAU;iBAJZ,CAME,kBAAC,GAAD;QAAO,WAAU;QAAS,eAAY;OAAQ,CAAA,GAAC,UAC9C;;KAEF;;GAEJ;IACI;;AAEf"}
|
|
1
|
+
{"version":3,"file":"PublicAssetsPage.js","names":[],"sources":["../../../../src/govcitizenhub/pages/intelligence/PublicAssetsPage.tsx"],"sourcesContent":["/**\n * PublicAssetsPage — the mappable public-asset registry for one jurisdiction.\n * @module govcitizenhub/pages/intelligence\n *\n * Route: `/govcitizenhub/intelligence/:jurisdictionId/assets`.\n *\n * Reads `govPublicAssets` (server-side category / operator / status /\n * accessibility / text filters, cursor-paginated) and `govPublicAssetSummary`\n * (a `groupBy` over the WHOLE registry, so the legend counts are authoritative\n * rather than derived from the loaded page — the connection carries no\n * `totalCount` and `items.length` is never presented as one).\n *\n * The map panel is a self-contained inline SVG scatter: no tile service, no map\n * library, no network image, so it renders offline and under a strict CSP. See\n * `AssetMapPanel` for the projection.\n *\n * Cache: the shared create/update/delete hooks already invalidate the asset\n * list, the category summary and the jurisdiction overview (and `govQuery`\n * clears the 15s response cache around every write), so a save is visible on the\n * next read instead of serving a stale pre-write page.\n */\n\nimport { useMemo, useState, type ReactElement } from 'react';\nimport { useParams } from 'react-router-dom';\nimport {\n Accessibility,\n Building2,\n Clock,\n Globe,\n Mail,\n MapPin,\n MoreVertical,\n Pencil,\n Phone,\n Plus,\n Search,\n Trash2,\n X,\n} from 'lucide-react';\nimport {\n Button,\n DropdownMenu,\n DropdownMenuContent,\n DropdownMenuItem,\n DropdownMenuTrigger,\n GlassCard,\n Input,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n} from '@burdenoff/fe-libs/ui';\n\nimport { SectionCard } from '../../components/SectionCard';\nimport { EmptyState } from '../../components/EmptyState';\nimport { ErrorView, LoadingView } from '../../components/StateViews';\nimport { Pagination } from '../../components/Pagination';\nimport { ConfirmDialog } from '../../components/ConfirmDialog';\nimport { CHART_SERIES_COLORS } from '../../components/GovCharts';\nimport { JurisdictionLayout, VerificationChip } from './JurisdictionLayout';\nimport { AssetMapPanel } from './AssetMapPanel';\nimport { AssetImage } from './AssetImage';\nimport {\n ASSET_CATEGORIES,\n ASSET_OPERATORS,\n ASSET_STATUSES,\n AssetFormDialog,\n} from './AssetFormDialog';\nimport {\n useCursorPager,\n useGovDeletePublicAsset,\n useGovPublicAssetSummary,\n useGovPublicAssets,\n} from '../../hooks';\nimport { describeError, notify } from '../../lib/toast';\nimport { formatDate, formatEnumLabel, formatNumber } from '../../utils/formatters';\nimport { cn } from '../../utils/cn';\nimport {\n GOV_ASSET_CATEGORY_LABELS,\n type GovAssetCategory,\n type GovAssetOperator,\n type GovAssetStatus,\n type GovPublicAsset,\n type GovPublicAssetFilterInput,\n} from '../../types';\n\nconst PAGE_SIZE = 12;\n\ntype CategoryFilter = 'ALL' | GovAssetCategory;\ntype OperatorFilter = 'ALL' | GovAssetOperator;\ntype StatusFilter = 'ALL' | GovAssetStatus;\ntype AccessibilityFilter = 'ALL' | 'YES' | 'NO';\n\n/** Operational state → the same semantic status tokens the rest of the MFE uses. */\nconst ASSET_STATUS_TONE: Record<GovAssetStatus, string> = {\n OPERATIONAL: 'bg-status-success-bg-subtle text-status-success-text',\n UNDER_CONSTRUCTION: 'bg-status-warning-bg-subtle text-status-warning-text',\n UNDER_MAINTENANCE: 'bg-status-warning-bg-subtle text-status-warning-text',\n CLOSED: 'bg-status-error-bg-subtle text-status-error-text',\n PLANNED: 'bg-bg-sunken text-text-secondary',\n};\n\nexport function PublicAssetsPage(): ReactElement {\n const { jurisdictionId } = useParams<{ jurisdictionId: string }>();\n const pager = useCursorPager();\n\n const [category, setCategory] = useState<CategoryFilter>('ALL');\n const [operator, setOperator] = useState<OperatorFilter>('ALL');\n const [status, setStatus] = useState<StatusFilter>('ALL');\n const [accessibility, setAccessibility] = useState<AccessibilityFilter>('ALL');\n const [searchDraft, setSearchDraft] = useState('');\n const [search, setSearch] = useState('');\n\n const [formOpen, setFormOpen] = useState(false);\n const [editing, setEditing] = useState<GovPublicAsset | null>(null);\n const [pendingDelete, setPendingDelete] = useState<GovPublicAsset | null>(null);\n const [selectedId, setSelectedId] = useState<string | null>(null);\n\n const deleteAsset = useGovDeletePublicAsset();\n\n const filter = useMemo<GovPublicAssetFilterInput>(\n () => ({\n jurisdictionId,\n category: category === 'ALL' ? undefined : category,\n operator: operator === 'ALL' ? undefined : operator,\n status: status === 'ALL' ? undefined : status,\n isAccessible: accessibility === 'ALL' ? undefined : accessibility === 'YES',\n search: search.length > 0 ? search : undefined,\n }),\n [jurisdictionId, category, operator, status, accessibility, search]\n );\n\n const { data, isLoading, isError, refetch } = useGovPublicAssets(filter, {\n limit: PAGE_SIZE,\n cursor: pager.cursor,\n });\n const { data: summary } = useGovPublicAssetSummary(jurisdictionId);\n\n const assets = useMemo(() => data?.items ?? [], [data]);\n const registryTotal = useMemo(\n () => (summary ?? []).reduce((total, row) => total + row.count, 0),\n [summary]\n );\n\n /**\n * Category → chart-token colour. Ordered by the authoritative registry summary\n * first so a category keeps the same swatch as the page filters change, then\n * extended with anything on the current page the summary has not caught up to.\n */\n const categoryColor = useMemo(() => {\n const ordered: GovAssetCategory[] = [];\n for (const row of summary ?? []) {\n if (!ordered.includes(row.category)) ordered.push(row.category);\n }\n for (const asset of assets) {\n if (!ordered.includes(asset.category)) ordered.push(asset.category);\n }\n const palette = new Map<GovAssetCategory, string>();\n ordered.forEach((entry, index) => {\n palette.set(entry, CHART_SERIES_COLORS[index % CHART_SERIES_COLORS.length]);\n });\n return (entry: GovAssetCategory): string => palette.get(entry) ?? CHART_SERIES_COLORS[0];\n }, [summary, assets]);\n\n const resetPaging = (): void => {\n pager.reset();\n setSelectedId(null);\n };\n\n const changeCategory = (next: CategoryFilter): void => {\n setCategory((current) => (current === next ? 'ALL' : next));\n resetPaging();\n };\n\n const filtersApplied =\n category !== 'ALL' ||\n operator !== 'ALL' ||\n status !== 'ALL' ||\n accessibility !== 'ALL' ||\n search.length > 0;\n\n const clearFilters = (): void => {\n setCategory('ALL');\n setOperator('ALL');\n setStatus('ALL');\n setAccessibility('ALL');\n setSearch('');\n setSearchDraft('');\n resetPaging();\n };\n\n const openCreate = (): void => {\n setEditing(null);\n setFormOpen(true);\n };\n\n const openEdit = (asset: GovPublicAsset): void => {\n setEditing(asset);\n setFormOpen(true);\n };\n\n const confirmDelete = async (): Promise<void> => {\n if (!pendingDelete) return;\n try {\n await deleteAsset.mutateAsync(pendingDelete.id);\n notify.success('Asset removed', `${pendingDelete.name} is no longer in the registry.`);\n if (selectedId === pendingDelete.id) setSelectedId(null);\n setPendingDelete(null);\n } catch (err) {\n notify.error('Could not remove the asset', describeError(err));\n }\n };\n\n return (\n <JurisdictionLayout\n actions={\n <Button onClick={openCreate}>\n <Plus className=\"mr-1.5 h-4 w-4\" aria-hidden=\"true\" /> Add asset\n </Button>\n }\n >\n <div className=\"flex flex-col gap-6\">\n {/* Filters */}\n <SectionCard title=\"Filter the registry\" icon={<Search />}>\n <div className=\"flex flex-col gap-4\">\n <form\n className=\"relative\"\n onSubmit={(event) => {\n event.preventDefault();\n setSearch(searchDraft.trim());\n resetPaging();\n }}\n >\n <Search\n className=\"pointer-events-none absolute left-3.5 top-1/2 size-4 -translate-y-1/2 text-text-muted\"\n aria-hidden=\"true\"\n />\n <Input\n value={searchDraft}\n onChange={(event) => setSearchDraft(event.target.value)}\n placeholder=\"Search assets by name or description…\"\n aria-label=\"Search public assets\"\n className=\"h-11 pl-10 pr-24\"\n />\n <div className=\"absolute right-1.5 top-1/2 flex -translate-y-1/2 items-center gap-1\">\n {search.length > 0 && (\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n aria-label=\"Clear search\"\n onClick={() => {\n setSearch('');\n setSearchDraft('');\n resetPaging();\n }}\n >\n <X className=\"size-4\" aria-hidden=\"true\" />\n </Button>\n )}\n <Button type=\"submit\" size=\"sm\">\n Search\n </Button>\n </div>\n </form>\n\n <div className=\"grid gap-3 sm:grid-cols-2 xl:grid-cols-4\">\n <div className=\"grid gap-1.5\">\n <span className=\"text-xs font-medium text-text-muted\">Category</span>\n <Select\n value={category}\n onValueChange={(value) => {\n setCategory(value as CategoryFilter);\n resetPaging();\n }}\n >\n <SelectTrigger aria-label=\"Filter by category\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"ALL\">All categories</SelectItem>\n {ASSET_CATEGORIES.map((entry) => (\n <SelectItem key={entry} value={entry}>\n {GOV_ASSET_CATEGORY_LABELS[entry]}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n\n <div className=\"grid gap-1.5\">\n <span className=\"text-xs font-medium text-text-muted\">Operator</span>\n <Select\n value={operator}\n onValueChange={(value) => {\n setOperator(value as OperatorFilter);\n resetPaging();\n }}\n >\n <SelectTrigger aria-label=\"Filter by operator\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"ALL\">Any operator</SelectItem>\n {ASSET_OPERATORS.map((entry) => (\n <SelectItem key={entry} value={entry}>\n {formatEnumLabel(entry)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n\n <div className=\"grid gap-1.5\">\n <span className=\"text-xs font-medium text-text-muted\">Status</span>\n <Select\n value={status}\n onValueChange={(value) => {\n setStatus(value as StatusFilter);\n resetPaging();\n }}\n >\n <SelectTrigger aria-label=\"Filter by status\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"ALL\">Any status</SelectItem>\n {ASSET_STATUSES.map((entry) => (\n <SelectItem key={entry} value={entry}>\n {formatEnumLabel(entry)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n\n <div className=\"grid gap-1.5\">\n <span className=\"text-xs font-medium text-text-muted\">Accessibility</span>\n <Select\n value={accessibility}\n onValueChange={(value) => {\n setAccessibility(value as AccessibilityFilter);\n resetPaging();\n }}\n >\n <SelectTrigger aria-label=\"Filter by disability accessibility\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n <SelectItem value=\"ALL\">Any accessibility</SelectItem>\n <SelectItem value=\"YES\">Accessible</SelectItem>\n <SelectItem value=\"NO\">Not accessible</SelectItem>\n </SelectContent>\n </Select>\n </div>\n </div>\n\n {filtersApplied && (\n <div>\n <Button variant=\"ghost\" size=\"sm\" onClick={clearFilters}>\n <X className=\"mr-1.5 size-4\" aria-hidden=\"true\" /> Clear filters\n </Button>\n </div>\n )}\n </div>\n </SectionCard>\n\n {/* Category legend — authoritative counts across the whole registry */}\n <SectionCard\n title=\"Registry by category\"\n icon={<Building2 />}\n actions={\n summary && summary.length > 0 ? (\n <span className=\"text-sm text-text-secondary tabular-nums\">\n {formatNumber(registryTotal)} recorded\n </span>\n ) : undefined\n }\n >\n {summary === undefined ? (\n <p className=\"text-sm text-text-muted\">Loading the category breakdown…</p>\n ) : summary.length === 0 ? (\n <p className=\"text-sm text-text-muted\">\n No assets have been recorded for this jurisdiction yet.\n </p>\n ) : (\n <ul className=\"flex flex-wrap gap-2\">\n {summary.map((row) => {\n const active = category === row.category;\n return (\n <li key={row.category}>\n <button\n type=\"button\"\n aria-pressed={active}\n onClick={() => changeCategory(row.category)}\n className={cn(\n 'inline-flex items-center gap-2 rounded-full border px-3 py-1.5 text-sm font-medium transition-colors',\n active\n ? 'border-transparent bg-action-primary-bg text-action-primary-text'\n : 'border-border-seam bg-bg-surface text-text-secondary hover:bg-bg-sunken hover:text-text-primary'\n )}\n >\n <span\n aria-hidden=\"true\"\n className=\"size-2.5 shrink-0 rounded-full\"\n style={{ backgroundColor: categoryColor(row.category) }}\n />\n {GOV_ASSET_CATEGORY_LABELS[row.category]}\n <span className=\"tabular-nums opacity-80\">{formatNumber(row.count)}</span>\n </button>\n </li>\n );\n })}\n </ul>\n )}\n </SectionCard>\n\n {/* Map */}\n <SectionCard title=\"Map\" icon={<MapPin />}>\n {isLoading ? (\n <LoadingView label=\"Loading the registry map…\" className=\"min-h-[16rem]\" />\n ) : isError ? (\n <ErrorView\n className=\"min-h-[16rem]\"\n message=\"We couldn't load the assets to map.\"\n onRetry={() => {\n void refetch();\n }}\n />\n ) : (\n <AssetMapPanel\n assets={assets}\n categoryColor={categoryColor}\n selectedId={selectedId}\n onSelect={setSelectedId}\n />\n )}\n </SectionCard>\n\n {/* Registry list */}\n {isLoading ? (\n <LoadingView label=\"Loading public assets…\" />\n ) : isError ? (\n <ErrorView\n message=\"We couldn't load the public-asset registry.\"\n onRetry={() => {\n void refetch();\n }}\n />\n ) : assets.length === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title={\n filtersApplied ? 'No assets match these filters' : 'No public assets recorded yet'\n }\n description={\n filtersApplied\n ? 'Nothing in the registry matches the current filters. Try widening them.'\n : 'Add the schools, clinics, stations, parks and offices that serve this jurisdiction so citizens can find them.'\n }\n action={\n filtersApplied ? (\n <Button variant=\"outline\" onClick={clearFilters}>\n Clear filters\n </Button>\n ) : (\n <Button onClick={openCreate}>\n <Plus className=\"mr-1.5 h-4 w-4\" aria-hidden=\"true\" /> Add asset\n </Button>\n )\n }\n />\n ) : (\n <>\n <div className=\"grid gap-4 md:grid-cols-2 xl:grid-cols-3\">\n {assets.map((asset) => (\n <AssetCard\n key={asset.id}\n asset={asset}\n color={categoryColor(asset.category)}\n selected={asset.id === selectedId}\n onSelect={() => setSelectedId(asset.id === selectedId ? null : asset.id)}\n onEdit={() => openEdit(asset)}\n onDelete={() => setPendingDelete(asset)}\n />\n ))}\n </div>\n <Pagination\n page={pager.page}\n pageSize={PAGE_SIZE}\n itemCount={assets.length}\n hasMore={data?.pageInfo.hasMore ?? false}\n onPageChange={(target) => {\n pager.onPageChange(target, data?.pageInfo.cursor);\n setSelectedId(null);\n }}\n />\n </>\n )}\n </div>\n\n {formOpen && jurisdictionId && (\n <AssetFormDialog\n jurisdictionId={jurisdictionId}\n asset={editing}\n onClose={() => {\n setFormOpen(false);\n setEditing(null);\n }}\n />\n )}\n\n <ConfirmDialog\n open={pendingDelete !== null}\n onOpenChange={(next) => {\n if (!next) setPendingDelete(null);\n }}\n title=\"Remove this asset?\"\n description={\n pendingDelete\n ? `${pendingDelete.name} will be removed from the public registry and will no longer appear on the map.`\n : undefined\n }\n confirmLabel=\"Remove asset\"\n destructive\n onConfirm={confirmDelete}\n />\n </JurisdictionLayout>\n );\n}\n\ninterface AssetCardProps {\n asset: GovPublicAsset;\n /** Chart-token colour for the asset's category, shared with the map marker. */\n color: string;\n selected: boolean;\n onSelect: () => void;\n onEdit: () => void;\n onDelete: () => void;\n}\n\nfunction AssetCard({\n asset,\n color,\n selected,\n onSelect,\n onEdit,\n onDelete,\n}: AssetCardProps): ReactElement {\n const hasContact = Boolean(asset.contactPhone || asset.contactEmail || asset.website);\n\n return (\n <GlassCard\n treatment=\"plain\"\n className={cn(\n 'flex flex-col overflow-hidden border-border-seam transition-shadow duration-200 hover:shadow-elevation-1',\n selected && 'ring-1 ring-border-focus'\n )}\n >\n <button\n type=\"button\"\n onClick={onSelect}\n aria-pressed={selected}\n aria-label={`Highlight ${asset.name} on the map`}\n className=\"h-32 w-full overflow-hidden outline-none focus-visible:ring-1 focus-visible:ring-border-focus\"\n >\n <AssetImage fileId={asset.imageFileId} alt={asset.name} />\n </button>\n\n <div className=\"flex flex-1 flex-col gap-3 p-5\">\n <div className=\"flex items-start gap-3\">\n <div className=\"min-w-0 flex-1\">\n <h3 className=\"truncate text-base font-semibold text-text-primary\">{asset.name}</h3>\n {asset.subCategory && (\n <p className=\"truncate text-sm text-text-muted\">{asset.subCategory}</p>\n )}\n </div>\n <DropdownMenu>\n <DropdownMenuTrigger asChild>\n <Button variant=\"ghost\" size=\"sm\" aria-label={`Actions for ${asset.name}`}>\n <MoreVertical className=\"size-4\" aria-hidden=\"true\" />\n </Button>\n </DropdownMenuTrigger>\n <DropdownMenuContent align=\"end\">\n <DropdownMenuItem onSelect={onEdit}>\n <Pencil className=\"mr-2 size-4\" aria-hidden=\"true\" /> Edit asset\n </DropdownMenuItem>\n <DropdownMenuItem onSelect={onDelete}>\n <Trash2 className=\"mr-2 size-4\" aria-hidden=\"true\" /> Remove asset\n </DropdownMenuItem>\n </DropdownMenuContent>\n </DropdownMenu>\n </div>\n\n <div className=\"flex flex-wrap items-center gap-2\">\n <span className=\"inline-flex items-center gap-1.5 rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs font-medium text-text-secondary\">\n <span\n aria-hidden=\"true\"\n className=\"size-2 shrink-0 rounded-full\"\n style={{ backgroundColor: color }}\n />\n {GOV_ASSET_CATEGORY_LABELS[asset.category]}\n </span>\n <span className=\"rounded-full bg-bg-sunken px-2.5 py-0.5 text-xs font-medium text-text-secondary\">\n {formatEnumLabel(asset.operator)}\n </span>\n <span\n className={cn(\n 'rounded-full px-2.5 py-0.5 text-xs font-medium',\n ASSET_STATUS_TONE[asset.status]\n )}\n >\n {formatEnumLabel(asset.status)}\n </span>\n <VerificationChip status={asset.verification} />\n </div>\n\n {asset.description && (\n <p className=\"line-clamp-2 text-sm text-text-secondary\">{asset.description}</p>\n )}\n\n <dl className=\"flex flex-col gap-1.5 text-sm text-text-secondary\">\n {asset.capacity != null && (\n <div className=\"flex items-center gap-2\">\n <dt className=\"sr-only\">Capacity</dt>\n <Building2 className=\"size-4 shrink-0 text-text-muted\" aria-hidden=\"true\" />\n <dd className=\"tabular-nums\">\n {formatNumber(asset.capacity)}\n {asset.capacityUnit ? ` ${asset.capacityUnit}` : ''}\n </dd>\n </div>\n )}\n {asset.isAccessible != null && (\n <div className=\"flex items-center gap-2\">\n <dt className=\"sr-only\">Disability accessibility</dt>\n <Accessibility\n className={cn(\n 'size-4 shrink-0',\n asset.isAccessible ? 'text-status-success-text' : 'text-text-muted'\n )}\n aria-hidden=\"true\"\n />\n <dd>{asset.isAccessible ? 'Accessible' : 'Not accessible'}</dd>\n </div>\n )}\n {asset.openingHours && (\n <div className=\"flex items-center gap-2\">\n <dt className=\"sr-only\">Opening hours</dt>\n <Clock className=\"size-4 shrink-0 text-text-muted\" aria-hidden=\"true\" />\n <dd className=\"truncate\">{asset.openingHours}</dd>\n </div>\n )}\n {asset.address && (\n <div className=\"flex items-start gap-2\">\n <dt className=\"sr-only\">Address</dt>\n <MapPin className=\"mt-0.5 size-4 shrink-0 text-text-muted\" aria-hidden=\"true\" />\n <dd className=\"line-clamp-2\">{asset.address}</dd>\n </div>\n )}\n {asset.establishedOn && (\n <div className=\"flex items-center gap-2\">\n <dt className=\"sr-only\">Established</dt>\n <span className=\"text-xs text-text-muted\">\n Established {formatDate(asset.establishedOn)}\n </span>\n </div>\n )}\n </dl>\n\n {asset.tags.length > 0 && (\n <ul className=\"flex flex-wrap gap-1.5\">\n {asset.tags.map((tag) => (\n <li\n key={tag}\n className=\"rounded-full bg-bg-sunken px-2 py-0.5 text-xs text-text-secondary\"\n >\n {tag}\n </li>\n ))}\n </ul>\n )}\n\n {hasContact && (\n <div className=\"mt-auto flex flex-wrap items-center gap-3 border-t border-border-seam pt-3 text-sm\">\n {asset.contactPhone && (\n <a\n href={`tel:${asset.contactPhone}`}\n className=\"inline-flex items-center gap-1.5 text-text-secondary transition-colors hover:text-text-primary\"\n >\n <Phone className=\"size-4\" aria-hidden=\"true\" /> {asset.contactPhone}\n </a>\n )}\n {asset.contactEmail && (\n <a\n href={`mailto:${asset.contactEmail}`}\n className=\"inline-flex items-center gap-1.5 truncate text-text-secondary transition-colors hover:text-text-primary\"\n >\n <Mail className=\"size-4 shrink-0\" aria-hidden=\"true\" />\n <span className=\"truncate\">{asset.contactEmail}</span>\n </a>\n )}\n {asset.website && (\n <a\n href={asset.website}\n target=\"_blank\"\n rel=\"noreferrer noopener\"\n className=\"inline-flex items-center gap-1.5 text-text-secondary transition-colors hover:text-text-primary\"\n >\n <Globe className=\"size-4\" aria-hidden=\"true\" /> Website\n </a>\n )}\n </div>\n )}\n </div>\n </GlassCard>\n );\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuFA,IAAM,IAAY,IAQZ,IAAoD;CACxD,aAAa;CACb,oBAAoB;CACpB,mBAAmB;CACnB,QAAQ;CACR,SAAS;AACX;AAEA,SAAgB,IAAiC;CAC/C,IAAM,EAAE,sBAAmB,GAAsC,GAC3D,IAAQ,EAAe,GAEvB,CAAC,GAAU,KAAe,EAAyB,KAAK,GACxD,CAAC,GAAU,KAAe,EAAyB,KAAK,GACxD,CAAC,GAAQ,KAAa,EAAuB,KAAK,GAClD,CAAC,GAAe,KAAoB,EAA8B,KAAK,GACvE,CAAC,GAAa,KAAkB,EAAS,EAAE,GAC3C,CAAC,GAAQ,KAAa,EAAS,EAAE,GAEjC,CAAC,GAAU,KAAe,EAAS,EAAK,GACxC,CAAC,GAAS,KAAc,EAAgC,IAAI,GAC5D,CAAC,GAAe,KAAoB,EAAgC,IAAI,GACxE,CAAC,GAAY,KAAiB,EAAwB,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C,OAAD;OAAK,WAAU;iBAAf,CACE,kBAAC,MAAD;QAAI,WAAU;kBAAU;OAAe,CAAA,GACvC,kBAAC,QAAD;QAAM,WAAU;kBAAhB,CAA0C,gBAC3B,EAAW,EAAM,aAAa,CACvC;SACH;;KAEL;;IAEH,EAAM,KAAK,SAAS,KACnB,kBAAC,MAAD;KAAI,WAAU;eACX,EAAM,KAAK,KAAK,MACf,kBAAC,MAAD;MAEE,WAAU;gBAET;KACC,GAJG,CAIH,CACL;IACC,CAAA;IAGL,KACC,kBAAC,OAAD;KAAK,WAAU;eAAf;MACG,EAAM,gBACL,kBAAC,KAAD;OACE,MAAM,OAAO,EAAM;OACnB,WAAU;iBAFZ;QAIE,kBAAC,GAAD;SAAO,WAAU;SAAS,eAAY;QAAQ,CAAA;QAAC;QAAE,EAAM;OACtD;;MAEJ,EAAM,gBACL,kBAAC,KAAD;OACE,MAAM,UAAU,EAAM;OACtB,WAAU;iBAFZ,CAIE,kBAAC,GAAD;QAAM,WAAU;QAAkB,eAAY;OAAQ,CAAA,GACtD,kBAAC,QAAD;QAAM,WAAU;kBAAY,EAAM;OAAmB,CAAA,CACpD;;MAEJ,EAAM,WACL,kBAAC,KAAD;OACE,MAAM,EAAM;OACZ,QAAO;OACP,KAAI;OACJ,WAAU;iBAJZ,CAME,kBAAC,GAAD;QAAO,WAAU;QAAS,eAAY;OAAQ,CAAA,GAAC,UAC9C;;KAEF;;GAEJ;IACI;;AAEf"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ServicePerformancePage.js","names":[],"sources":["../../../../src/govcitizenhub/pages/intelligence/ServicePerformancePage.tsx"],"sourcesContent":["/**\n * ServicePerformancePage — reused service-delivery and grievance performance\n * for one jurisdiction (BOFF-5666).\n * @module govcitizenhub/pages/intelligence\n *\n * Route: `intelligence/:jurisdictionId/services`\n *\n * This surface stores nothing. `govJurisdictionServicePerformance` is rolled up\n * live from the existing service catalogue + casework models, and\n * `govJurisdictionGrievanceInsights` from the existing grievance model — the\n * Community Intelligence module holds no shadow copy of an application, a\n * service or a citizen issue. Change a case and this page changes with it. That\n * anti-duplication contract is stated on the page itself, because it is the\n * reason the numbers here can be trusted to match the casework desk.\n *\n * NO FABRICATED DATA: every count, rate and duration below is a field of one of\n * those two responses. Nothing is estimated or back-filled client-side.\n */\n\nimport { type FC, type ReactElement, useMemo, useState } from 'react';\nimport { useParams } from 'react-router-dom';\nimport {\n BadgeCheck,\n CheckCircle2,\n FileText,\n Inbox,\n Info,\n MapPin,\n MessageSquareWarning,\n Timer,\n} from 'lucide-react';\nimport { Button, GlassCard, Input, Label } from '@burdenoff/fe-libs/ui';\n\nimport { JurisdictionLayout } from './JurisdictionLayout';\nimport { SectionCard } from '../../components/SectionCard';\nimport { MetricsCard } from '../../components/MetricsCard';\nimport { EmptyState } from '../../components/EmptyState';\nimport { LoadingView, ErrorView } from '../../components/StateViews';\nimport { GovDonutChart, ChartLegend, CHART_SERIES_COLORS } from '../../components/GovCharts';\nimport {\n useGovJurisdictionGrievanceInsights,\n useGovJurisdictionServicePerformance,\n} from '../../hooks';\nimport { describeError } from '../../lib/toast';\nimport { formatNumber, formatEnumLabel } from '../../utils/formatters';\nimport type {\n GovAgencyPerformanceRow,\n GovGrievanceInsights,\n GovServicePerformance,\n GovServicePerformanceRow,\n} from '../../types';\n\n/** How many grievance categories the \"top categories\" list shows. */\nconst TOP_CATEGORY_COUNT = 6;\n\n// ============================================================================\n// Formatting\n// ============================================================================\n\n/** A percentage the service computed, or an em-dash when it published none. */\nconst formatPercent = (value: number | null | undefined): string =>\n value == null ? '—' : `${formatNumber(value, { maximumFractionDigits: 1 })}%`;\n\n/** Durations read as hours up to two days, then as days. */\nfunction formatHours(value: number | null | undefined): string {\n if (value == null) return '—';\n if (value < 48) return `${formatNumber(value, { maximumFractionDigits: 1 })} h`;\n return `${formatNumber(value / 24, { maximumFractionDigits: 1 })} days`;\n}\n\n/** `YYYY-MM-DD` → the start of that day in ISO, or undefined when blank. */\nfunction toRangeStart(input: string): string | undefined {\n if (!input) return undefined;\n const parsed = new Date(`${input}T00:00:00.000Z`);\n return Number.isNaN(parsed.getTime()) ? undefined : parsed.toISOString();\n}\n\n/** `YYYY-MM-DD` → the END of that day in ISO, so the chosen day is inclusive. */\nfunction toRangeEnd(input: string): string | undefined {\n if (!input) return undefined;\n const parsed = new Date(`${input}T23:59:59.999Z`);\n return Number.isNaN(parsed.getTime()) ? undefined : parsed.toISOString();\n}\n\n/** Worst compliance first; rows the service could not score sink to the bottom. */\nfunction byWorstCompliance(\n a: { slaCompliancePercent?: number | null },\n b: { slaCompliancePercent?: number | null }\n): number {\n const left = a.slaCompliancePercent;\n const right = b.slaCompliancePercent;\n if (left == null && right == null) return 0;\n if (left == null) return 1;\n if (right == null) return -1;\n return left - right;\n}\n\n/** A neutral progress track — one token colour, no invented pass/fail threshold. */\nconst ComplianceBar: FC<{ percent: number | null | undefined; label: string }> = ({\n percent,\n label,\n}) => (\n <span className=\"flex items-center justify-end gap-2\">\n <span\n className=\"hidden h-2 w-20 overflow-hidden rounded-full bg-bg-sunken sm:inline-block\"\n role=\"img\"\n aria-label={`${label}: ${formatPercent(percent)}`}\n >\n {percent != null && (\n <span\n className=\"block h-full rounded-full bg-[var(--color-action-primary-bg)]\"\n style={{ width: `${Math.min(100, Math.max(0, percent))}%` }}\n />\n )}\n </span>\n <span className=\"w-14 text-right text-sm font-semibold tabular-nums text-text-primary\">\n {formatPercent(percent)}\n </span>\n </span>\n);\n\n// ============================================================================\n// Page\n// ============================================================================\n\nexport function ServicePerformancePage(): ReactElement {\n const { jurisdictionId } = useParams<{ jurisdictionId: string }>();\n\n const [fromDate, setFromDate] = useState('');\n const [toDate, setToDate] = useState('');\n\n const range = useMemo(\n () => ({ from: toRangeStart(fromDate), to: toRangeEnd(toDate) }),\n [fromDate, toDate]\n );\n\n const performance = useGovJurisdictionServicePerformance(jurisdictionId, range);\n const grievances = useGovJurisdictionGrievanceInsights(jurisdictionId, range);\n\n const rangeIsSet = Boolean(fromDate || toDate);\n\n return (\n <JurisdictionLayout description=\"Service delivery and citizen issues for this region, computed live.\">\n {/* --------------------------------------------- anti-duplication note */}\n <div className=\"mb-6 flex gap-3 rounded-lg border border-border-seam bg-bg-sunken p-4\">\n <Info className=\"mt-0.5 size-4 shrink-0 text-text-muted\" aria-hidden=\"true\" />\n <p className=\"text-sm text-text-secondary\">\n This page is computed live from the service catalogue, casework and grievance records.\n Community Intelligence keeps no second copy of an application, a service or a citizen\n issue — every figure below is derived on read, so it always matches the casework desk.\n </p>\n </div>\n\n {/* ------------------------------------------------------- date filter */}\n <GlassCard treatment=\"plain\" className=\"mb-6 border-border-seam p-5\">\n <div className=\"flex flex-wrap items-end gap-4\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"performance-from\">From</Label>\n <Input\n id=\"performance-from\"\n type=\"date\"\n value={fromDate}\n max={toDate || undefined}\n onChange={(event) => setFromDate(event.target.value)}\n className=\"w-44\"\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"performance-to\">To</Label>\n <Input\n id=\"performance-to\"\n type=\"date\"\n value={toDate}\n min={fromDate || undefined}\n onChange={(event) => setToDate(event.target.value)}\n className=\"w-44\"\n />\n </div>\n {rangeIsSet && (\n <Button\n variant=\"outline\"\n onClick={() => {\n setFromDate('');\n setToDate('');\n }}\n >\n Clear range\n </Button>\n )}\n <p className=\"text-xs text-text-muted\">\n {rangeIsSet\n ? 'Counting only cases and issues raised inside this window.'\n : 'Counting every case and issue on record for this region.'}\n </p>\n </div>\n </GlassCard>\n\n {/* -------------------------------------------------- service delivery */}\n {performance.isLoading ? (\n <LoadingView label=\"Computing service performance…\" />\n ) : performance.isError ? (\n <ErrorView\n title=\"We couldn't compute service performance\"\n message={describeError(performance.error)}\n onRetry={() => {\n void performance.refetch();\n }}\n />\n ) : !performance.data || performance.data.totalApplications === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title=\"No applications on record\"\n description={\n rangeIsSet\n ? 'No citizen applications were filed for this region inside the selected window.'\n : 'No citizen applications have been filed against this region’s services yet.'\n }\n action={\n rangeIsSet ? (\n <Button\n variant=\"outline\"\n onClick={() => {\n setFromDate('');\n setToDate('');\n }}\n >\n Clear range\n </Button>\n ) : undefined\n }\n />\n ) : (\n <ServiceDeliverySection performance={performance.data} />\n )}\n\n {/* ---------------------------------------------------- citizen issues */}\n <div className=\"mt-8\">\n <h2 className=\"mb-3 text-lg font-semibold text-text-primary\">Citizen issues</h2>\n {grievances.isLoading ? (\n <LoadingView label=\"Computing grievance insight…\" />\n ) : grievances.isError ? (\n <ErrorView\n title=\"We couldn't compute grievance insight\"\n message={describeError(grievances.error)}\n onRetry={() => {\n void grievances.refetch();\n }}\n />\n ) : !grievances.data || grievances.data.total === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title=\"No grievances on record\"\n description={\n rangeIsSet\n ? 'No citizen issues were reported for this region inside the selected window.'\n : 'No citizen issues have been reported against this region yet.'\n }\n />\n ) : (\n <GrievanceSection insights={grievances.data} />\n )}\n </div>\n </JurisdictionLayout>\n );\n}\n\n// ============================================================================\n// Service delivery\n// ============================================================================\n\nconst ServiceDeliverySection: FC<{ performance: GovServicePerformance }> = ({ performance }) => {\n const agencies = useMemo(\n () => [...performance.byAgency].sort(byWorstCompliance),\n [performance.byAgency]\n );\n const services = useMemo(\n () => [...performance.byService].sort(byWorstCompliance),\n [performance.byService]\n );\n\n return (\n <div className=\"space-y-6\">\n <div className=\"grid grid-cols-2 gap-4 sm:grid-cols-3 xl:grid-cols-5\">\n <MetricsCard\n icon={<FileText className=\"h-5 w-5\" />}\n value={formatNumber(performance.totalApplications)}\n label=\"Applications\"\n sublabel=\"filed against this region\"\n featured\n />\n <MetricsCard\n icon={<CheckCircle2 className=\"h-5 w-5\" />}\n value={formatPercent(performance.approvalRate)}\n label=\"Approval rate\"\n sublabel={\n performance.approvalRate == null\n ? 'nothing decided yet'\n : `${formatNumber(performance.approvedCount)} of ${formatNumber(\n performance.approvedCount + performance.rejectedCount\n )} decided`\n }\n accent=\"success\"\n />\n <MetricsCard\n icon={<Timer className=\"h-5 w-5\" />}\n value={formatHours(performance.avgProcessingHours)}\n label=\"Average processing\"\n sublabel=\"submission to decision\"\n />\n <MetricsCard\n icon={<BadgeCheck className=\"h-5 w-5\" />}\n value={formatPercent(performance.slaCompliancePercent)}\n label=\"SLA compliance\"\n sublabel={`${formatNumber(performance.slaBreachedCount)} breached`}\n accent={performance.slaBreachedCount > 0 ? 'warning' : 'success'}\n />\n <MetricsCard\n icon={<Inbox className=\"h-5 w-5\" />}\n value={formatNumber(performance.pendingCount)}\n label=\"Open backlog\"\n sublabel=\"awaiting a decision\"\n accent=\"warning\"\n />\n </div>\n\n {/* ------------------------------------------------- department league */}\n <SectionCard\n title=\"Departments, worst compliance first\"\n actions={\n <span className=\"text-xs text-text-muted\">\n Ordered by SLA compliance; unscored departments last\n </span>\n }\n flush\n >\n {agencies.length === 0 ? (\n <div className=\"p-5\">\n <EmptyState\n title=\"No department has handled a case yet\"\n description=\"Applications are not yet routed to an agency for this region.\"\n />\n </div>\n ) : (\n <div className=\"overflow-x-auto\">\n <table className=\"w-full min-w-[52rem] border-collapse text-left\">\n <thead>\n <tr className=\"border-b border-border-seam text-xs font-medium uppercase tracking-wide text-text-muted\">\n <th scope=\"col\" className=\"px-5 py-2.5 font-medium\">\n Department\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n Applications\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n Approved\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n Rejected\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n Pending\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n Avg processing\n </th>\n <th scope=\"col\" className=\"px-5 py-2.5 text-right font-medium\">\n SLA compliance\n </th>\n </tr>\n </thead>\n <tbody>\n {agencies.map((row: GovAgencyPerformanceRow) => (\n <tr\n key={row.agencyId}\n className=\"border-b border-border-subtle last:border-0 hover:bg-bg-sunken/60\"\n >\n <td className=\"px-5 py-3 text-sm font-medium text-text-primary\">\n {row.agencyName}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-text-secondary\">\n {formatNumber(row.applications)}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-status-success-text\">\n {formatNumber(row.approved)}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-status-error-text\">\n {formatNumber(row.rejected)}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-text-secondary\">\n {formatNumber(row.pending)}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-text-secondary\">\n {formatHours(row.avgProcessingHours)}\n </td>\n <td className=\"px-5 py-3\">\n <ComplianceBar\n percent={row.slaCompliancePercent}\n label={`${row.agencyName} SLA compliance`}\n />\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )}\n </SectionCard>\n\n {/* ---------------------------------------------------- by service */}\n <SectionCard title=\"By service\" flush>\n {services.length === 0 ? (\n <div className=\"p-5\">\n <EmptyState\n title=\"No service has been applied for yet\"\n description=\"Once citizens file against a published service it appears here.\"\n />\n </div>\n ) : (\n <div className=\"overflow-x-auto\">\n <table className=\"w-full min-w-[52rem] border-collapse text-left\">\n <thead>\n <tr className=\"border-b border-border-seam text-xs font-medium uppercase tracking-wide text-text-muted\">\n <th scope=\"col\" className=\"px-5 py-2.5 font-medium\">\n Service\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n Applications\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n Approved\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n Rejected\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n Pending\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n SLA\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n Avg processing\n </th>\n <th scope=\"col\" className=\"px-5 py-2.5 text-right font-medium\">\n SLA compliance\n </th>\n </tr>\n </thead>\n <tbody>\n {services.map((row: GovServicePerformanceRow) => (\n <tr\n key={row.serviceId}\n className=\"border-b border-border-subtle last:border-0 hover:bg-bg-sunken/60\"\n >\n <td className=\"px-5 py-3 text-sm font-medium text-text-primary\">\n {row.serviceName}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-text-secondary\">\n {formatNumber(row.applications)}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-status-success-text\">\n {formatNumber(row.approved)}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-status-error-text\">\n {formatNumber(row.rejected)}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-text-secondary\">\n {formatNumber(row.pending)}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-text-muted\">\n {formatNumber(row.slaDays)} day{row.slaDays === 1 ? '' : 's'}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-text-secondary\">\n {formatHours(row.avgProcessingHours)}\n </td>\n <td className=\"px-5 py-3\">\n <ComplianceBar\n percent={row.slaCompliancePercent}\n label={`${row.serviceName} SLA compliance`}\n />\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )}\n </SectionCard>\n </div>\n );\n};\n\n// ============================================================================\n// Citizen issues\n// ============================================================================\n\nconst GrievanceSection: FC<{ insights: GovGrievanceInsights }> = ({ insights }) => {\n const slices = useMemo(\n () =>\n [\n { name: 'Open', value: insights.open, color: CHART_SERIES_COLORS[0] },\n { name: 'In progress', value: insights.inProgress, color: CHART_SERIES_COLORS[1] },\n { name: 'Resolved', value: insights.resolved, color: CHART_SERIES_COLORS[2] },\n ].filter((slice) => slice.value > 0),\n [insights]\n );\n\n /**\n * Grievances the service counts in `total` but in none of the three tracked\n * states (a rejected report). Rendered only when it is non-zero, so the three\n * states are never implied to add up to the total.\n */\n const otherStates = Math.max(\n 0,\n insights.total - insights.open - insights.inProgress - insights.resolved\n );\n\n const topCategories = useMemo(\n () => [...insights.byCategory].sort((a, b) => b.total - a.total).slice(0, TOP_CATEGORY_COUNT),\n [insights.byCategory]\n );\n const categoryMax = topCategories.reduce((max, row) => Math.max(max, row.total), 0);\n\n return (\n <div className=\"grid grid-cols-1 gap-6 xl:grid-cols-3\">\n <SectionCard\n title=\"Where issues stand\"\n icon={<MessageSquareWarning aria-hidden=\"true\" />}\n className=\"xl:col-span-1\"\n >\n <GovDonutChart\n data={slices}\n centerValue={formatNumber(insights.total)}\n centerLabel=\"Reported\"\n emptyLabel=\"No issues in a tracked state.\"\n />\n <ChartLegend\n className=\"mt-4\"\n items={slices.map((slice) => ({\n label: slice.name,\n color: slice.color,\n value: formatNumber(slice.value),\n }))}\n />\n <div className=\"mt-4 space-y-1.5 border-t border-border-seam pt-3 text-xs text-text-muted\">\n <p>\n Average resolution time:{' '}\n <span className=\"font-semibold text-text-secondary\">\n {formatHours(insights.avgResolutionHours)}\n </span>\n </p>\n {otherStates > 0 && (\n <p>\n {formatNumber(otherStates)} further report{otherStates === 1 ? '' : 's'} sit in another\n state (for example rejected) and are counted in the total but not in the three states\n above.\n </p>\n )}\n </div>\n </SectionCard>\n\n <SectionCard title=\"Top categories\" className=\"xl:col-span-1\">\n {topCategories.length === 0 ? (\n <EmptyState\n title=\"No categorised issues\"\n description=\"Reported issues will group by service category here.\"\n />\n ) : (\n <ul className=\"space-y-3\">\n {topCategories.map((row) => {\n const width = categoryMax > 0 ? Math.round((row.total / categoryMax) * 100) : 0;\n return (\n <li key={row.category}>\n <div className=\"flex items-baseline justify-between gap-3\">\n <span className=\"truncate text-sm font-medium text-text-primary\">\n {formatEnumLabel(row.category)}\n </span>\n <span className=\"shrink-0 text-sm tabular-nums text-text-secondary\">\n {formatNumber(row.total)}\n </span>\n </div>\n <span className=\"mt-1 block h-2 overflow-hidden rounded-full bg-bg-sunken\">\n <span\n className=\"block h-full rounded-full bg-[var(--color-chart-2)]\"\n style={{ width: `${width}%` }}\n aria-hidden=\"true\"\n />\n </span>\n <p className=\"mt-1 text-xs text-text-muted\">\n {formatNumber(row.resolved)} resolved · average{' '}\n {formatHours(row.avgResolutionHours)}\n </p>\n </li>\n );\n })}\n </ul>\n )}\n </SectionCard>\n\n <SectionCard title=\"Recurring hotspots\" icon={<MapPin aria-hidden=\"true\" />}>\n {insights.hotspots.length === 0 ? (\n <EmptyState\n title=\"No publishable clusters\"\n description=\"No location has enough reports to publish a hotspot without risking a reporter's privacy.\"\n />\n ) : (\n <ul className=\"space-y-2.5\">\n {insights.hotspots.map((hotspot) => (\n <li\n key={`${hotspot.locationLabel}-${hotspot.topCategory}`}\n className=\"flex items-start justify-between gap-3 rounded-lg border border-border-seam px-3 py-2.5\"\n >\n <span className=\"min-w-0\">\n <span className=\"block truncate text-sm font-medium text-text-primary\">\n {hotspot.locationLabel}\n </span>\n <span className=\"block text-xs text-text-muted\">\n Mostly {formatEnumLabel(hotspot.topCategory)}\n </span>\n </span>\n <span className=\"shrink-0 rounded-full bg-bg-sunken px-2.5 py-0.5 text-sm font-semibold tabular-nums text-text-secondary\">\n {formatNumber(hotspot.count)}\n </span>\n </li>\n ))}\n </ul>\n )}\n <p className=\"mt-4 border-t border-border-seam pt-3 text-xs text-text-muted\">\n Clusters below the suppression threshold are withheld: at a street-level label a\n “hotspot” of one or two reports can identify the person who filed it. Only\n locations with enough reports to stay anonymous are published here.\n </p>\n </SectionCard>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAqDA,IAAM,IAAqB,GAOrB,KAAiB,MACrB,KAAS,OAAO,MAAM,GAAG,EAAa,GAAO,EAAE,uBAAuB,EAAE,CAAC,EAAE;AAG7E,SAAS,EAAY,GAA0C;CAG7D,OAFI,KAAS,OAAa,MACtB,IAAQ,KAAW,GAAG,EAAa,GAAO,EAAE,uBAAuB,EAAE,CAAC,EAAE,MACrE,GAAG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AAQ,WAAW,CACvC;SACF;UACN,kBAAC,QAAD;OAAM,WAAU;iBACb,EAAa,EAAQ,KAAK;MACvB,CAAA,CACJ;QAdG,GAAG,EAAQ,cAAc,GAAG,EAAQ,aAcvC,CACL;IACC,CAAA,GAEN,kBAAC,KAAD;KAAG,WAAU;eAAgE;IAI1E,CAAA,CACQ;;EACV;;AAET"}
|
|
1
|
+
{"version":3,"file":"ServicePerformancePage.js","names":[],"sources":["../../../../src/govcitizenhub/pages/intelligence/ServicePerformancePage.tsx"],"sourcesContent":["/**\n * ServicePerformancePage — reused service-delivery and grievance performance\n * for one jurisdiction (BOFF-5666).\n * @module govcitizenhub/pages/intelligence\n *\n * Route: `intelligence/:jurisdictionId/services`\n *\n * This surface stores nothing. `govJurisdictionServicePerformance` is rolled up\n * live from the existing service catalogue + casework models, and\n * `govJurisdictionGrievanceInsights` from the existing grievance model — the\n * Community Intelligence module holds no shadow copy of an application, a\n * service or a citizen issue. Change a case and this page changes with it. That\n * anti-duplication contract is stated on the page itself, because it is the\n * reason the numbers here can be trusted to match the casework desk.\n *\n * NO FABRICATED DATA: every count, rate and duration below is a field of one of\n * those two responses. Nothing is estimated or back-filled client-side.\n */\n\nimport { type FC, type ReactElement, useMemo, useState } from 'react';\nimport { useParams } from 'react-router-dom';\nimport {\n BadgeCheck,\n CheckCircle2,\n FileText,\n Inbox,\n Info,\n MapPin,\n MessageSquareWarning,\n Timer,\n} from 'lucide-react';\nimport { Button, GlassCard, Input, Label } from '@burdenoff/fe-libs/ui';\n\nimport { JurisdictionLayout } from './JurisdictionLayout';\nimport { SectionCard } from '../../components/SectionCard';\nimport { MetricsCard } from '../../components/MetricsCard';\nimport { EmptyState } from '../../components/EmptyState';\nimport { LoadingView, ErrorView } from '../../components/StateViews';\nimport { GovDonutChart, ChartLegend, CHART_SERIES_COLORS } from '../../components/GovCharts';\nimport {\n useGovJurisdictionGrievanceInsights,\n useGovJurisdictionServicePerformance,\n} from '../../hooks';\nimport { describeError } from '../../lib/toast';\nimport { formatNumber, formatEnumLabel } from '../../utils/formatters';\nimport type {\n GovAgencyPerformanceRow,\n GovGrievanceInsights,\n GovServicePerformance,\n GovServicePerformanceRow,\n} from '../../types';\n\n/** How many grievance categories the \"top categories\" list shows. */\nconst TOP_CATEGORY_COUNT = 6;\n\n// ============================================================================\n// Formatting\n// ============================================================================\n\n/** A percentage the service computed, or an em-dash when it published none. */\nconst formatPercent = (value: number | null | undefined): string =>\n value == null ? '—' : `${formatNumber(value, { maximumFractionDigits: 1 })}%`;\n\n/** Durations read as hours up to two days, then as days. */\nfunction formatHours(value: number | null | undefined): string {\n if (value == null) return '—';\n if (value < 48) return `${formatNumber(value, { maximumFractionDigits: 1 })} h`;\n return `${formatNumber(value / 24, { maximumFractionDigits: 1 })} days`;\n}\n\n/** `YYYY-MM-DD` → the start of that day in ISO, or undefined when blank. */\nfunction toRangeStart(input: string): string | undefined {\n if (!input) return undefined;\n const parsed = new Date(`${input}T00:00:00.000Z`);\n return Number.isNaN(parsed.getTime()) ? undefined : parsed.toISOString();\n}\n\n/** `YYYY-MM-DD` → the END of that day in ISO, so the chosen day is inclusive. */\nfunction toRangeEnd(input: string): string | undefined {\n if (!input) return undefined;\n const parsed = new Date(`${input}T23:59:59.999Z`);\n return Number.isNaN(parsed.getTime()) ? undefined : parsed.toISOString();\n}\n\n/** Worst compliance first; rows the service could not score sink to the bottom. */\nfunction byWorstCompliance(\n a: { slaCompliancePercent?: number | null },\n b: { slaCompliancePercent?: number | null }\n): number {\n const left = a.slaCompliancePercent;\n const right = b.slaCompliancePercent;\n if (left == null && right == null) return 0;\n if (left == null) return 1;\n if (right == null) return -1;\n return left - right;\n}\n\n/** A neutral progress track — one token colour, no invented pass/fail threshold. */\nconst ComplianceBar: FC<{ percent: number | null | undefined; label: string }> = ({\n percent,\n label,\n}) => (\n <span className=\"flex items-center justify-end gap-2\">\n <span\n className=\"hidden h-2 w-20 overflow-hidden rounded-full bg-bg-sunken sm:inline-block\"\n role=\"img\"\n aria-label={`${label}: ${formatPercent(percent)}`}\n >\n {percent != null && (\n <span\n className=\"block h-full rounded-full bg-[var(--color-action-primary-bg)]\"\n style={{ width: `${Math.min(100, Math.max(0, percent))}%` }}\n />\n )}\n </span>\n <span className=\"w-14 text-right text-sm font-semibold tabular-nums text-text-primary\">\n {formatPercent(percent)}\n </span>\n </span>\n);\n\n// ============================================================================\n// Page\n// ============================================================================\n\nexport function ServicePerformancePage(): ReactElement {\n const { jurisdictionId } = useParams<{ jurisdictionId: string }>();\n\n const [fromDate, setFromDate] = useState('');\n const [toDate, setToDate] = useState('');\n\n const range = useMemo(\n () => ({ from: toRangeStart(fromDate), to: toRangeEnd(toDate) }),\n [fromDate, toDate]\n );\n\n const performance = useGovJurisdictionServicePerformance(jurisdictionId, range);\n const grievances = useGovJurisdictionGrievanceInsights(jurisdictionId, range);\n\n const rangeIsSet = Boolean(fromDate || toDate);\n\n return (\n <JurisdictionLayout description=\"Service delivery and citizen issues for this region, computed live.\">\n {/* --------------------------------------------- anti-duplication note */}\n <div className=\"mb-6 flex gap-3 rounded-lg border border-border-seam bg-bg-sunken p-4\">\n <Info className=\"mt-0.5 size-4 shrink-0 text-text-muted\" aria-hidden=\"true\" />\n <p className=\"text-sm text-text-secondary\">\n This page is computed live from the service catalogue, casework and grievance records.\n Community Intelligence keeps no second copy of an application, a service or a citizen\n issue — every figure below is derived on read, so it always matches the casework desk.\n </p>\n </div>\n\n {/* ------------------------------------------------------- date filter */}\n <GlassCard treatment=\"plain\" className=\"mb-6 border-border-seam p-5\">\n <div className=\"flex flex-wrap items-end gap-4\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"performance-from\">From</Label>\n <Input\n id=\"performance-from\"\n type=\"date\"\n value={fromDate}\n max={toDate || undefined}\n onChange={(event) => setFromDate(event.target.value)}\n className=\"w-44\"\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"performance-to\">To</Label>\n <Input\n id=\"performance-to\"\n type=\"date\"\n value={toDate}\n min={fromDate || undefined}\n onChange={(event) => setToDate(event.target.value)}\n className=\"w-44\"\n />\n </div>\n {rangeIsSet && (\n <Button\n variant=\"outline\"\n onClick={() => {\n setFromDate('');\n setToDate('');\n }}\n >\n Clear range\n </Button>\n )}\n <p className=\"text-xs text-text-muted\">\n {rangeIsSet\n ? 'Counting only cases and issues raised inside this window.'\n : 'Counting every case and issue on record for this region.'}\n </p>\n </div>\n </GlassCard>\n\n {/* -------------------------------------------------- service delivery */}\n {performance.isLoading ? (\n <LoadingView label=\"Computing service performance…\" />\n ) : performance.isError ? (\n <ErrorView\n title=\"We couldn't compute service performance\"\n message={describeError(performance.error)}\n onRetry={() => {\n void performance.refetch();\n }}\n />\n ) : !performance.data || performance.data.totalApplications === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title=\"No applications on record\"\n description={\n rangeIsSet\n ? 'No citizen applications were filed for this region inside the selected window.'\n : 'No citizen applications have been filed against this region’s services yet.'\n }\n action={\n rangeIsSet ? (\n <Button\n variant=\"outline\"\n onClick={() => {\n setFromDate('');\n setToDate('');\n }}\n >\n Clear range\n </Button>\n ) : undefined\n }\n />\n ) : (\n <ServiceDeliverySection performance={performance.data} />\n )}\n\n {/* ---------------------------------------------------- citizen issues */}\n <div className=\"mt-8\">\n <h2 className=\"mb-3 text-lg font-semibold text-text-primary\">Citizen issues</h2>\n {grievances.isLoading ? (\n <LoadingView label=\"Computing grievance insight…\" />\n ) : grievances.isError ? (\n <ErrorView\n title=\"We couldn't compute grievance insight\"\n message={describeError(grievances.error)}\n onRetry={() => {\n void grievances.refetch();\n }}\n />\n ) : !grievances.data || grievances.data.total === 0 ? (\n <EmptyState\n illustration=\"empty-data\"\n title=\"No grievances on record\"\n description={\n rangeIsSet\n ? 'No citizen issues were reported for this region inside the selected window.'\n : 'No citizen issues have been reported against this region yet.'\n }\n />\n ) : (\n <GrievanceSection insights={grievances.data} />\n )}\n </div>\n </JurisdictionLayout>\n );\n}\n\n// ============================================================================\n// Service delivery\n// ============================================================================\n\nconst ServiceDeliverySection: FC<{ performance: GovServicePerformance }> = ({ performance }) => {\n const agencies = useMemo(\n () => [...performance.byAgency].sort(byWorstCompliance),\n [performance.byAgency]\n );\n const services = useMemo(\n () => [...performance.byService].sort(byWorstCompliance),\n [performance.byService]\n );\n\n return (\n <div className=\"space-y-6\">\n <div className=\"grid grid-cols-2 gap-4 sm:grid-cols-3 xl:grid-cols-5\">\n <MetricsCard\n icon={<FileText className=\"h-5 w-5\" />}\n value={formatNumber(performance.totalApplications)}\n label=\"Applications\"\n sublabel=\"filed against this region\"\n featured\n />\n <MetricsCard\n icon={<CheckCircle2 className=\"h-5 w-5\" />}\n value={formatPercent(performance.approvalRate)}\n label=\"Approval rate\"\n sublabel={\n performance.approvalRate == null\n ? 'nothing decided yet'\n : `${formatNumber(performance.approvedCount)} of ${formatNumber(\n performance.approvedCount + performance.rejectedCount\n )} decided`\n }\n accent=\"success\"\n />\n <MetricsCard\n icon={<Timer className=\"h-5 w-5\" />}\n value={formatHours(performance.avgProcessingHours)}\n label=\"Average processing\"\n sublabel=\"submission to decision\"\n />\n <MetricsCard\n icon={<BadgeCheck className=\"h-5 w-5\" />}\n value={formatPercent(performance.slaCompliancePercent)}\n label=\"SLA compliance\"\n sublabel={`${formatNumber(performance.slaBreachedCount)} breached`}\n accent={performance.slaBreachedCount > 0 ? 'warning' : 'success'}\n />\n <MetricsCard\n icon={<Inbox className=\"h-5 w-5\" />}\n value={formatNumber(performance.pendingCount)}\n label=\"Open backlog\"\n sublabel=\"awaiting a decision\"\n accent=\"warning\"\n />\n </div>\n\n {/* ------------------------------------------------- department league */}\n <SectionCard\n title=\"Departments, worst compliance first\"\n actions={\n <span className=\"text-xs text-text-muted\">\n Ordered by SLA compliance; unscored departments last\n </span>\n }\n flush\n >\n {agencies.length === 0 ? (\n <div className=\"p-5\">\n <EmptyState\n title=\"No department has handled a case yet\"\n description=\"Applications are not yet routed to an agency for this region.\"\n />\n </div>\n ) : (\n <div className=\"overflow-x-auto\">\n <table className=\"w-full min-w-[52rem] border-collapse text-left\">\n <thead>\n <tr className=\"border-b border-border-seam text-xs font-medium uppercase tracking-wide text-text-muted\">\n <th scope=\"col\" className=\"px-5 py-2.5 font-medium\">\n Department\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n Applications\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n Approved\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n Rejected\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n Pending\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n Avg processing\n </th>\n <th scope=\"col\" className=\"px-5 py-2.5 text-right font-medium\">\n SLA compliance\n </th>\n </tr>\n </thead>\n <tbody>\n {agencies.map((row: GovAgencyPerformanceRow) => (\n <tr\n key={row.agencyId}\n className=\"border-b border-border-subtle last:border-0 hover:bg-bg-sunken/60\"\n >\n <td className=\"px-5 py-3 text-sm font-medium text-text-primary\">\n {row.agencyName}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-text-secondary\">\n {formatNumber(row.applications)}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-status-success-text\">\n {formatNumber(row.approved)}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-status-error-text\">\n {formatNumber(row.rejected)}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-text-secondary\">\n {formatNumber(row.pending)}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-text-secondary\">\n {formatHours(row.avgProcessingHours)}\n </td>\n <td className=\"px-5 py-3\">\n <ComplianceBar\n percent={row.slaCompliancePercent}\n label={`${row.agencyName} SLA compliance`}\n />\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )}\n </SectionCard>\n\n {/* ---------------------------------------------------- by service */}\n <SectionCard title=\"By service\" flush>\n {services.length === 0 ? (\n <div className=\"p-5\">\n <EmptyState\n title=\"No service has been applied for yet\"\n description=\"Once citizens file against a published service it appears here.\"\n />\n </div>\n ) : (\n <div className=\"overflow-x-auto\">\n <table className=\"w-full min-w-[52rem] border-collapse text-left\">\n <thead>\n <tr className=\"border-b border-border-seam text-xs font-medium uppercase tracking-wide text-text-muted\">\n <th scope=\"col\" className=\"px-5 py-2.5 font-medium\">\n Service\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n Applications\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n Approved\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n Rejected\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n Pending\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n SLA\n </th>\n <th scope=\"col\" className=\"px-3 py-2.5 text-right font-medium\">\n Avg processing\n </th>\n <th scope=\"col\" className=\"px-5 py-2.5 text-right font-medium\">\n SLA compliance\n </th>\n </tr>\n </thead>\n <tbody>\n {services.map((row: GovServicePerformanceRow) => (\n <tr\n key={row.serviceId}\n className=\"border-b border-border-subtle last:border-0 hover:bg-bg-sunken/60\"\n >\n <td className=\"px-5 py-3 text-sm font-medium text-text-primary\">\n {row.serviceName}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-text-secondary\">\n {formatNumber(row.applications)}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-status-success-text\">\n {formatNumber(row.approved)}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-status-error-text\">\n {formatNumber(row.rejected)}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-text-secondary\">\n {formatNumber(row.pending)}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-text-muted\">\n {formatNumber(row.slaDays)} day{row.slaDays === 1 ? '' : 's'}\n </td>\n <td className=\"px-3 py-3 text-right text-sm tabular-nums text-text-secondary\">\n {formatHours(row.avgProcessingHours)}\n </td>\n <td className=\"px-5 py-3\">\n <ComplianceBar\n percent={row.slaCompliancePercent}\n label={`${row.serviceName} SLA compliance`}\n />\n </td>\n </tr>\n ))}\n </tbody>\n </table>\n </div>\n )}\n </SectionCard>\n </div>\n );\n};\n\n// ============================================================================\n// Citizen issues\n// ============================================================================\n\nconst GrievanceSection: FC<{ insights: GovGrievanceInsights }> = ({ insights }) => {\n const slices = useMemo(\n () =>\n [\n { name: 'Open', value: insights.open, color: CHART_SERIES_COLORS[0] },\n { name: 'In progress', value: insights.inProgress, color: CHART_SERIES_COLORS[1] },\n { name: 'Resolved', value: insights.resolved, color: CHART_SERIES_COLORS[2] },\n ].filter((slice) => slice.value > 0),\n [insights]\n );\n\n /**\n * Grievances the service counts in `total` but in none of the three tracked\n * states (a rejected report). Rendered only when it is non-zero, so the three\n * states are never implied to add up to the total.\n */\n const otherStates = Math.max(\n 0,\n insights.total - insights.open - insights.inProgress - insights.resolved\n );\n\n const topCategories = useMemo(\n () => [...insights.byCategory].sort((a, b) => b.total - a.total).slice(0, TOP_CATEGORY_COUNT),\n [insights.byCategory]\n );\n const categoryMax = topCategories.reduce((max, row) => Math.max(max, row.total), 0);\n\n return (\n <div className=\"grid grid-cols-1 gap-6 xl:grid-cols-3\">\n <SectionCard\n title=\"Where issues stand\"\n icon={<MessageSquareWarning aria-hidden=\"true\" />}\n className=\"xl:col-span-1\"\n >\n <GovDonutChart\n data={slices}\n centerValue={formatNumber(insights.total)}\n centerLabel=\"Reported\"\n emptyLabel=\"No issues in a tracked state.\"\n />\n <ChartLegend\n className=\"mt-4\"\n items={slices.map((slice) => ({\n label: slice.name,\n color: slice.color,\n value: formatNumber(slice.value),\n }))}\n />\n <div className=\"mt-4 space-y-1.5 border-t border-border-seam pt-3 text-xs text-text-muted\">\n <p>\n Average resolution time:{' '}\n <span className=\"font-semibold text-text-secondary\">\n {formatHours(insights.avgResolutionHours)}\n </span>\n </p>\n {otherStates > 0 && (\n <p>\n {formatNumber(otherStates)} further report{otherStates === 1 ? '' : 's'} sit in\n another state (for example rejected) and are counted in the total but not in the three\n states above.\n </p>\n )}\n </div>\n </SectionCard>\n\n <SectionCard title=\"Top categories\" className=\"xl:col-span-1\">\n {topCategories.length === 0 ? (\n <EmptyState\n title=\"No categorised issues\"\n description=\"Reported issues will group by service category here.\"\n />\n ) : (\n <ul className=\"space-y-3\">\n {topCategories.map((row) => {\n const width = categoryMax > 0 ? Math.round((row.total / categoryMax) * 100) : 0;\n return (\n <li key={row.category}>\n <div className=\"flex items-baseline justify-between gap-3\">\n <span className=\"truncate text-sm font-medium text-text-primary\">\n {formatEnumLabel(row.category)}\n </span>\n <span className=\"shrink-0 text-sm tabular-nums text-text-secondary\">\n {formatNumber(row.total)}\n </span>\n </div>\n <span className=\"mt-1 block h-2 overflow-hidden rounded-full bg-bg-sunken\">\n <span\n className=\"block h-full rounded-full bg-[var(--color-chart-2)]\"\n style={{ width: `${width}%` }}\n aria-hidden=\"true\"\n />\n </span>\n <p className=\"mt-1 text-xs text-text-muted\">\n {formatNumber(row.resolved)} resolved · average{' '}\n {formatHours(row.avgResolutionHours)}\n </p>\n </li>\n );\n })}\n </ul>\n )}\n </SectionCard>\n\n <SectionCard title=\"Recurring hotspots\" icon={<MapPin aria-hidden=\"true\" />}>\n {insights.hotspots.length === 0 ? (\n <EmptyState\n title=\"No publishable clusters\"\n description=\"No location has enough reports to publish a hotspot without risking a reporter's privacy.\"\n />\n ) : (\n <ul className=\"space-y-2.5\">\n {insights.hotspots.map((hotspot) => (\n <li\n key={`${hotspot.locationLabel}-${hotspot.topCategory}`}\n className=\"flex items-start justify-between gap-3 rounded-lg border border-border-seam px-3 py-2.5\"\n >\n <span className=\"min-w-0\">\n <span className=\"block truncate text-sm font-medium text-text-primary\">\n {hotspot.locationLabel}\n </span>\n <span className=\"block text-xs text-text-muted\">\n Mostly {formatEnumLabel(hotspot.topCategory)}\n </span>\n </span>\n <span className=\"shrink-0 rounded-full bg-bg-sunken px-2.5 py-0.5 text-sm font-semibold tabular-nums text-text-secondary\">\n {formatNumber(hotspot.count)}\n </span>\n </li>\n ))}\n </ul>\n )}\n <p className=\"mt-4 border-t border-border-seam pt-3 text-xs text-text-muted\">\n Clusters below the suppression threshold are withheld: at a street-level label a\n “hotspot” of one or two reports can identify the person who filed it. Only\n locations with enough reports to stay anonymous are published here.\n </p>\n </SectionCard>\n </div>\n );\n};\n"],"mappings":";;;;;;;;;;;;;;;;AAqDA,IAAM,IAAqB,GAOrB,KAAiB,MACrB,KAAS,OAAO,MAAM,GAAG,EAAa,GAAO,EAAE,uBAAuB,EAAE,CAAC,EAAE;AAG7E,SAAS,EAAY,GAA0C;CAG7D,OAFI,KAAS,OAAa,MACtB,IAAQ,KAAW,GAAG,EAAa,GAAO,EAAE,uBAAuB,EAAE,CAAC,EAAE,MACrE,GAAG,EAAa,IAAQ,IAAI,EAAE,uBAAuB,EAAE,CAAC,EAAE;AACnE;AAGA,SAAS,EAAa,GAAmC;CACvD,IAAI,CAAC,GAAO;CACZ,IAAM,oBAAS,IAAI,KAAK,GAAG,EAAM,eAAe;CAChD,OAAO,OAAO,MAAM,EAAO,QAAQ,CAAC,IAAI,KAAA,IAAY,EAAO,YAAY;AACzE;AAGA,SAAS,EAAW,GAAmC;CACrD,IAAI,CAAC,GAAO;CACZ,IAAM,oBAAS,IAAI,KAAK,GAAG,EAAM,eAAe;CAChD,OAAO,OAAO,MAAM,EAAO,QAAQ,CAAC,IAAI,KAAA,IAAY,EAAO,YAAY;AACzE;AAGA,SAAS,EACP,GACA,GACQ;CACR,IAAM,IAAO,EAAE,sBACT,IAAQ,EAAE;CAIhB,OAHI,KAAQ,QAAQ,KAAS,OAAa,IACtC,KAAQ,OAAa,IACrB,KAAS,OAAa,KACnB,IAAO;AAChB;AAGA,IAAM,KAA4E,EAChF,YACA,eAEA,kBAAC,QAAD;CAAM,WAAU;WAAhB,CACE,kBAAC,QAAD;EACE,WAAU;EACV,MAAK;EACL,c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AAI,QAAQ;SAAE;SAAoB;SAC/C,EAAY,EAAI,kBAAkB;QAClC;;MACD,EAAA,GApBK,EAAI,QAoBT;KAER,CAAC;IACC,CAAA;GAEK,CAAA;GAEb,kBAAC,GAAD;IAAa,OAAM;IAAqB,MAAM,kBAAC,GAAD,EAAQ,eAAY,OAAQ,CAAA;cAA1E,CACG,EAAS,SAAS,WAAW,IAC5B,kBAAC,GAAD;KACE,OAAM;KACN,aAAY;IACb,CAAA,IAED,kBAAC,MAAD;KAAI,WAAU;eACX,EAAS,SAAS,KAAK,MACtB,kBAAC,MAAD;MAEE,WAAU;gBAFZ,CAIE,kBAAC,QAAD;OAAM,WAAU;iBAAhB,CACE,kBAAC,QAAD;QAAM,WAAU;kBACb,EAAQ;OACL,CAAA,GACN,kBAAC,QAAD;QAAM,WAAU;kBAAhB,CAAgD,WACtC,EAAgB,EAAQ,WAAW,CACvC;SACF;UACN,kBAAC,QAAD;OAAM,WAAU;iBACb,EAAa,EAAQ,KAAK;MACvB,CAAA,CACJ;QAdG,GAAG,EAAQ,cAAc,GAAG,EAAQ,aAcvC,CACL;IACC,CAAA,GAEN,kBAAC,KAAD;KAAG,WAAU;eAAgE;IAI1E,CAAA,CACQ;;EACV;;AAET"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consultationQuestions.d.ts","sourceRoot":"","sources":["../../../../src/govcitizenhub/pages/intelligence/consultationQuestions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,4DAA4D;AAC5D,eAAO,MAAM,2BAA2B,mFAM9B,CAAC;AAEX,MAAM,MAAM,2BAA2B,GAAG,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvF,2EAA2E;AAC3E,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,2BAA2B,EAAE,MAAM,CAM5E,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oBAAoB,OAAO,CAAC;AAEzC,4CAA4C;AAC5C,MAAM,WAAW,oBAAoB;IACnC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,2BAA2B,CAAC;IAClC,QAAQ,EAAE,OAAO,CAAC;IAClB,0DAA0D;IAC1D,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;IACnB,GAAG,EAAE,MAAM,GAAG,IAAI,CAAC;CACpB;AAED,qDAAqD;AACrD,MAAM,WAAW,kBAAkB;IACjC,UAAU,EAAE,MAAM,CAAC;IACnB,KAAK,EAAE,OAAO,CAAC;CAChB;AAqBD,8EAA8E;AAC9E,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAS5D;AASD,6DAA6D;AAC7D,wBAAgB,0BAA0B,CAAC,SAAS,EAAE,OAAO,GAAG,oBAAoB,EAAE,CAqCrF;AAED,wDAAwD;AACxD,wBAAgB,wBAAwB,CAAC,OAAO,EAAE,OAAO,GAAG,kBAAkB,EAAE,CAa/E;AAED,iFAAiF;AACjF,wBAAgB,YAAY,
|
|
1
|
+
{"version":3,"file":"consultationQuestions.d.ts","sourceRoot":"","sources":["../../../../src/govcitizenhub/pages/intelligence/consultationQuestions.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AAE3C,4DAA4D;AAC5D,eAAO,MAAM,2BAA2B,mFAM9B,CAAC;AAEX,MAAM,MAAM,2BAA2B,GAAG,CAAC,OAAO,2BAA2B,CAAC,CAAC,MAAM,CAAC,CAAC;AAEvF,2EAA2E;AAC3E,eAAO,MAAM,oBAAoB,EAAE,MAAM,CAAC,2BAA2B,EAAE,MAAM,CAM5E,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,oB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E,OAAO,GAAG,MAAM,EAAE,CA8B5F;AAED,iFAAiF;AACjF,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CASrE"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"consultationQuestions.js","names":[],"sources":["../../../../src/govcitizenhub/pages/intelligence/consultationQuestions.ts"],"sourcesContent":["/**\n * Consultation question-schema helpers.\n * @module govcitizenhub/pages/intelligence\n *\n * `GovConsultation.questions` and `GovConsultationResponse.answers` are JSON\n * scalars, so the shapes the backend validates\n * (`[{ id, label, type, options?, required, min?, max? }]` and\n * `[{ questionId, value }]`) have to be re-established on the client before\n * anything can be rendered.\n *\n * These readers are deliberately TOLERANT: a malformed entry is skipped rather\n * than thrown away wholesale or replaced with a plausible-looking default, so a\n * partially malformed schema still renders the questions that are valid and\n * never invents one that is not there.\n *\n * The rules mirror `participation.service.ts` exactly — including the\n * budget-allocation sum tolerance — so the form blocks locally on the same\n * grounds the API would reject on.\n */\n\nimport type { GovJson } from '../../types';\n\n/** The five question types the frozen contract declares. */\nexport const CONSULTATION_QUESTION_TYPES = [\n 'SINGLE_CHOICE',\n 'MULTI_CHOICE',\n 'RATING',\n 'TEXT',\n 'BUDGET_ALLOCATION',\n] as const;\n\nexport type GovConsultationQuestionType = (typeof CONSULTATION_QUESTION_TYPES)[number];\n\n/** Human label per question type, for the builder and the results view. */\nexport const QUESTION_TYPE_LABELS: Record<GovConsultationQuestionType, string> = {\n SINGLE_CHOICE: 'Single choice',\n MULTI_CHOICE: 'Multiple choice',\n RATING: 'Rating scale',\n TEXT: 'Free text',\n BUDGET_ALLOCATION: 'Budget allocation',\n};\n\n/**\n * Budget allocations must sum to the consultation's pot. Money is a float, so\n * the backend compares within this tolerance rather than for exact equality —\n * the form applies the identical rule so it never blocks a submission the API\n * would have accepted, or waves through one it would reject.\n */\nexport const BUDGET_SUM_TOLERANCE = 0.01;\n\n/** One normalized consultation question. */\nexport interface ConsultationQuestion {\n id: string;\n label: string;\n type: GovConsultationQuestionType;\n required: boolean;\n /** Declared options; always empty for RATING and TEXT. */\n options: string[];\n min: number | null;\n max: number | null;\n}\n\n/** One normalized `{ questionId, value }` answer. */\nexport interface ConsultationAnswer {\n questionId: string;\n value: unknown;\n}\n\n/**\n * Narrows an unknown JSON node to a plain object.\n *\n * The cast is safe and unavoidable: `typeof x === 'object'` plus the null and\n * array guards is exactly the runtime check that establishes the shape, and\n * TypeScript cannot narrow `unknown` to an index signature on its own.\n */\nfunction asRecord(value: unknown): Record<string, unknown> | null {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return null;\n }\n return value as Record<string, unknown>;\n}\n\n/** Narrows an unknown JSON node to an array. */\nfunction asArray(value: unknown): unknown[] | null {\n return Array.isArray(value) ? value : null;\n}\n\n/** A finite number parsed from a JSON number or numeric string, else null. */\nexport function asFiniteNumber(value: unknown): number | null {\n if (typeof value === 'number') {\n return Number.isFinite(value) ? value : null;\n }\n if (typeof value === 'string' && value.trim().length > 0) {\n const parsed = Number(value);\n return Number.isFinite(parsed) ? parsed : null;\n }\n return null;\n}\n\n/** A trimmed non-empty string, else null. */\nfunction asText(value: unknown): string | null {\n if (typeof value !== 'string') return null;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : null;\n}\n\n/** Reads the declared question schema off a consultation. */\nexport function parseConsultationQuestions(questions: GovJson): ConsultationQuestion[] {\n const list = asArray(questions);\n if (list === null) return [];\n\n const parsed: ConsultationQuestion[] = [];\n const seen = new Set<string>();\n\n for (const entry of list) {\n const record = asRecord(entry);\n if (record === null) continue;\n\n const id = asText(record.id);\n const label = asText(record.label);\n if (id === null || label === null || seen.has(id)) continue;\n\n const type = CONSULTATION_QUESTION_TYPES.find((candidate) => candidate === record.type);\n if (type === undefined) continue;\n\n const options: string[] = [];\n for (const option of asArray(record.options) ?? []) {\n const text = asText(option);\n if (text !== null && !options.includes(text)) options.push(text);\n }\n\n seen.add(id);\n parsed.push({\n id,\n label,\n type,\n required: record.required === true,\n options,\n min: asFiniteNumber(record.min),\n max: asFiniteNumber(record.max),\n });\n }\n\n return parsed;\n}\n\n/** Reads a submitted answer set back off a response. */\nexport function parseConsultationAnswers(answers: GovJson): ConsultationAnswer[] {\n const list = asArray(answers);\n if (list === null) return [];\n\n const parsed: ConsultationAnswer[] = [];\n for (const entry of list) {\n const record = asRecord(entry);\n if (record === null) continue;\n const questionId = asText(record.questionId);\n if (questionId === null) continue;\n parsed.push({ questionId, value: record.value });\n }\n return parsed;\n}\n\n/** `{ option: count }` map read off an aggregate, sorted by count then label. */\nexport function readCountMap(\n aggregate: GovJson,\n key: string\n): { name: string; value: number }[] {\n const record = asRecord(aggregate);\n if (record === null) return [];\n const counts = asRecord(record[key]);\n if (counts === null) return [];\n\n return Object.entries(counts)\n .map(([name, raw]) => ({ name, value: asFiniteNumber(raw) ?? 0 }))\n .sort((a, b) => b.value - a.value || a.name.localeCompare(b.name));\n}\n\n/** `{ bucket: count }` map read off an aggregate, sorted numerically by bucket. */\nexport function readNumericBuckets(\n aggregate: GovJson,\n key: string\n): { name: string; value: number }[] {\n const record = asRecord(aggregate);\n if (record === null) return [];\n const buckets = asRecord(record[key]);\n if (buckets === null) return [];\n\n return Object.entries(buckets)\n .map(([name, raw]) => ({ name, value: asFiniteNumber(raw) ?? 0 }))\n .sort((a, b) => (asFiniteNumber(a.name) ?? 0) - (asFiniteNumber(b.name) ?? 0));\n}\n\n/** A single numeric field read off an aggregate, or null when absent. */\nexport function readAggregateNumber(aggregate: GovJson, key: string): number | null {\n const record = asRecord(aggregate);\n if (record === null) return null;\n return asFiniteNumber(record[key]);\n}\n\n/** Renders a value the author supplied as one of the declared options. */\nexport function describeAnswerValue(question: ConsultationQuestion, value: unknown): string[] {\n switch (question.type) {\n case 'SINGLE_CHOICE':\n case 'TEXT': {\n const text = asText(value);\n return text === null ? [] : [text];\n }\n case 'RATING': {\n const rating = asFiniteNumber(value);\n return rating === null ? [] : [String(rating)];\n }\n case 'MULTI_CHOICE': {\n const list = asArray(value) ?? [];\n const chosen: string[] = [];\n for (const entry of list) {\n const text = asText(entry);\n if (text !== null) chosen.push(text);\n }\n return chosen;\n }\n case 'BUDGET_ALLOCATION': {\n const record = asRecord(value);\n if (record === null) return [];\n return Object.entries(record).map(([option, raw]) => `${option}: ${asFiniteNumber(raw) ?? 0}`);\n }\n default:\n return [];\n }\n}\n\n/** The allocation map for one budget question, read back off a stored answer. */\nexport function readAllocation(value: unknown): Record<string, number> {\n const record = asRecord(value);\n if (record === null) return {};\n const allocation: Record<string, number> = {};\n for (const [option, raw] of Object.entries(record)) {\n const amount = asFiniteNumber(raw);\n if (amount !== null) allocation[option] = amount;\n }\n return allocation;\n}\n"],"mappings":";AAuBA,IAAa,IAA8B;CACzC;CACA;CACA;CACA;CACA;AACF,GAKa,IAAoE;CAC/E,eAAe;CACf,cAAc;CACd,QAAQ;CACR,MAAM;CACN,mBAAmB;AACrB,GAQa,IAAuB;AA2BpC,SAAS,EAAS,GAAgD;CAIhE,OAHI,OAAO,KAAU,aAAY,KAAkB,MAAM,QAAQ,CAAK,IAC7D,OAEF;AACT;AAGA,SAAS,EAAQ,GAAkC;CACjD,OAAO,MAAM,QAAQ,CAAK,IAAI,IAAQ;AACxC;AAGA,SAAgB,EAAe,GAA+B;CAC5D,IAAI,OAAO,KAAU,UACnB,OAAO,OAAO,SAAS,CAAK,IAAI,IAAQ;CAE1C,IAAI,OAAO,KAAU,YAAY,EAAM,KAAK,EAAE,SAAS,GAAG;EACxD,IAAM,IAAS,OAAO,CAAK;EAC3B,OAAO,OAAO,SAAS,CAAM,IAAI,IAAS;CAC5C;CACA,OAAO;AACT;AAGA,SAAS,EAAO,GAA+B;CAC7C,IAAI,OAAO,KAAU,UAAU,OAAO;CACtC,IAAM,IAAU,EAAM,KAAK;CAC3B,OAAO,EAAQ,SAAS,IAAI,IAAU;AACxC;AAGA,SAAgB,EAA2B,GAA4C;CACrF,IAAM,IAAO,EA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K,qBAAqB;GACxB,IAAM,IAAS,EAAS,CAAK;GAE7B,OADI,MAAW,OAAa,CAAC,IACtB,OAAO,QAAQ,CAAM,EAAE,KAAK,CAAC,GAAQ,OAAS,GAAG,EAAO,IAAI,EAAe,CAAG,KAAK,GAAG;EAC/F;EACA,SACE,OAAO,CAAC;CACZ;AACF;AAGA,SAAgB,EAAe,GAAwC;CACrE,IAAM,IAAS,EAAS,CAAK;CAC7B,IAAI,MAAW,MAAM,OAAO,CAAC;CAC7B,IAAM,IAAqC,CAAC;CAC5C,KAAK,IAAM,CAAC,GAAQ,MAAQ,OAAO,QAAQ,CAAM,GAAG;EAClD,IAAM,IAAS,EAAe,CAAG;EACjC,AAAI,MAAW,SAAM,EAAW,KAAU;CAC5C;CACA,OAAO;AACT"}
|
|
1
|
+
{"version":3,"file":"consultationQuestions.js","names":[],"sources":["../../../../src/govcitizenhub/pages/intelligence/consultationQuestions.ts"],"sourcesContent":["/**\n * Consultation question-schema helpers.\n * @module govcitizenhub/pages/intelligence\n *\n * `GovConsultation.questions` and `GovConsultationResponse.answers` are JSON\n * scalars, so the shapes the backend validates\n * (`[{ id, label, type, options?, required, min?, max? }]` and\n * `[{ questionId, value }]`) have to be re-established on the client before\n * anything can be rendered.\n *\n * These readers are deliberately TOLERANT: a malformed entry is skipped rather\n * than thrown away wholesale or replaced with a plausible-looking default, so a\n * partially malformed schema still renders the questions that are valid and\n * never invents one that is not there.\n *\n * The rules mirror `participation.service.ts` exactly — including the\n * budget-allocation sum tolerance — so the form blocks locally on the same\n * grounds the API would reject on.\n */\n\nimport type { GovJson } from '../../types';\n\n/** The five question types the frozen contract declares. */\nexport const CONSULTATION_QUESTION_TYPES = [\n 'SINGLE_CHOICE',\n 'MULTI_CHOICE',\n 'RATING',\n 'TEXT',\n 'BUDGET_ALLOCATION',\n] as const;\n\nexport type GovConsultationQuestionType = (typeof CONSULTATION_QUESTION_TYPES)[number];\n\n/** Human label per question type, for the builder and the results view. */\nexport const QUESTION_TYPE_LABELS: Record<GovConsultationQuestionType, string> = {\n SINGLE_CHOICE: 'Single choice',\n MULTI_CHOICE: 'Multiple choice',\n RATING: 'Rating scale',\n TEXT: 'Free text',\n BUDGET_ALLOCATION: 'Budget allocation',\n};\n\n/**\n * Budget allocations must sum to the consultation's pot. Money is a float, so\n * the backend compares within this tolerance rather than for exact equality —\n * the form applies the identical rule so it never blocks a submission the API\n * would have accepted, or waves through one it would reject.\n */\nexport const BUDGET_SUM_TOLERANCE = 0.01;\n\n/** One normalized consultation question. */\nexport interface ConsultationQuestion {\n id: string;\n label: string;\n type: GovConsultationQuestionType;\n required: boolean;\n /** Declared options; always empty for RATING and TEXT. */\n options: string[];\n min: number | null;\n max: number | null;\n}\n\n/** One normalized `{ questionId, value }` answer. */\nexport interface ConsultationAnswer {\n questionId: string;\n value: unknown;\n}\n\n/**\n * Narrows an unknown JSON node to a plain object.\n *\n * The cast is safe and unavoidable: `typeof x === 'object'` plus the null and\n * array guards is exactly the runtime check that establishes the shape, and\n * TypeScript cannot narrow `unknown` to an index signature on its own.\n */\nfunction asRecord(value: unknown): Record<string, unknown> | null {\n if (typeof value !== 'object' || value === null || Array.isArray(value)) {\n return null;\n }\n return value as Record<string, unknown>;\n}\n\n/** Narrows an unknown JSON node to an array. */\nfunction asArray(value: unknown): unknown[] | null {\n return Array.isArray(value) ? value : null;\n}\n\n/** A finite number parsed from a JSON number or numeric string, else null. */\nexport function asFiniteNumber(value: unknown): number | null {\n if (typeof value === 'number') {\n return Number.isFinite(value) ? value : null;\n }\n if (typeof value === 'string' && value.trim().length > 0) {\n const parsed = Number(value);\n return Number.isFinite(parsed) ? parsed : null;\n }\n return null;\n}\n\n/** A trimmed non-empty string, else null. */\nfunction asText(value: unknown): string | null {\n if (typeof value !== 'string') return null;\n const trimmed = value.trim();\n return trimmed.length > 0 ? trimmed : null;\n}\n\n/** Reads the declared question schema off a consultation. */\nexport function parseConsultationQuestions(questions: GovJson): ConsultationQuestion[] {\n const list = asArray(questions);\n if (list === null) return [];\n\n const parsed: ConsultationQuestion[] = [];\n const seen = new Set<string>();\n\n for (const entry of list) {\n const record = asRecord(entry);\n if (record === null) continue;\n\n const id = asText(record.id);\n const label = asText(record.label);\n if (id === null || label === null || seen.has(id)) continue;\n\n const type = CONSULTATION_QUESTION_TYPES.find((candidate) => candidate === record.type);\n if (type === undefined) continue;\n\n const options: string[] = [];\n for (const option of asArray(record.options) ?? []) {\n const text = asText(option);\n if (text !== null && !options.includes(text)) options.push(text);\n }\n\n seen.add(id);\n parsed.push({\n id,\n label,\n type,\n required: record.required === true,\n options,\n min: asFiniteNumber(record.min),\n max: asFiniteNumber(record.max),\n });\n }\n\n return parsed;\n}\n\n/** Reads a submitted answer set back off a response. */\nexport function parseConsultationAnswers(answers: GovJson): ConsultationAnswer[] {\n const list = asArray(answers);\n if (list === null) return [];\n\n const parsed: ConsultationAnswer[] = [];\n for (const entry of list) {\n const record = asRecord(entry);\n if (record === null) continue;\n const questionId = asText(record.questionId);\n if (questionId === null) continue;\n parsed.push({ questionId, value: record.value });\n }\n return parsed;\n}\n\n/** `{ option: count }` map read off an aggregate, sorted by count then label. */\nexport function readCountMap(aggregate: GovJson, key: string): { name: string; value: number }[] {\n const record = asRecord(aggregate);\n if (record === null) return [];\n const counts = asRecord(record[key]);\n if (counts === null) return [];\n\n return Object.entries(counts)\n .map(([name, raw]) => ({ name, value: asFiniteNumber(raw) ?? 0 }))\n .sort((a, b) => b.value - a.value || a.name.localeCompare(b.name));\n}\n\n/** `{ bucket: count }` map read off an aggregate, sorted numerically by bucket. */\nexport function readNumericBuckets(\n aggregate: GovJson,\n key: string\n): { name: string; value: number }[] {\n const record = asRecord(aggregate);\n if (record === null) return [];\n const buckets = asRecord(record[key]);\n if (buckets === null) return [];\n\n return Object.entries(buckets)\n .map(([name, raw]) => ({ name, value: asFiniteNumber(raw) ?? 0 }))\n .sort((a, b) => (asFiniteNumber(a.name) ?? 0) - (asFiniteNumber(b.name) ?? 0));\n}\n\n/** A single numeric field read off an aggregate, or null when absent. */\nexport function readAggregateNumber(aggregate: GovJson, key: string): number | null {\n const record = asRecord(aggregate);\n if (record === null) return null;\n return asFiniteNumber(record[key]);\n}\n\n/** Renders a value the author supplied as one of the declared options. */\nexport function describeAnswerValue(question: ConsultationQuestion, value: unknown): string[] {\n switch (question.type) {\n case 'SINGLE_CHOICE':\n case 'TEXT': {\n const text = asText(value);\n return text === null ? [] : [text];\n }\n case 'RATING': {\n const rating = asFiniteNumber(value);\n return rating === null ? [] : [String(rating)];\n }\n case 'MULTI_CHOICE': {\n const list = asArray(value) ?? [];\n const chosen: string[] = [];\n for (const entry of list) {\n const text = asText(entry);\n if (text !== null) chosen.push(text);\n }\n return chosen;\n }\n case 'BUDGET_ALLOCATION': {\n const record = asRecord(value);\n if (record === null) return [];\n return Object.entries(record).map(\n ([option, raw]) => `${option}: ${asFiniteNumber(raw) ?? 0}`\n );\n }\n default:\n return [];\n }\n}\n\n/** The allocation map for one budget question, read back off a stored answer. */\nexport function readAllocation(value: unknown): Record<string, number> {\n const record = asRecord(value);\n if (record === null) return {};\n const allocation: Record<string, number> = {};\n for (const [option, raw] of Object.entries(record)) {\n const amount = asFiniteNumber(raw);\n if (amount !== null) allocation[option] = amount;\n }\n return allocation;\n}\n"],"mappings":";AAuBA,IAAa,IAA8B;CACzC;CACA;CACA;CACA;CACA;AACF,GAKa,IAAoE;CAC/E,eAAe;CACf,cAAc;CACd,QAAQ;CACR,MAAM;CACN,mBAAmB;AACrB,GAQa,IAAuB;AA2BpC,SAAS,EAAS,GAAgD;CAIhE,OAHI,OAAO,KAAU,aAAY,KAAkB,MAAM,QAAQ,CAAK,IAC7D,OAEF;AACT;AAGA,SAAS,EAAQ,GAAkC;CACjD,OAAO,MAAM,QAAQ,CAAK,IAAI,IAAQ;AACxC;AAGA,SAAgB,EAAe,GAA+B;CAC5D,IAAI,OAAO,KAAU,UACnB,OAAO,OAAO,SAAS,CAAK,IAAI,IAAQ;CAE1C,IAAI,OAAO,KAA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