@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":"ConsultationFormDialog.js","names":[],"sources":["../../../../src/govcitizenhub/pages/intelligence/ConsultationFormDialog.tsx"],"sourcesContent":["/**\n * ConsultationFormDialog — author a consultation and its question schema.\n * @module govcitizenhub/pages/intelligence\n *\n * Writes `govCreateConsultation` / `govUpdateConsultation`. The question builder\n * produces exactly the JSON shape the service validates —\n * `[{ id, label, type, options?, required, min?, max? }]` — and enforces the\n * same rules locally so an unanswerable questionnaire is caught before it is\n * sent: choice questions need options, rating questions need `min < max`, and a\n * BUDGET_ALLOCATION question needs the consultation to carry a positive pot and\n * a currency (you cannot ask citizens to split money that does not exist).\n *\n * Question ids of already-published questions are PRESERVED on edit: they are\n * the key existing responses are recorded against.\n *\n * Lifecycle note: the parent mounts this component only while the dialog is\n * open, so every field seeds itself from props on mount — there is no state\n * syncing effect to fall out of step with the record being edited.\n */\n\nimport { useRef, useState, type ReactElement } from 'react';\nimport { AlertTriangle, FileText, Loader2, Plus, Trash2, Upload } from 'lucide-react';\nimport {\n Button,\n Input,\n Label,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n Switch,\n Textarea,\n} from '@burdenoff/fe-libs/ui';\n\nimport { TagInput } from '../../components/TagInput';\nimport {\n CONSULTATION_QUESTION_TYPES,\n QUESTION_TYPE_LABELS,\n parseConsultationQuestions,\n type GovConsultationQuestionType,\n} from './consultationQuestions';\nimport { useGovCreateConsultation, useGovUpdateConsultation } from '../../hooks';\nimport { uploadFileToFiles } from '../../hooks/useFiles';\nimport { describeError, notify } from '../../lib/toast';\nimport { formatEnumLabel, slugify } from '../../utils/formatters';\nimport type { GovConsultation, GovConsultationType } from '../../types';\n\n/** wspace-files-svc folder that holds consultation background documents. */\nconst CONSULTATION_DOC_FOLDER = '/GovCitizenHub/Intelligence/Consultations';\n\nconst CONSULTATION_TYPES: readonly GovConsultationType[] = [\n 'SURVEY',\n 'POLL',\n 'PARTICIPATORY_BUDGET',\n 'PUBLIC_HEARING',\n 'FEEDBACK',\n];\n\n/** Question types whose `options` list is meaningful. */\nconst OPTION_TYPES = new Set<GovConsultationQuestionType>([\n 'SINGLE_CHOICE',\n 'MULTI_CHOICE',\n 'BUDGET_ALLOCATION',\n]);\n\ninterface BuilderQuestion {\n /** Local React key. */\n key: string;\n /** The id already published for this question, preserved on edit. */\n persistedId: string | null;\n label: string;\n type: GovConsultationQuestionType;\n required: boolean;\n options: string[];\n min: string;\n max: string;\n}\n\n/** ISO timestamp → the `YYYY-MM-DDTHH:mm` an `<input type=\"datetime-local\">` wants. */\nfunction toLocalDateTimeInput(value: string | null | undefined): string {\n if (!value) return '';\n const parsed = new Date(value);\n if (Number.isNaN(parsed.getTime())) return '';\n const pad = (part: number): string => String(part).padStart(2, '0');\n return `${parsed.getFullYear()}-${pad(parsed.getMonth() + 1)}-${pad(parsed.getDate())}T${pad(\n parsed.getHours()\n )}:${pad(parsed.getMinutes())}`;\n}\n\n/** Seeds the builder rows from a consultation's published question schema. */\nfunction seedQuestions(consultation: GovConsultation | null | undefined): BuilderQuestion[] {\n if (!consultation) return [];\n return parseConsultationQuestions(consultation.questions).map((question, index) => ({\n key: `seed-${index}-${question.id}`,\n persistedId: question.id,\n label: question.label,\n type: question.type,\n required: question.required,\n options: question.options,\n min: question.min === null ? '' : String(question.min),\n max: question.max === null ? '' : String(question.max),\n }));\n}\n\nexport interface ConsultationFormDialogProps {\n /** Owning jurisdiction — required by `GovCreateConsultationInput`. */\n jurisdictionId: string;\n /** The consultation being edited. Omit for a create flow. */\n consultation?: GovConsultation | null;\n onClose: () => void;\n onSaved?: (consultation: GovConsultation) => void;\n}\n\nexport function ConsultationFormDialog({\n jurisdictionId,\n consultation,\n onClose,\n onSaved,\n}: ConsultationFormDialogProps): ReactElement {\n const isEdit = Boolean(consultation);\n const createConsultation = useGovCreateConsultation();\n const updateConsultation = useGovUpdateConsultation();\n const nextKey = useRef(0);\n\n const [title, setTitle] = useState(consultation?.title ?? '');\n const [description, setDescription] = useState(consultation?.description ?? '');\n const [consultationType, setConsultationType] = useState<GovConsultationType>(\n consultation?.consultationType ?? 'SURVEY'\n );\n const [opensAt, setOpensAt] = useState(toLocalDateTimeInput(consultation?.opensAt));\n const [closesAt, setClosesAt] = useState(toLocalDateTimeInput(consultation?.closesAt));\n const [allowAnonymous, setAllowAnonymous] = useState(consultation?.allowAnonymous ?? true);\n const [budgetAmount, setBudgetAmount] = useState(\n consultation?.budgetAmount != null ? String(consultation.budgetAmount) : ''\n );\n const [currencyCode, setCurrencyCode] = useState(consultation?.currencyCode ?? '');\n const [documentFileId, setDocumentFileId] = useState<string | null>(\n consultation?.documentFileId ?? null\n );\n const [tags, setTags] = useState<string[]>(consultation?.tags ?? []);\n const [questions, setQuestions] = useState<BuilderQuestion[]>(() => seedQuestions(consultation));\n\n const [uploading, setUploading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const busy = createConsultation.isPending || updateConsultation.isPending || uploading;\n const hasBudgetQuestion = questions.some((question) => question.type === 'BUDGET_ALLOCATION');\n\n const addQuestion = (): void => {\n nextKey.current += 1;\n setQuestions((current) => [\n ...current,\n {\n key: `new-${nextKey.current}`,\n persistedId: null,\n label: '',\n type: 'SINGLE_CHOICE',\n required: false,\n options: [],\n min: '1',\n max: '5',\n },\n ]);\n };\n\n const patchQuestion = (key: string, patch: Partial<BuilderQuestion>): void => {\n setQuestions((current) =>\n current.map((question) => (question.key === key ? { ...question, ...patch } : question))\n );\n };\n\n const removeQuestion = (key: string): void => {\n setQuestions((current) => current.filter((question) => question.key !== key));\n };\n\n const moveQuestion = (key: string, delta: number): void => {\n setQuestions((current) => {\n const index = current.findIndex((question) => question.key === key);\n const target = index + delta;\n if (index < 0 || target < 0 || target >= current.length) return current;\n const next = [...current];\n const [moved] = next.splice(index, 1);\n next.splice(target, 0, moved);\n return next;\n });\n };\n\n const uploadDocument = async (file: File): Promise<void> => {\n setUploading(true);\n try {\n const uploaded = await uploadFileToFiles(file, CONSULTATION_DOC_FOLDER);\n setDocumentFileId(uploaded.id);\n notify.success('Document attached', uploaded.name);\n } catch (err) {\n notify.error('Upload failed', describeError(err));\n } finally {\n setUploading(false);\n }\n };\n\n /**\n * Builds the persisted question schema, applying the same rules the service\n * validates with. Returns the payload, or the first problem to show inline.\n */\n const buildQuestionSchema = ():\n | { ok: true; payload: Record<string, unknown>[] }\n | { ok: false; message: string } => {\n if (questions.length === 0) {\n return { ok: false, message: 'Add at least one question.' };\n }\n\n const used = new Set<string>();\n const payload: Record<string, unknown>[] = [];\n\n for (const [index, question] of questions.entries()) {\n const label = question.label.trim();\n if (label.length === 0) {\n return { ok: false, message: `Question ${index + 1} needs a label.` };\n }\n\n let id = question.persistedId ?? slugify(label);\n if (id.length === 0) id = `question-${index + 1}`;\n if (used.has(id)) {\n let suffix = 2;\n while (used.has(`${id}-${suffix}`)) suffix += 1;\n id = `${id}-${suffix}`;\n }\n used.add(id);\n\n const entry: Record<string, unknown> = {\n id,\n label,\n type: question.type,\n required: question.required,\n };\n\n if (OPTION_TYPES.has(question.type)) {\n const options = question.options.map((option) => option.trim()).filter(Boolean);\n if (question.type !== 'BUDGET_ALLOCATION' && options.length === 0) {\n return { ok: false, message: `“${label}” needs at least one option.` };\n }\n if (question.type === 'BUDGET_ALLOCATION' && options.length === 0) {\n return {\n ok: false,\n message: `“${label}” needs the spending options citizens can allocate to.`,\n };\n }\n entry.options = options;\n }\n\n if (question.type === 'RATING') {\n const min = Number(question.min);\n const max = Number(question.max);\n if (!Number.isFinite(min) || !Number.isFinite(max)) {\n return { ok: false, message: `“${label}” needs a numeric minimum and maximum.` };\n }\n if (min >= max) {\n return { ok: false, message: `“${label}” needs a minimum lower than its maximum.` };\n }\n entry.min = min;\n entry.max = max;\n }\n\n payload.push(entry);\n }\n\n if (hasBudgetQuestion) {\n const pot = Number(budgetAmount);\n if (!Number.isFinite(pot) || pot <= 0) {\n return {\n ok: false,\n message: 'A budget-allocation question needs a positive budget pot on the consultation.',\n };\n }\n if (!/^[A-Za-z]{3}$/.test(currencyCode.trim())) {\n return {\n ok: false,\n message: 'A budget-allocation question needs a 3-letter currency code.',\n };\n }\n }\n\n return { ok: true, payload };\n };\n\n const submit = async (): Promise<void> => {\n if (!title.trim()) {\n setError('A title is required.');\n return;\n }\n\n const schema = buildQuestionSchema();\n if (!schema.ok) {\n setError(schema.message);\n return;\n }\n\n const opensAtIso = opensAt ? new Date(opensAt).toISOString() : undefined;\n const closesAtIso = closesAt ? new Date(closesAt).toISOString() : undefined;\n if (opensAtIso && closesAtIso && new Date(closesAtIso) <= new Date(opensAtIso)) {\n setError('The closing time must be after the opening time.');\n return;\n }\n\n const pot = budgetAmount.trim().length > 0 ? Number(budgetAmount) : undefined;\n if (pot !== undefined && (!Number.isFinite(pot) || pot < 0)) {\n setError('The budget pot must be a non-negative number.');\n return;\n }\n const currency = currencyCode.trim().length > 0 ? currencyCode.trim().toUpperCase() : undefined;\n\n setError(null);\n try {\n if (isEdit && consultation) {\n const updated = await updateConsultation.mutateAsync({\n id: consultation.id,\n input: {\n title: title.trim(),\n description: description.trim(),\n consultationType,\n opensAt: opensAtIso,\n closesAt: closesAtIso,\n questions: schema.payload,\n allowAnonymous,\n budgetAmount: pot,\n currencyCode: currency,\n documentFileId: documentFileId ?? '',\n tags,\n },\n });\n notify.success('Consultation updated', updated.title);\n onSaved?.(updated);\n } else {\n const created = await createConsultation.mutateAsync({\n jurisdictionId,\n title: title.trim(),\n description: description.trim().length > 0 ? description.trim() : undefined,\n consultationType,\n opensAt: opensAtIso,\n closesAt: closesAtIso,\n questions: schema.payload,\n allowAnonymous,\n budgetAmount: pot,\n currencyCode: currency,\n documentFileId,\n tags: tags.length > 0 ? tags : undefined,\n });\n notify.success('Consultation created', `${created.title} is in draft.`);\n onSaved?.(created);\n }\n onClose();\n } catch (err) {\n setError(describeError(err));\n }\n };\n\n return (\n <ResponsiveDialog\n open\n onOpenChange={(next) => {\n if (!next && !busy) onClose();\n }}\n >\n <ResponsiveDialogContent className=\"max-h-[90vh] overflow-y-auto sm:max-w-3xl\">\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>\n {isEdit ? 'Edit consultation' : 'Create a consultation'}\n </ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n Ask this jurisdiction’s residents a question. New consultations start in draft —\n open them when the questionnaire is final.\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n\n <div className=\"flex flex-col gap-4 py-2\">\n <div className=\"grid gap-4 sm:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"consultation-title\">Title</Label>\n <Input\n id=\"consultation-title\"\n value={title}\n onChange={(event) => setTitle(event.target.value)}\n placeholder=\"What are you asking about?\"\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label>Type</Label>\n <Select\n value={consultationType}\n onValueChange={(value) => setConsultationType(value as GovConsultationType)}\n >\n <SelectTrigger aria-label=\"Consultation type\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {CONSULTATION_TYPES.map((entry) => (\n <SelectItem key={entry} value={entry}>\n {formatEnumLabel(entry)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n </div>\n\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"consultation-description\">Description</Label>\n <Textarea\n id=\"consultation-description\"\n rows={3}\n value={description}\n onChange={(event) => setDescription(event.target.value)}\n placeholder=\"Why this consultation is being held and what happens with the answers.\"\n />\n </div>\n\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"consultation-opens\">Opens at</Label>\n <Input\n id=\"consultation-opens\"\n type=\"datetime-local\"\n value={opensAt}\n onChange={(event) => setOpensAt(event.target.value)}\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"consultation-closes\">Closes at</Label>\n <Input\n id=\"consultation-closes\"\n type=\"datetime-local\"\n value={closesAt}\n onChange={(event) => setClosesAt(event.target.value)}\n />\n </div>\n </div>\n\n <div className=\"flex items-start gap-3 rounded-xl border border-border-seam bg-bg-sunken/40 p-4\">\n <Switch\n id=\"consultation-allow-anonymous\"\n checked={allowAnonymous}\n onCheckedChange={(next) => setAllowAnonymous(next === true)}\n />\n <div className=\"min-w-0\">\n <Label htmlFor=\"consultation-allow-anonymous\" className=\"cursor-pointer\">\n Accept anonymous responses\n </Label>\n <p className=\"mt-1 text-xs text-text-muted\">\n Anonymous responses store no respondent id, so they cannot be de-duplicated or\n retrieved by their author afterwards.\n </p>\n </div>\n </div>\n\n <div className=\"grid gap-4 sm:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"consultation-budget\">\n Budget pot {hasBudgetQuestion ? '(required)' : '(optional)'}\n </Label>\n <Input\n id=\"consultation-budget\"\n type=\"number\"\n min=\"0\"\n step=\"any\"\n value={budgetAmount}\n onChange={(event) => setBudgetAmount(event.target.value)}\n placeholder=\"Total amount citizens allocate\"\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"consultation-currency\">Currency</Label>\n <Input\n id=\"consultation-currency\"\n value={currencyCode}\n maxLength={3}\n onChange={(event) => setCurrencyCode(event.target.value.toUpperCase())}\n placeholder=\"ISO 4217\"\n />\n </div>\n </div>\n\n <div className=\"grid gap-1.5\">\n <Label>Background document</Label>\n <div className=\"flex flex-wrap items-center gap-2\">\n <label className=\"inline-flex cursor-pointer items-center gap-1.5 rounded-button border border-border-seam bg-bg-surface px-3 py-1.5 text-sm font-medium text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary\">\n {uploading ? (\n <Loader2 className=\"size-4 animate-spin\" aria-hidden=\"true\" />\n ) : (\n <Upload className=\"size-4\" aria-hidden=\"true\" />\n )}\n {uploading ? 'Uploading…' : documentFileId ? 'Replace document' : 'Attach document'}\n <input\n type=\"file\"\n className=\"sr-only\"\n disabled={busy}\n onChange={(event) => {\n const file = event.target.files?.[0];\n event.target.value = '';\n if (file) void uploadDocument(file);\n }}\n />\n </label>\n {documentFileId && (\n <>\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 <FileText className=\"size-3.5\" aria-hidden=\"true\" /> Document attached\n </span>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n disabled={busy}\n onClick={() => setDocumentFileId(null)}\n >\n Remove\n </Button>\n </>\n )}\n </div>\n </div>\n\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"consultation-tags\">Tags</Label>\n <TagInput\n id=\"consultation-tags\"\n value={tags}\n onChange={setTags}\n placeholder=\"Add a tag…\"\n />\n </div>\n\n {/* Question builder */}\n <div className=\"border-t border-border-seam pt-4\">\n <div className=\"mb-3 flex flex-wrap items-center justify-between gap-2\">\n <div>\n <h3 className=\"text-sm font-semibold text-text-primary\">Questions</h3>\n <p className=\"text-xs text-text-muted\">\n These are rendered exactly as written on the citizen participation form.\n </p>\n </div>\n <Button type=\"button\" variant=\"outline\" size=\"sm\" onClick={addQuestion} disabled={busy}>\n <Plus className=\"mr-1.5 size-4\" aria-hidden=\"true\" /> Add question\n </Button>\n </div>\n\n {isEdit && consultation && consultation.responseCount > 0 && (\n <p className=\"mb-3 flex items-start gap-1.5 rounded-lg bg-status-warning-bg-subtle p-3 text-xs text-status-warning-text\">\n <AlertTriangle className=\"mt-0.5 size-3.5 shrink-0\" aria-hidden=\"true\" />\n This consultation already has responses. Changing or removing a question means the\n answers already recorded against it can no longer be aggregated.\n </p>\n )}\n\n {questions.length === 0 ? (\n <p className=\"rounded-xl border border-dashed border-border-seam p-4 text-sm text-text-muted\">\n No questions yet. Add at least one before the consultation can be opened.\n </p>\n ) : (\n <ul className=\"flex flex-col gap-3\">\n {questions.map((question, index) => (\n <li\n key={question.key}\n className=\"rounded-xl border border-border-seam bg-bg-surface p-4\"\n >\n <div className=\"mb-3 flex items-center justify-between gap-2\">\n <span className=\"text-xs font-semibold uppercase tracking-wide text-text-muted\">\n Question {index + 1}\n {question.persistedId && ' · published'}\n </span>\n <div className=\"flex items-center gap-1\">\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n aria-label=\"Move question up\"\n disabled={index === 0 || busy}\n onClick={() => moveQuestion(question.key, -1)}\n >\n ↑\n </Button>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n aria-label=\"Move question down\"\n disabled={index === questions.length - 1 || busy}\n onClick={() => moveQuestion(question.key, 1)}\n >\n ↓\n </Button>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n aria-label=\"Remove question\"\n disabled={busy}\n onClick={() => removeQuestion(question.key)}\n >\n <Trash2 className=\"size-4\" aria-hidden=\"true\" />\n </Button>\n </div>\n </div>\n\n <div className=\"grid gap-3 sm:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor={`${question.key}-label`}>Label</Label>\n <Input\n id={`${question.key}-label`}\n value={question.label}\n onChange={(event) =>\n patchQuestion(question.key, { label: event.target.value })\n }\n placeholder=\"What do you want to ask?\"\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label>Type</Label>\n <Select\n value={question.type}\n onValueChange={(value) =>\n patchQuestion(question.key, {\n type: value as GovConsultationQuestionType,\n })\n }\n >\n <SelectTrigger aria-label=\"Question type\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {CONSULTATION_QUESTION_TYPES.map((entry) => (\n <SelectItem key={entry} value={entry}>\n {QUESTION_TYPE_LABELS[entry]}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n </div>\n\n {OPTION_TYPES.has(question.type) && (\n <div className=\"mt-3 grid gap-1.5\">\n <Label htmlFor={`${question.key}-options`}>\n {question.type === 'BUDGET_ALLOCATION' ? 'Spending options' : 'Options'}\n </Label>\n <TagInput\n id={`${question.key}-options`}\n value={question.options}\n max={24}\n onChange={(options) => patchQuestion(question.key, { options })}\n placeholder=\"Add an option…\"\n />\n </div>\n )}\n\n {question.type === 'RATING' && (\n <div className=\"mt-3 grid gap-3 sm:grid-cols-2\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor={`${question.key}-min`}>Lowest value</Label>\n <Input\n id={`${question.key}-min`}\n type=\"number\"\n value={question.min}\n onChange={(event) =>\n patchQuestion(question.key, { min: event.target.value })\n }\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor={`${question.key}-max`}>Highest value</Label>\n <Input\n id={`${question.key}-max`}\n type=\"number\"\n value={question.max}\n onChange={(event) =>\n patchQuestion(question.key, { max: event.target.value })\n }\n />\n </div>\n </div>\n )}\n\n <div className=\"mt-3 flex items-center gap-2.5\">\n <Switch\n id={`${question.key}-required`}\n checked={question.required}\n onCheckedChange={(next) =>\n patchQuestion(question.key, { required: next === true })\n }\n />\n <Label htmlFor={`${question.key}-required`} className=\"cursor-pointer\">\n Required\n </Label>\n </div>\n </li>\n ))}\n </ul>\n )}\n </div>\n\n {error && (\n <p className=\"text-sm text-status-error-text\" role=\"alert\">\n {error}\n </p>\n )}\n </div>\n\n <ResponsiveDialogFooter>\n <Button variant=\"outline\" onClick={onClose} disabled={busy}>\n Cancel\n </Button>\n <Button\n onClick={() => {\n void submit();\n }}\n disabled={busy}\n >\n {isEdit ? 'Save changes' : 'Create consultation'}\n </Button>\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAuDA,IAAM,KAA0B,6CAE1B,KAAqD;CACzD;CACA;CACA;CACA;CACA;AACF,GAGM,IAAe,IAAI,IAAiC;CACxD;CACA;CACA;AACF,CAAC;AAgBD,SAAS,EAAqB,GAA0C;CACtE,IAAI,CAAC,GAAO,OAAO;CACnB,IAAM,IAAS,IAAI,KAAK,CAAK;CAC7B,IAAI,OAAO,MAAM,EAAO,QAAQ,CAAC,GAAG,OAAO;CAC3C,IAAM,KAAO,MAAyB,OAAO,CAAI,EAAE,SAAS,GAAG,GAAG;CAClE,OAAO,GAAG,EAAO,YAAY,EAAE,GAAG,EAAI,EAAO,SAAS,IAAI,CAAC,EAAE,GAAG,EAAI,EAAO,QAAQ,CAAC,EAAE,GAAG,EACvF,EAAO,SAAS,CAClB,EAAE,GAAG,EAAI,EAAO,WAAW,CAAC;AAC9B;AAGA,SAAS,GAAc,GAAqE;CAE1F,OADK,IACE,EAA2B,EAAa,SAAS,EAAE,KAAK,G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
|
|
1
|
+
{"version":3,"file":"ConsultationFormDialog.js","names":[],"sources":["../../../../src/govcitizenhub/pages/intelligence/ConsultationFormDialog.tsx"],"sourcesContent":["/**\n * ConsultationFormDialog — author a consultation and its question schema.\n * @module govcitizenhub/pages/intelligence\n *\n * Writes `govCreateConsultation` / `govUpdateConsultation`. The question builder\n * produces exactly the JSON shape the service validates —\n * `[{ id, label, type, options?, required, min?, max? }]` — and enforces the\n * same rules locally so an unanswerable questionnaire is caught before it is\n * sent: choice questions need options, rating questions need `min < max`, and a\n * BUDGET_ALLOCATION question needs the consultation to carry a positive pot and\n * a currency (you cannot ask citizens to split money that does not exist).\n *\n * Question ids of already-published questions are PRESERVED on edit: they are\n * the key existing responses are recorded against.\n *\n * Lifecycle note: the parent mounts this component only while the dialog is\n * open, so every field seeds itself from props on mount — there is no state\n * syncing effect to fall out of step with the record being edited.\n */\n\nimport { useRef, useState, type ReactElement } from 'react';\nimport { AlertTriangle, FileText, Loader2, Plus, Trash2, Upload } from 'lucide-react';\nimport {\n Button,\n Input,\n Label,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n Switch,\n Textarea,\n} from '@burdenoff/fe-libs/ui';\n\nimport { TagInput } from '../../components/TagInput';\nimport {\n CONSULTATION_QUESTION_TYPES,\n QUESTION_TYPE_LABELS,\n parseConsultationQuestions,\n type GovConsultationQuestionType,\n} from './consultationQuestions';\nimport { useGovCreateConsultation, useGovUpdateConsultation } from '../../hooks';\nimport { uploadFileToFiles } from '../../hooks/useFiles';\nimport { describeError, notify } from '../../lib/toast';\nimport { formatEnumLabel, slugify } from '../../utils/formatters';\nimport type { GovConsultation, GovConsultationType } from '../../types';\n\n/** wspace-files-svc folder that holds consultation background documents. */\nconst CONSULTATION_DOC_FOLDER = '/GovCitizenHub/Intelligence/Consultations';\n\nconst CONSULTATION_TYPES: readonly GovConsultationType[] = [\n 'SURVEY',\n 'POLL',\n 'PARTICIPATORY_BUDGET',\n 'PUBLIC_HEARING',\n 'FEEDBACK',\n];\n\n/** Question types whose `options` list is meaningful. */\nconst OPTION_TYPES = new Set<GovConsultationQuestionType>([\n 'SINGLE_CHOICE',\n 'MULTI_CHOICE',\n 'BUDGET_ALLOCATION',\n]);\n\ninterface BuilderQuestion {\n /** Local React key. */\n key: string;\n /** The id already published for this question, preserved on edit. */\n persistedId: string | null;\n label: string;\n type: GovConsultationQuestionType;\n required: boolean;\n options: string[];\n min: string;\n max: string;\n}\n\n/** ISO timestamp → the `YYYY-MM-DDTHH:mm` an `<input type=\"datetime-local\">` wants. */\nfunction toLocalDateTimeInput(value: string | null | undefined): string {\n if (!value) return '';\n const parsed = new Date(value);\n if (Number.isNaN(parsed.getTime())) return '';\n const pad = (part: number): string => String(part).padStart(2, '0');\n return `${parsed.getFullYear()}-${pad(parsed.getMonth() + 1)}-${pad(parsed.getDate())}T${pad(\n parsed.getHours()\n )}:${pad(parsed.getMinutes())}`;\n}\n\n/** Seeds the builder rows from a consultation's published question schema. */\nfunction seedQuestions(consultation: GovConsultation | null | undefined): BuilderQuestion[] {\n if (!consultation) return [];\n return parseConsultationQuestions(consultation.questions).map((question, index) => ({\n key: `seed-${index}-${question.id}`,\n persistedId: question.id,\n label: question.label,\n type: question.type,\n required: question.required,\n options: question.options,\n min: question.min === null ? '' : String(question.min),\n max: question.max === null ? '' : String(question.max),\n }));\n}\n\nexport interface ConsultationFormDialogProps {\n /** Owning jurisdiction — required by `GovCreateConsultationInput`. */\n jurisdictionId: string;\n /** The consultation being edited. Omit for a create flow. */\n consultation?: GovConsultation | null;\n onClose: () => void;\n onSaved?: (consultation: GovConsultation) => void;\n}\n\nexport function ConsultationFormDialog({\n jurisdictionId,\n consultation,\n onClose,\n onSaved,\n}: ConsultationFormDialogProps): ReactElement {\n const isEdit = Boolean(consultation);\n const createConsultation = useGovCreateConsultation();\n const updateConsultation = useGovUpdateConsultation();\n const nextKey = useRef(0);\n\n const [title, setTitle] = useState(consultation?.title ?? '');\n const [description, setDescription] = useState(consultation?.description ?? '');\n const [consultationType, setConsultationType] = useState<GovConsultationType>(\n consultation?.consultationType ?? 'SURVEY'\n );\n const [opensAt, setOpensAt] = useState(toLocalDateTimeInput(consultation?.opensAt));\n const [closesAt, setClosesAt] = useState(toLocalDateTimeInput(consultation?.closesAt));\n const [allowAnonymous, setAllowAnonymous] = useState(consultation?.allowAnonymous ?? true);\n const [budgetAmount, setBudgetAmount] = useState(\n consultation?.budgetAmount != null ? String(consultation.budgetAmount) : ''\n );\n const [currencyCode, setCurrencyCode] = useState(consultation?.currencyCode ?? '');\n const [documentFileId, setDocumentFileId] = useState<string | null>(\n consultation?.documentFileId ?? null\n );\n const [tags, setTags] = useState<string[]>(consultation?.tags ?? []);\n const [questions, setQuestions] = useState<BuilderQuestion[]>(() => seedQuestions(consultation));\n\n const [uploading, setUploading] = useState(false);\n const [error, setError] = useState<string | null>(null);\n\n const busy = createConsultation.isPending || updateConsultation.isPending || uploading;\n const hasBudgetQuestion = questions.some((question) => question.type === 'BUDGET_ALLOCATION');\n\n const addQuestion = (): void => {\n nextKey.current += 1;\n setQuestions((current) => [\n ...current,\n {\n key: `new-${nextKey.current}`,\n persistedId: null,\n label: '',\n type: 'SINGLE_CHOICE',\n required: false,\n options: [],\n min: '1',\n max: '5',\n },\n ]);\n };\n\n const patchQuestion = (key: string, patch: Partial<BuilderQuestion>): void => {\n setQuestions((current) =>\n current.map((question) => (question.key === key ? { ...question, ...patch } : question))\n );\n };\n\n const removeQuestion = (key: string): void => {\n setQuestions((current) => current.filter((question) => question.key !== key));\n };\n\n const moveQuestion = (key: string, delta: number): void => {\n setQuestions((current) => {\n const index = current.findIndex((question) => question.key === key);\n const target = index + delta;\n if (index < 0 || target < 0 || target >= current.length) return current;\n const next = [...current];\n const [moved] = next.splice(index, 1);\n next.splice(target, 0, moved);\n return next;\n });\n };\n\n const uploadDocument = async (file: File): Promise<void> => {\n setUploading(true);\n try {\n const uploaded = await uploadFileToFiles(file, CONSULTATION_DOC_FOLDER);\n setDocumentFileId(uploaded.id);\n notify.success('Document attached', uploaded.name);\n } catch (err) {\n notify.error('Upload failed', describeError(err));\n } finally {\n setUploading(false);\n }\n };\n\n /**\n * Builds the persisted question schema, applying the same rules the service\n * validates with. Returns the payload, or the first problem to show inline.\n */\n const buildQuestionSchema = ():\n { ok: true; payload: Record<string, unknown>[] } | { ok: false; message: string } => {\n if (questions.length === 0) {\n return { ok: false, message: 'Add at least one question.' };\n }\n\n const used = new Set<string>();\n const payload: Record<string, unknown>[] = [];\n\n for (const [index, question] of questions.entries()) {\n const label = question.label.trim();\n if (label.length === 0) {\n return { ok: false, message: `Question ${index + 1} needs a label.` };\n }\n\n let id = question.persistedId ?? slugify(label);\n if (id.length === 0) id = `question-${index + 1}`;\n if (used.has(id)) {\n let suffix = 2;\n while (used.has(`${id}-${suffix}`)) suffix += 1;\n id = `${id}-${suffix}`;\n }\n used.add(id);\n\n const entry: Record<string, unknown> = {\n id,\n label,\n type: question.type,\n required: question.required,\n };\n\n if (OPTION_TYPES.has(question.type)) {\n const options = question.options.map((option) => option.trim()).filter(Boolean);\n if (question.type !== 'BUDGET_ALLOCATION' && options.length === 0) {\n return { ok: false, message: `“${label}” needs at least one option.` };\n }\n if (question.type === 'BUDGET_ALLOCATION' && options.length === 0) {\n return {\n ok: false,\n message: `“${label}” needs the spending options citizens can allocate to.`,\n };\n }\n entry.options = options;\n }\n\n if (question.type === 'RATING') {\n const min = Number(question.min);\n const max = Number(question.max);\n if (!Number.isFinite(min) || !Number.isFinite(max)) {\n return { ok: false, message: `“${label}” needs a numeric minimum and maximum.` };\n }\n if (min >= max) {\n return { ok: false, message: `“${label}” needs a minimum lower than its maximum.` };\n }\n entry.min = min;\n entry.max = max;\n }\n\n payload.push(entry);\n }\n\n if (hasBudgetQuestion) {\n const pot = Number(budgetAmount);\n if (!Number.isFinite(pot) || pot <= 0) {\n return {\n ok: false,\n message: 'A budget-allocation question needs a positive budget pot on the consultation.',\n };\n }\n if (!/^[A-Za-z]{3}$/.test(currencyCode.trim())) {\n return {\n ok: false,\n message: 'A budget-allocation question needs a 3-letter currency code.',\n };\n }\n }\n\n return { ok: true, payload };\n };\n\n const submit = async (): Promise<void> => {\n if (!title.trim()) {\n setError('A title is required.');\n return;\n }\n\n const schema = buildQuestionSchema();\n if (!schema.ok) {\n setError(schema.message);\n return;\n }\n\n const opensAtIso = opensAt ? new Date(opensAt).toISOString() : undefined;\n const closesAtIso = closesAt ? new Date(closesAt).toISOString() : undefined;\n if (opensAtIso && closesAtIso && new Date(closesAtIso) <= new Date(opensAtIso)) {\n setError('The closing time must be after the opening time.');\n return;\n }\n\n const pot = budgetAmount.trim().length > 0 ? Number(budgetAmount) : undefined;\n if (pot !== undefined && (!Number.isFinite(pot) || pot < 0)) {\n setError('The budget pot must be a non-negative number.');\n return;\n }\n const currency = currencyCode.trim().length > 0 ? currencyCode.trim().toUpperCase() : undefined;\n\n setError(null);\n try {\n if (isEdit && consultation) {\n const updated = await updateConsultation.mutateAsync({\n id: consultation.id,\n input: {\n title: title.trim(),\n description: description.trim(),\n consultationType,\n opensAt: opensAtIso,\n closesAt: closesAtIso,\n questions: schema.payload,\n allowAnonymous,\n budgetAmount: pot,\n currencyCode: currency,\n documentFileId: documentFileId ?? '',\n tags,\n },\n });\n notify.success('Consultation updated', updated.title);\n onSaved?.(updated);\n } else {\n const created = await createConsultation.mutateAsync({\n jurisdictionId,\n title: title.trim(),\n description: description.trim().length > 0 ? description.trim() : undefined,\n consultationType,\n opensAt: opensAtIso,\n closesAt: closesAtIso,\n questions: schema.payload,\n allowAnonymous,\n budgetAmount: pot,\n currencyCode: currency,\n documentFileId,\n tags: tags.length > 0 ? tags : undefined,\n });\n notify.success('Consultation created', `${created.title} is in draft.`);\n onSaved?.(created);\n }\n onClose();\n } catch (err) {\n setError(describeError(err));\n }\n };\n\n return (\n <ResponsiveDialog\n open\n onOpenChange={(next) => {\n if (!next && !busy) onClose();\n }}\n >\n <ResponsiveDialogContent className=\"max-h-[90vh] overflow-y-auto sm:max-w-3xl\">\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>\n {isEdit ? 'Edit consultation' : 'Create a consultation'}\n </ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n Ask this jurisdiction’s residents a question. New consultations start in draft —\n open them when the questionnaire is final.\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n\n <div className=\"flex flex-col gap-4 py-2\">\n <div className=\"grid gap-4 sm:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"consultation-title\">Title</Label>\n <Input\n id=\"consultation-title\"\n value={title}\n onChange={(event) => setTitle(event.target.value)}\n placeholder=\"What are you asking about?\"\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label>Type</Label>\n <Select\n value={consultationType}\n onValueChange={(value) => setConsultationType(value as GovConsultationType)}\n >\n <SelectTrigger aria-label=\"Consultation type\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {CONSULTATION_TYPES.map((entry) => (\n <SelectItem key={entry} value={entry}>\n {formatEnumLabel(entry)}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n </div>\n\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"consultation-description\">Description</Label>\n <Textarea\n id=\"consultation-description\"\n rows={3}\n value={description}\n onChange={(event) => setDescription(event.target.value)}\n placeholder=\"Why this consultation is being held and what happens with the answers.\"\n />\n </div>\n\n <div className=\"grid gap-4 sm:grid-cols-2\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"consultation-opens\">Opens at</Label>\n <Input\n id=\"consultation-opens\"\n type=\"datetime-local\"\n value={opensAt}\n onChange={(event) => setOpensAt(event.target.value)}\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"consultation-closes\">Closes at</Label>\n <Input\n id=\"consultation-closes\"\n type=\"datetime-local\"\n value={closesAt}\n onChange={(event) => setClosesAt(event.target.value)}\n />\n </div>\n </div>\n\n <div className=\"flex items-start gap-3 rounded-xl border border-border-seam bg-bg-sunken/40 p-4\">\n <Switch\n id=\"consultation-allow-anonymous\"\n checked={allowAnonymous}\n onCheckedChange={(next) => setAllowAnonymous(next === true)}\n />\n <div className=\"min-w-0\">\n <Label htmlFor=\"consultation-allow-anonymous\" className=\"cursor-pointer\">\n Accept anonymous responses\n </Label>\n <p className=\"mt-1 text-xs text-text-muted\">\n Anonymous responses store no respondent id, so they cannot be de-duplicated or\n retrieved by their author afterwards.\n </p>\n </div>\n </div>\n\n <div className=\"grid gap-4 sm:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"consultation-budget\">\n Budget pot {hasBudgetQuestion ? '(required)' : '(optional)'}\n </Label>\n <Input\n id=\"consultation-budget\"\n type=\"number\"\n min=\"0\"\n step=\"any\"\n value={budgetAmount}\n onChange={(event) => setBudgetAmount(event.target.value)}\n placeholder=\"Total amount citizens allocate\"\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"consultation-currency\">Currency</Label>\n <Input\n id=\"consultation-currency\"\n value={currencyCode}\n maxLength={3}\n onChange={(event) => setCurrencyCode(event.target.value.toUpperCase())}\n placeholder=\"ISO 4217\"\n />\n </div>\n </div>\n\n <div className=\"grid gap-1.5\">\n <Label>Background document</Label>\n <div className=\"flex flex-wrap items-center gap-2\">\n <label className=\"inline-flex cursor-pointer items-center gap-1.5 rounded-button border border-border-seam bg-bg-surface px-3 py-1.5 text-sm font-medium text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary\">\n {uploading ? (\n <Loader2 className=\"size-4 animate-spin\" aria-hidden=\"true\" />\n ) : (\n <Upload className=\"size-4\" aria-hidden=\"true\" />\n )}\n {uploading ? 'Uploading…' : documentFileId ? 'Replace document' : 'Attach document'}\n <input\n type=\"file\"\n className=\"sr-only\"\n disabled={busy}\n onChange={(event) => {\n const file = event.target.files?.[0];\n event.target.value = '';\n if (file) void uploadDocument(file);\n }}\n />\n </label>\n {documentFileId && (\n <>\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 <FileText className=\"size-3.5\" aria-hidden=\"true\" /> Document attached\n </span>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n disabled={busy}\n onClick={() => setDocumentFileId(null)}\n >\n Remove\n </Button>\n </>\n )}\n </div>\n </div>\n\n <div className=\"grid gap-1.5\">\n <Label htmlFor=\"consultation-tags\">Tags</Label>\n <TagInput\n id=\"consultation-tags\"\n value={tags}\n onChange={setTags}\n placeholder=\"Add a tag…\"\n />\n </div>\n\n {/* Question builder */}\n <div className=\"border-t border-border-seam pt-4\">\n <div className=\"mb-3 flex flex-wrap items-center justify-between gap-2\">\n <div>\n <h3 className=\"text-sm font-semibold text-text-primary\">Questions</h3>\n <p className=\"text-xs text-text-muted\">\n These are rendered exactly as written on the citizen participation form.\n </p>\n </div>\n <Button\n type=\"button\"\n variant=\"outline\"\n size=\"sm\"\n onClick={addQuestion}\n disabled={busy}\n >\n <Plus className=\"mr-1.5 size-4\" aria-hidden=\"true\" /> Add question\n </Button>\n </div>\n\n {isEdit && consultation && consultation.responseCount > 0 && (\n <p className=\"mb-3 flex items-start gap-1.5 rounded-lg bg-status-warning-bg-subtle p-3 text-xs text-status-warning-text\">\n <AlertTriangle className=\"mt-0.5 size-3.5 shrink-0\" aria-hidden=\"true\" />\n This consultation already has responses. Changing or removing a question means the\n answers already recorded against it can no longer be aggregated.\n </p>\n )}\n\n {questions.length === 0 ? (\n <p className=\"rounded-xl border border-dashed border-border-seam p-4 text-sm text-text-muted\">\n No questions yet. Add at least one before the consultation can be opened.\n </p>\n ) : (\n <ul className=\"flex flex-col gap-3\">\n {questions.map((question, index) => (\n <li\n key={question.key}\n className=\"rounded-xl border border-border-seam bg-bg-surface p-4\"\n >\n <div className=\"mb-3 flex items-center justify-between gap-2\">\n <span className=\"text-xs font-semibold uppercase tracking-wide text-text-muted\">\n Question {index + 1}\n {question.persistedId && ' · published'}\n </span>\n <div className=\"flex items-center gap-1\">\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n aria-label=\"Move question up\"\n disabled={index === 0 || busy}\n onClick={() => moveQuestion(question.key, -1)}\n >\n ↑\n </Button>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n aria-label=\"Move question down\"\n disabled={index === questions.length - 1 || busy}\n onClick={() => moveQuestion(question.key, 1)}\n >\n ↓\n </Button>\n <Button\n type=\"button\"\n variant=\"ghost\"\n size=\"sm\"\n aria-label=\"Remove question\"\n disabled={busy}\n onClick={() => removeQuestion(question.key)}\n >\n <Trash2 className=\"size-4\" aria-hidden=\"true\" />\n </Button>\n </div>\n </div>\n\n <div className=\"grid gap-3 sm:grid-cols-[minmax(0,2fr)_minmax(0,1fr)]\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor={`${question.key}-label`}>Label</Label>\n <Input\n id={`${question.key}-label`}\n value={question.label}\n onChange={(event) =>\n patchQuestion(question.key, { label: event.target.value })\n }\n placeholder=\"What do you want to ask?\"\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label>Type</Label>\n <Select\n value={question.type}\n onValueChange={(value) =>\n patchQuestion(question.key, {\n type: value as GovConsultationQuestionType,\n })\n }\n >\n <SelectTrigger aria-label=\"Question type\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {CONSULTATION_QUESTION_TYPES.map((entry) => (\n <SelectItem key={entry} value={entry}>\n {QUESTION_TYPE_LABELS[entry]}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n </div>\n\n {OPTION_TYPES.has(question.type) && (\n <div className=\"mt-3 grid gap-1.5\">\n <Label htmlFor={`${question.key}-options`}>\n {question.type === 'BUDGET_ALLOCATION' ? 'Spending options' : 'Options'}\n </Label>\n <TagInput\n id={`${question.key}-options`}\n value={question.options}\n max={24}\n onChange={(options) => patchQuestion(question.key, { options })}\n placeholder=\"Add an option…\"\n />\n </div>\n )}\n\n {question.type === 'RATING' && (\n <div className=\"mt-3 grid gap-3 sm:grid-cols-2\">\n <div className=\"grid gap-1.5\">\n <Label htmlFor={`${question.key}-min`}>Lowest value</Label>\n <Input\n id={`${question.key}-min`}\n type=\"number\"\n value={question.min}\n onChange={(event) =>\n patchQuestion(question.key, { min: event.target.value })\n }\n />\n </div>\n <div className=\"grid gap-1.5\">\n <Label htmlFor={`${question.key}-max`}>Highest value</Label>\n <Input\n id={`${question.key}-max`}\n type=\"number\"\n value={question.max}\n onChange={(event) =>\n patchQuestion(question.key, { max: event.target.value })\n }\n />\n </div>\n </div>\n )}\n\n <div className=\"mt-3 flex items-center gap-2.5\">\n <Switch\n id={`${question.key}-required`}\n checked={question.required}\n onCheckedChange={(next) =>\n patchQuestion(question.key, { required: next === true })\n }\n />\n <Label htmlFor={`${question.key}-required`} className=\"cursor-pointer\">\n Required\n </Label>\n </div>\n </li>\n ))}\n </ul>\n )}\n </div>\n\n {error && (\n <p className=\"text-sm text-status-error-text\" role=\"alert\">\n {error}\n </p>\n )}\n </div>\n\n <ResponsiveDialogFooter>\n <Button variant=\"outline\" onClick={onClose} disabled={busy}>\n Cancel\n </Button>\n <Button\n onClick={() => {\n void submit();\n }}\n disabled={busy}\n >\n {isEdit ? 'Save changes' : 'Create consultation'}\n </Button>\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n}\n"],"mappings":";;;;;;;;;;;;AAuDA,IAAM,KAA0B,6CAE1B,KAAqD;CACzD;CACA;CACA;CACA;CACA;AACF,GAGM,IAAe,IAAI,IAAiC;CACxD;CACA;CACA;AACF,CAAC;AAgBD,SAAS,EAAqB,GAA0C;CACtE,IAAI,CAAC,GAAO,OAAO;CACnB,IAAM,IAAS,IAAI,KAAK,CAAK;CAC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AA,CACJ;;UACH;YApIG,EAAS,GAoIZ,CACL;QACC,CAAA;OAEH;;MAEJ,KACC,kBAAC,KAAD;OAAG,WAAU;OAAiC,MAAK;iBAChD;MACA,CAAA;KAEF;;IAEL,kBAAC,IAAD,EAAA,UAAA,CACE,kBAAC,GAAD;KAAQ,SAAQ;KAAU,SAAS;KAAS,UAAU;eAAM;IAEpD,CAAA,GACR,kBAAC,GAAD;KACE,eAAe;MACb,GAAY;KACd;KACA,UAAU;eAET,IAAS,iBAAiB;IACrB,CAAA,CACc,EAAA,CAAA;GACD;;CACT,CAAA;AAEtB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConsultationParticipateDialog.d.ts","sourceRoot":"","sources":["../../../../src/govcitizenhub/pages/intelligence/ConsultationParticipateDialog.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AA+B7D,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,aAAa,CAAC;AAcjE,MAAM,WAAW,kCAAkC;IACjD,YAAY,EAAE,eAAe,CAAC;IAC9B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,wBAAgB,6BAA6B,CAAC,EAC5C,YAAY,EACZ,OAAO,EACP,WAAW,GACZ,EAAE,kCAAkC,GAAG,YAAY,
|
|
1
|
+
{"version":3,"file":"ConsultationParticipateDialog.d.ts","sourceRoot":"","sources":["../../../../src/govcitizenhub/pages/intelligence/ConsultationParticipateDialog.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;GAkBG;AAEH,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AA+B7D,OAAO,KAAK,EAAE,eAAe,EAAgB,MAAM,aAAa,CAAC;AAcjE,MAAM,WAAW,kCAAkC;IACjD,YAAY,EAAE,eAAe,CAAC;IAC9B,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,qEAAqE;IACrE,WAAW,CAAC,EAAE,MAAM,IAAI,CAAC;CAC1B;AAED,wBAAgB,6BAA6B,CAAC,EAC5C,YAAY,EACZ,OAAO,EACP,WAAW,GACZ,EAAE,kCAAkC,GAAG,YAAY,CA8YnD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConsultationParticipateDialog.js","names":[],"sources":["../../../../src/govcitizenhub/pages/intelligence/ConsultationParticipateDialog.tsx"],"sourcesContent":["/**\n * ConsultationParticipateDialog — the citizen participation form.\n * @module govcitizenhub/pages/intelligence\n *\n * Renders the consultation's own `questions` JSON schema: there is no hard-coded\n * questionnaire anywhere here. All five declared types are supported —\n * SINGLE_CHOICE (radio), MULTI_CHOICE (checkboxes), RATING (a min..max scale),\n * TEXT (free text) and BUDGET_ALLOCATION (an amount per option with a live\n * running total and a remaining-balance indicator).\n *\n * The budget rule is the API's rule: allocations must sum to the consultation's\n * pot within `BUDGET_SUM_TOLERANCE`, so submission stays BLOCKED until they do\n * rather than sending a request the service will reject.\n *\n * Anonymity: the toggle only appears when the consultation allows it. An\n * anonymous submission stores no respondent id at all — which also means the\n * respondent can never retrieve it afterwards, and the dialog says so before it\n * is sent rather than letting the reader discover it later.\n */\n\nimport { useMemo, useState, type ReactElement } from 'react';\nimport { AlertTriangle, Send, ShieldOff } from 'lucide-react';\nimport {\n Button,\n Checkbox,\n Input,\n Label,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n Switch,\n Textarea,\n} from '@burdenoff/fe-libs/ui';\n\nimport {\n BUDGET_SUM_TOLERANCE,\n parseConsultationQuestions,\n type ConsultationQuestion,\n} from './consultationQuestions';\nimport { useGovSubmitConsultationResponse } from '../../hooks';\nimport { describeError, notify } from '../../lib/toast';\nimport { formatCurrency, formatNumber } from '../../utils/formatters';\nimport { cn } from '../../utils/cn';\nimport type { GovConsultation, GovSentiment } from '../../types';\n\n/** Beyond this many steps a rating scale becomes a number field, not buttons. */\nconst MAX_RATING_BUTTONS = 12;\n\ntype SentimentChoice = GovSentiment | 'NONE';\n\nconst SENTIMENT_LABELS: Record<SentimentChoice, string> = {\n NONE: 'Prefer not to say',\n POSITIVE: 'Positive',\n NEUTRAL: 'Neutral',\n NEGATIVE: 'Negative',\n};\n\nexport interface ConsultationParticipateDialogProps {\n consultation: GovConsultation;\n onClose: () => void;\n /** Fired after a successful submission, before the dialog closes. */\n onSubmitted?: () => void;\n}\n\nexport function ConsultationParticipateDialog({\n consultation,\n onClose,\n onSubmitted,\n}: ConsultationParticipateDialogProps): ReactElement {\n const questions = useMemo(\n () => parseConsultationQuestions(consultation.questions),\n [consultation.questions]\n );\n\n /** SINGLE_CHOICE option, RATING value and TEXT body all live here as strings. */\n const [singleValues, setSingleValues] = useState<Record<string, string>>({});\n const [multiValues, setMultiValues] = useState<Record<string, string[]>>({});\n const [budgetValues, setBudgetValues] = useState<Record<string, Record<string, string>>>({});\n const [anonymous, setAnonymous] = useState(false);\n const [sentiment, setSentiment] = useState<SentimentChoice>('NONE');\n const [error, setError] = useState<string | null>(null);\n\n const submitResponse = useGovSubmitConsultationResponse();\n const pot = consultation.budgetAmount ?? null;\n const currency = consultation.currencyCode;\n\n const setSingle = (questionId: string, value: string): void => {\n setSingleValues((current) => ({ ...current, [questionId]: value }));\n };\n\n const toggleMulti = (questionId: string, option: string, checked: boolean): void => {\n setMultiValues((current) => {\n const chosen = current[questionId] ?? [];\n const next = checked\n ? chosen.includes(option)\n ? chosen\n : [...chosen, option]\n : chosen.filter((entry) => entry !== option);\n return { ...current, [questionId]: next };\n });\n };\n\n const setAllocation = (questionId: string, option: string, value: string): void => {\n setBudgetValues((current) => ({\n ...current,\n [questionId]: { ...(current[questionId] ?? {}), [option]: value },\n }));\n };\n\n /** Sum of the amounts typed against one budget question. */\n const allocationTotal = (question: ConsultationQuestion): number => {\n const entries = budgetValues[question.id] ?? {};\n let total = 0;\n for (const option of question.options) {\n const parsed = Number(entries[option] ?? '');\n if (Number.isFinite(parsed)) total += parsed;\n }\n return total;\n };\n\n /** True when the respondent has typed nothing at all against a budget question. */\n const allocationUntouched = (question: ConsultationQuestion): boolean => {\n const entries = budgetValues[question.id] ?? {};\n return question.options.every((option) => (entries[option] ?? '').trim().length === 0);\n };\n\n const isAnswered = (question: ConsultationQuestion): boolean => {\n switch (question.type) {\n case 'MULTI_CHOICE':\n return (multiValues[question.id] ?? []).length > 0;\n case 'BUDGET_ALLOCATION':\n return !allocationUntouched(question);\n default:\n return (singleValues[question.id] ?? '').trim().length > 0;\n }\n };\n\n /** Everything that currently blocks submission, mirroring the API's rules. */\n const issues = useMemo<string[]>(() => {\n const found: string[] = [];\n for (const question of questions) {\n const answered =\n question.type === 'MULTI_CHOICE'\n ? (multiValues[question.id] ?? []).length > 0\n : question.type === 'BUDGET_ALLOCATION'\n ? question.options.some(\n (option) => ((budgetValues[question.id] ?? {})[option] ?? '').trim().length > 0\n )\n : (singleValues[question.id] ?? '').trim().length > 0;\n\n if (question.required && !answered) {\n found.push(`“${question.label}” is required.`);\n }\n\n if (question.type === 'RATING' && answered) {\n const value = Number(singleValues[question.id]);\n if (!Number.isFinite(value)) {\n found.push(`“${question.label}” needs a number.`);\n } else if (\n (question.min !== null && value < question.min) ||\n (question.max !== null && value > question.max)\n ) {\n found.push(`“${question.label}” must be between ${question.min} and ${question.max}.`);\n }\n }\n\n if (question.type === 'BUDGET_ALLOCATION' && (answered || question.required)) {\n if (pot === null || pot <= 0) {\n found.push(\n `“${question.label}” cannot be answered: this consultation has no budget pot recorded.`\n );\n } else {\n const entries = budgetValues[question.id] ?? {};\n let total = 0;\n let negative = false;\n for (const option of question.options) {\n const raw = (entries[option] ?? '').trim();\n if (raw.length === 0) continue;\n const parsed = Number(raw);\n if (!Number.isFinite(parsed)) {\n negative = true;\n break;\n }\n if (parsed < 0) negative = true;\n total += parsed;\n }\n if (negative) {\n found.push(`“${question.label}” only accepts non-negative amounts.`);\n } else if (Math.abs(total - pot) > BUDGET_SUM_TOLERANCE) {\n found.push(\n `“${question.label}” must allocate exactly ${formatCurrency(pot, currency)}.`\n );\n }\n }\n }\n }\n return found;\n }, [questions, singleValues, multiValues, budgetValues, pot, currency]);\n\n const busy = submitResponse.isPending;\n const canSubmit = questions.length > 0 && issues.length === 0 && !busy;\n\n const submit = async (): Promise<void> => {\n const answers: { questionId: string; value: unknown }[] = [];\n\n for (const question of questions) {\n if (!isAnswered(question)) continue;\n\n switch (question.type) {\n case 'SINGLE_CHOICE':\n answers.push({ questionId: question.id, value: singleValues[question.id].trim() });\n break;\n case 'TEXT':\n answers.push({ questionId: question.id, value: singleValues[question.id].trim() });\n break;\n case 'RATING':\n answers.push({ questionId: question.id, value: Number(singleValues[question.id]) });\n break;\n case 'MULTI_CHOICE':\n answers.push({ questionId: question.id, value: multiValues[question.id] });\n break;\n case 'BUDGET_ALLOCATION': {\n const entries = budgetValues[question.id] ?? {};\n const allocation: Record<string, number> = {};\n for (const option of question.options) {\n const parsed = Number((entries[option] ?? '').trim());\n allocation[option] = Number.isFinite(parsed) ? parsed : 0;\n }\n answers.push({ questionId: question.id, value: allocation });\n break;\n }\n default:\n break;\n }\n }\n\n setError(null);\n try {\n await submitResponse.mutateAsync({\n consultationId: consultation.id,\n answers,\n sentiment: sentiment === 'NONE' ? undefined : sentiment,\n anonymous: anonymous ? true : undefined,\n });\n notify.success(\n 'Response submitted',\n anonymous\n ? 'Your answers were recorded without your identity.'\n : 'Thank you for taking part.'\n );\n onSubmitted?.();\n onClose();\n } catch (err) {\n setError(describeError(err));\n }\n };\n\n return (\n <ResponsiveDialog\n open\n onOpenChange={(next) => {\n if (!next && !busy) onClose();\n }}\n >\n <ResponsiveDialogContent className=\"max-h-[90vh] overflow-y-auto sm:max-w-2xl\">\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>{consultation.title}</ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n {consultation.description ?? 'Answer the questions below to take part.'}\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n\n <div className=\"flex flex-col gap-5 py-2\">\n {questions.length === 0 ? (\n <p className=\"text-sm text-text-muted\">\n This consultation has no published questions yet, so there is nothing to answer.\n </p>\n ) : (\n questions.map((question, index) => (\n <fieldset\n key={question.id}\n className=\"rounded-xl border border-border-seam bg-bg-surface p-4\"\n >\n <legend className=\"px-1 text-sm font-semibold text-text-primary\">\n {index + 1}. {question.label}\n {question.required && (\n <span className=\"ml-1 text-status-error-text\" aria-label=\"required\">\n *\n </span>\n )}\n </legend>\n\n {question.type === 'SINGLE_CHOICE' && (\n <div role=\"radiogroup\" aria-label={question.label} className=\"mt-3 flex flex-col gap-2\">\n {question.options.map((option) => {\n const selected = singleValues[question.id] === option;\n return (\n <button\n key={option}\n type=\"button\"\n role=\"radio\"\n aria-checked={selected}\n onClick={() => setSingle(question.id, option)}\n className={cn(\n 'flex w-full items-center gap-2.5 rounded-lg border px-3 py-2 text-left text-sm transition-colors',\n selected\n ? 'border-action-primary-bg bg-[var(--color-accent-soft)] text-text-primary'\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={cn(\n 'size-4 shrink-0 rounded-full border-2',\n selected ? 'border-[5px] border-action-primary-bg' : 'border-border-strong'\n )}\n />\n {option}\n </button>\n );\n })}\n </div>\n )}\n\n {question.type === 'MULTI_CHOICE' && (\n <div className=\"mt-3 flex flex-col gap-2\">\n {question.options.map((option) => {\n const checkboxId = `${question.id}-${option}`;\n const chosen = (multiValues[question.id] ?? []).includes(option);\n return (\n <label\n key={option}\n htmlFor={checkboxId}\n className=\"flex cursor-pointer items-center gap-2.5 rounded-lg border border-border-seam bg-bg-surface px-3 py-2 text-sm text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary\"\n >\n <Checkbox\n id={checkboxId}\n checked={chosen}\n onCheckedChange={(next) =>\n toggleMulti(question.id, option, next === true)\n }\n />\n {option}\n </label>\n );\n })}\n </div>\n )}\n\n {question.type === 'RATING' && (\n <RatingField\n question={question}\n value={singleValues[question.id] ?? ''}\n onChange={(value) => setSingle(question.id, value)}\n />\n )}\n\n {question.type === 'TEXT' && (\n <Textarea\n className=\"mt-3\"\n rows={3}\n value={singleValues[question.id] ?? ''}\n onChange={(event) => setSingle(question.id, event.target.value)}\n placeholder=\"Your answer\"\n aria-label={question.label}\n />\n )}\n\n {question.type === 'BUDGET_ALLOCATION' && (\n <BudgetAllocationField\n question={question}\n pot={pot}\n currency={currency}\n values={budgetValues[question.id] ?? {}}\n total={allocationTotal(question)}\n onChange={(option, value) => setAllocation(question.id, option, value)}\n />\n )}\n </fieldset>\n ))\n )}\n\n {questions.length > 0 && (\n <div className=\"grid gap-1.5\">\n <Label>Overall sentiment (optional)</Label>\n <Select\n value={sentiment}\n onValueChange={(value) => setSentiment(value as SentimentChoice)}\n >\n <SelectTrigger aria-label=\"Overall sentiment\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {(['NONE', 'POSITIVE', 'NEUTRAL', 'NEGATIVE'] as const).map((entry) => (\n <SelectItem key={entry} value={entry}>\n {SENTIMENT_LABELS[entry]}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n )}\n\n {consultation.allowAnonymous && questions.length > 0 && (\n <div className=\"flex items-start gap-3 rounded-xl border border-border-seam bg-bg-sunken/40 p-4\">\n <Switch\n id=\"consultation-anonymous\"\n checked={anonymous}\n onCheckedChange={(next) => setAnonymous(next === true)}\n />\n <div className=\"min-w-0\">\n <Label htmlFor=\"consultation-anonymous\" className=\"cursor-pointer\">\n Submit anonymously\n </Label>\n <p className=\"mt-1 flex items-start gap-1.5 text-xs text-text-muted\">\n <ShieldOff className=\"mt-0.5 size-3.5 shrink-0\" aria-hidden=\"true\" />\n No respondent id is stored. Because nothing links the response back to you, you\n will not be able to view or change it afterwards.\n </p>\n </div>\n </div>\n )}\n\n {issues.length > 0 && (\n <div\n className=\"rounded-xl border border-border-seam bg-status-warning-bg-subtle p-3\"\n role=\"status\"\n >\n <p className=\"flex items-center gap-1.5 text-sm font-medium text-status-warning-text\">\n <AlertTriangle className=\"size-4 shrink-0\" aria-hidden=\"true\" /> Before you can\n submit\n </p>\n <ul className=\"mt-1.5 list-inside list-disc text-sm text-status-warning-text\">\n {issues.map((issue) => (\n <li key={issue}>{issue}</li>\n ))}\n </ul>\n </div>\n )}\n\n {error && <p className=\"text-sm text-status-error-text\">{error}</p>}\n </div>\n\n <ResponsiveDialogFooter>\n <Button variant=\"outline\" onClick={onClose} disabled={busy}>\n Cancel\n </Button>\n <Button\n disabled={!canSubmit}\n onClick={() => {\n void submit();\n }}\n >\n <Send className=\"mr-1.5 h-4 w-4\" aria-hidden=\"true\" />\n {busy ? 'Submitting…' : 'Submit response'}\n </Button>\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n}\n\ninterface RatingFieldProps {\n question: ConsultationQuestion;\n value: string;\n onChange: (value: string) => void;\n}\n\n/** A min..max scale — buttons for a short scale, a number field for a long one. */\nfunction RatingField({ question, value, onChange }: RatingFieldProps): ReactElement {\n const min = question.min;\n const max = question.max;\n\n if (min === null || max === null || max - min + 1 > MAX_RATING_BUTTONS) {\n return (\n <div className=\"mt-3\">\n <Input\n type=\"number\"\n value={value}\n min={min ?? undefined}\n max={max ?? undefined}\n onChange={(event) => onChange(event.target.value)}\n aria-label={question.label}\n placeholder={min !== null && max !== null ? `${min} to ${max}` : 'Your rating'}\n />\n {min !== null && max !== null && (\n <p className=\"mt-1 text-xs text-text-muted\">\n Rate between {formatNumber(min)} and {formatNumber(max)}.\n </p>\n )}\n </div>\n );\n }\n\n const steps: number[] = [];\n for (let step = min; step <= max; step += 1) steps.push(step);\n\n return (\n <div className=\"mt-3\">\n <div role=\"radiogroup\" aria-label={question.label} className=\"flex flex-wrap gap-1.5\">\n {steps.map((step) => {\n const selected = value === String(step);\n return (\n <button\n key={step}\n type=\"button\"\n role=\"radio\"\n aria-checked={selected}\n onClick={() => onChange(String(step))}\n className={cn(\n 'inline-flex size-10 items-center justify-center rounded-lg border text-sm font-medium tabular-nums transition-colors',\n selected\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 {step}\n </button>\n );\n })}\n </div>\n <p className=\"mt-1.5 text-xs text-text-muted\">\n {formatNumber(min)} is the lowest, {formatNumber(max)} the highest.\n </p>\n </div>\n );\n}\n\ninterface BudgetAllocationFieldProps {\n question: ConsultationQuestion;\n /** The consultation's pot. Null when the author has not recorded one. */\n pot: number | null;\n currency?: string | null;\n values: Record<string, string>;\n total: number;\n onChange: (option: string, value: string) => void;\n}\n\n/**\n * An amount per option with a live running total and a remaining-balance\n * indicator. The submit button stays disabled until the balance is settled —\n * the same rule `validateConsultationAnswers` enforces server-side.\n */\nfunction BudgetAllocationField({\n question,\n pot,\n currency,\n values,\n total,\n onChange,\n}: BudgetAllocationFieldProps): ReactElement {\n if (pot === null || pot <= 0) {\n return (\n <p className=\"mt-3 text-sm text-status-error-text\">\n This question cannot be answered: no budget pot has been recorded for the consultation.\n </p>\n );\n }\n\n const remaining = pot - total;\n const settled = Math.abs(remaining) <= BUDGET_SUM_TOLERANCE;\n const overAllocated = remaining < -BUDGET_SUM_TOLERANCE;\n const filled = Math.max(0, Math.min(100, (total / pot) * 100));\n\n return (\n <div className=\"mt-3 flex flex-col gap-3\">\n <div className=\"flex flex-col gap-2\">\n {question.options.map((option) => (\n <div key={option} className=\"flex flex-wrap items-center gap-2\">\n <Label\n htmlFor={`${question.id}-${option}`}\n className=\"min-w-0 flex-1 text-sm font-normal text-text-secondary\"\n >\n {option}\n </Label>\n <Input\n id={`${question.id}-${option}`}\n type=\"number\"\n min=\"0\"\n step=\"any\"\n inputMode=\"decimal\"\n className=\"w-40\"\n value={values[option] ?? ''}\n onChange={(event) => onChange(option, event.target.value)}\n placeholder=\"0\"\n />\n </div>\n ))}\n </div>\n\n <div className=\"rounded-xl border border-border-seam bg-bg-sunken/40 p-3\">\n <div className=\"flex flex-wrap items-baseline justify-between gap-2 text-sm\">\n <span className=\"text-text-secondary\">Allocated</span>\n <span className=\"font-semibold tabular-nums text-text-primary\">\n {formatCurrency(total, currency)} of {formatCurrency(pot, currency)}\n </span>\n </div>\n <div\n className=\"mt-2 h-2 w-full overflow-hidden rounded-full bg-bg-sunken\"\n role=\"progressbar\"\n aria-valuemin={0}\n aria-valuemax={pot}\n aria-valuenow={total}\n aria-label=\"Budget allocated\"\n >\n <div\n className={cn(\n 'h-full rounded-full transition-[width] duration-200',\n overAllocated\n ? 'bg-status-error-bg'\n : settled\n ? 'bg-status-success-bg'\n : 'bg-action-primary-bg'\n )}\n style={{ width: `${filled}%` }}\n />\n </div>\n <p\n className={cn(\n 'mt-2 text-sm tabular-nums',\n overAllocated\n ? 'text-status-error-text'\n : settled\n ? 'text-status-success-text'\n : 'text-text-secondary'\n )}\n >\n {overAllocated\n ? `Over by ${formatCurrency(Math.abs(remaining), currency)} — reduce an allocation to continue.`\n : settled\n ? 'The full pot is allocated.'\n : `${formatCurrency(remaining, currency)} still to allocate.`}\n </p>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AAsDA,IAAM,IAAqB,IAIrB,IAAoD;CACxD,MAAM;CACN,UAAU;CACV,SAAS;CACT,UAAU;AACZ;AASA,SAAgB,EAA8B,EAC5C,iBACA,YACA,kBACmD;CACnD,IAAM,IAAY,QACV,EAA2B,EAAa,SAAS,GACvD,CAAC,EAAa,SAAS,CACzB,GAGM,CAAC,GAAc,KAAmB,EAAiC,CAAC,CAAC,GACrE,CAAC,GAAa,KAAkB,EAAmC,CAAC,CAAC,GACrE,CAAC,GAAc,KAAmB,EAAiD,C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AI,GAAG,KAAK,IAAI,KAAM,IAAQ,IAAO,GAAG,CAAC;CAE7D,OACE,kBAAC,OAAD;EAAK,WAAU;YAAf,CACE,kBAAC,OAAD;GAAK,WAAU;aACZ,EAAS,QAAQ,KAAK,MACrB,kBAAC,OAAD;IAAkB,WAAU;cAA5B,CACE,kBAAC,GAAD;KACE,SAAS,GAAG,EAAS,GAAG,GAAG;KAC3B,WAAU;eAET;IACI,CAAA,GACP,kBAAC,GAAD;KACE,IAAI,GAAG,EAAS,GAAG,GAAG;KACtB,MAAK;KACL,KAAI;KACJ,MAAK;KACL,WAAU;KACV,WAAU;KACV,OAAO,EAAO,MAAW;KACzB,WAAW,MAAU,EAAS,GAAQ,EAAM,OAAO,KAAK;KACxD,aAAY;IACb,CAAA,CACE;MAlBK,CAkBL,CACN;EACE,CAAA,GAEL,kBAAC,OAAD;GAAK,WAAU;aAAf;IACE,kBAAC,OAAD;KAAK,WAAU;eAAf,CACE,kBAAC,QAAD;MAAM,WAAU;gBAAsB;KAAe,CAAA,GACrD,kBAAC,QAAD;MAAM,WAAU;gBAAhB;OACG,EAAe,GAAO,CAAQ;OAAE;OAAK,EAAe,GAAK,CAAQ;MAC9D;OACH;;IACL,kBAAC,OAAD;KACE,WAAU;KACV,MAAK;KACL,iBAAe;KACf,iBAAe;KACf,iBAAe;KACf,cAAW;eAEX,kBAAC,OAAD;MACE,WAAW,EACT,uDACA,IACI,uBACA,IACE,yBACA,sBACR;MACA,OAAO,EAAE,OAAO,GAAG,EAAO,GAAG;KAC9B,CAAA;IACE,CAAA;IACL,kBAAC,KAAD;KACE,WAAW,EACT,6BACA,IACI,2BACA,IACE,6BACA,qBACR;eAEC,IACG,WAAW,EAAe,KAAK,IAAI,CAAS,GAAG,CAAQ,EAAE,wCACzD,IACE,+BACA,GAAG,EAAe,GAAW,CAAQ,EAAE;IAC5C,CAAA;GACA;IACF;;AAET"}
|
|
1
|
+
{"version":3,"file":"ConsultationParticipateDialog.js","names":[],"sources":["../../../../src/govcitizenhub/pages/intelligence/ConsultationParticipateDialog.tsx"],"sourcesContent":["/**\n * ConsultationParticipateDialog — the citizen participation form.\n * @module govcitizenhub/pages/intelligence\n *\n * Renders the consultation's own `questions` JSON schema: there is no hard-coded\n * questionnaire anywhere here. All five declared types are supported —\n * SINGLE_CHOICE (radio), MULTI_CHOICE (checkboxes), RATING (a min..max scale),\n * TEXT (free text) and BUDGET_ALLOCATION (an amount per option with a live\n * running total and a remaining-balance indicator).\n *\n * The budget rule is the API's rule: allocations must sum to the consultation's\n * pot within `BUDGET_SUM_TOLERANCE`, so submission stays BLOCKED until they do\n * rather than sending a request the service will reject.\n *\n * Anonymity: the toggle only appears when the consultation allows it. An\n * anonymous submission stores no respondent id at all — which also means the\n * respondent can never retrieve it afterwards, and the dialog says so before it\n * is sent rather than letting the reader discover it later.\n */\n\nimport { useMemo, useState, type ReactElement } from 'react';\nimport { AlertTriangle, Send, ShieldOff } from 'lucide-react';\nimport {\n Button,\n Checkbox,\n Input,\n Label,\n ResponsiveDialog,\n ResponsiveDialogContent,\n ResponsiveDialogDescription,\n ResponsiveDialogFooter,\n ResponsiveDialogHeader,\n ResponsiveDialogTitle,\n Select,\n SelectContent,\n SelectItem,\n SelectTrigger,\n SelectValue,\n Switch,\n Textarea,\n} from '@burdenoff/fe-libs/ui';\n\nimport {\n BUDGET_SUM_TOLERANCE,\n parseConsultationQuestions,\n type ConsultationQuestion,\n} from './consultationQuestions';\nimport { useGovSubmitConsultationResponse } from '../../hooks';\nimport { describeError, notify } from '../../lib/toast';\nimport { formatCurrency, formatNumber } from '../../utils/formatters';\nimport { cn } from '../../utils/cn';\nimport type { GovConsultation, GovSentiment } from '../../types';\n\n/** Beyond this many steps a rating scale becomes a number field, not buttons. */\nconst MAX_RATING_BUTTONS = 12;\n\ntype SentimentChoice = GovSentiment | 'NONE';\n\nconst SENTIMENT_LABELS: Record<SentimentChoice, string> = {\n NONE: 'Prefer not to say',\n POSITIVE: 'Positive',\n NEUTRAL: 'Neutral',\n NEGATIVE: 'Negative',\n};\n\nexport interface ConsultationParticipateDialogProps {\n consultation: GovConsultation;\n onClose: () => void;\n /** Fired after a successful submission, before the dialog closes. */\n onSubmitted?: () => void;\n}\n\nexport function ConsultationParticipateDialog({\n consultation,\n onClose,\n onSubmitted,\n}: ConsultationParticipateDialogProps): ReactElement {\n const questions = useMemo(\n () => parseConsultationQuestions(consultation.questions),\n [consultation.questions]\n );\n\n /** SINGLE_CHOICE option, RATING value and TEXT body all live here as strings. */\n const [singleValues, setSingleValues] = useState<Record<string, string>>({});\n const [multiValues, setMultiValues] = useState<Record<string, string[]>>({});\n const [budgetValues, setBudgetValues] = useState<Record<string, Record<string, string>>>({});\n const [anonymous, setAnonymous] = useState(false);\n const [sentiment, setSentiment] = useState<SentimentChoice>('NONE');\n const [error, setError] = useState<string | null>(null);\n\n const submitResponse = useGovSubmitConsultationResponse();\n const pot = consultation.budgetAmount ?? null;\n const currency = consultation.currencyCode;\n\n const setSingle = (questionId: string, value: string): void => {\n setSingleValues((current) => ({ ...current, [questionId]: value }));\n };\n\n const toggleMulti = (questionId: string, option: string, checked: boolean): void => {\n setMultiValues((current) => {\n const chosen = current[questionId] ?? [];\n const next = checked\n ? chosen.includes(option)\n ? chosen\n : [...chosen, option]\n : chosen.filter((entry) => entry !== option);\n return { ...current, [questionId]: next };\n });\n };\n\n const setAllocation = (questionId: string, option: string, value: string): void => {\n setBudgetValues((current) => ({\n ...current,\n [questionId]: { ...(current[questionId] ?? {}), [option]: value },\n }));\n };\n\n /** Sum of the amounts typed against one budget question. */\n const allocationTotal = (question: ConsultationQuestion): number => {\n const entries = budgetValues[question.id] ?? {};\n let total = 0;\n for (const option of question.options) {\n const parsed = Number(entries[option] ?? '');\n if (Number.isFinite(parsed)) total += parsed;\n }\n return total;\n };\n\n /** True when the respondent has typed nothing at all against a budget question. */\n const allocationUntouched = (question: ConsultationQuestion): boolean => {\n const entries = budgetValues[question.id] ?? {};\n return question.options.every((option) => (entries[option] ?? '').trim().length === 0);\n };\n\n const isAnswered = (question: ConsultationQuestion): boolean => {\n switch (question.type) {\n case 'MULTI_CHOICE':\n return (multiValues[question.id] ?? []).length > 0;\n case 'BUDGET_ALLOCATION':\n return !allocationUntouched(question);\n default:\n return (singleValues[question.id] ?? '').trim().length > 0;\n }\n };\n\n /** Everything that currently blocks submission, mirroring the API's rules. */\n const issues = useMemo<string[]>(() => {\n const found: string[] = [];\n for (const question of questions) {\n const answered =\n question.type === 'MULTI_CHOICE'\n ? (multiValues[question.id] ?? []).length > 0\n : question.type === 'BUDGET_ALLOCATION'\n ? question.options.some(\n (option) => ((budgetValues[question.id] ?? {})[option] ?? '').trim().length > 0\n )\n : (singleValues[question.id] ?? '').trim().length > 0;\n\n if (question.required && !answered) {\n found.push(`“${question.label}” is required.`);\n }\n\n if (question.type === 'RATING' && answered) {\n const value = Number(singleValues[question.id]);\n if (!Number.isFinite(value)) {\n found.push(`“${question.label}” needs a number.`);\n } else if (\n (question.min !== null && value < question.min) ||\n (question.max !== null && value > question.max)\n ) {\n found.push(`“${question.label}” must be between ${question.min} and ${question.max}.`);\n }\n }\n\n if (question.type === 'BUDGET_ALLOCATION' && (answered || question.required)) {\n if (pot === null || pot <= 0) {\n found.push(\n `“${question.label}” cannot be answered: this consultation has no budget pot recorded.`\n );\n } else {\n const entries = budgetValues[question.id] ?? {};\n let total = 0;\n let negative = false;\n for (const option of question.options) {\n const raw = (entries[option] ?? '').trim();\n if (raw.length === 0) continue;\n const parsed = Number(raw);\n if (!Number.isFinite(parsed)) {\n negative = true;\n break;\n }\n if (parsed < 0) negative = true;\n total += parsed;\n }\n if (negative) {\n found.push(`“${question.label}” only accepts non-negative amounts.`);\n } else if (Math.abs(total - pot) > BUDGET_SUM_TOLERANCE) {\n found.push(\n `“${question.label}” must allocate exactly ${formatCurrency(pot, currency)}.`\n );\n }\n }\n }\n }\n return found;\n }, [questions, singleValues, multiValues, budgetValues, pot, currency]);\n\n const busy = submitResponse.isPending;\n const canSubmit = questions.length > 0 && issues.length === 0 && !busy;\n\n const submit = async (): Promise<void> => {\n const answers: { questionId: string; value: unknown }[] = [];\n\n for (const question of questions) {\n if (!isAnswered(question)) continue;\n\n switch (question.type) {\n case 'SINGLE_CHOICE':\n answers.push({ questionId: question.id, value: singleValues[question.id].trim() });\n break;\n case 'TEXT':\n answers.push({ questionId: question.id, value: singleValues[question.id].trim() });\n break;\n case 'RATING':\n answers.push({ questionId: question.id, value: Number(singleValues[question.id]) });\n break;\n case 'MULTI_CHOICE':\n answers.push({ questionId: question.id, value: multiValues[question.id] });\n break;\n case 'BUDGET_ALLOCATION': {\n const entries = budgetValues[question.id] ?? {};\n const allocation: Record<string, number> = {};\n for (const option of question.options) {\n const parsed = Number((entries[option] ?? '').trim());\n allocation[option] = Number.isFinite(parsed) ? parsed : 0;\n }\n answers.push({ questionId: question.id, value: allocation });\n break;\n }\n default:\n break;\n }\n }\n\n setError(null);\n try {\n await submitResponse.mutateAsync({\n consultationId: consultation.id,\n answers,\n sentiment: sentiment === 'NONE' ? undefined : sentiment,\n anonymous: anonymous ? true : undefined,\n });\n notify.success(\n 'Response submitted',\n anonymous\n ? 'Your answers were recorded without your identity.'\n : 'Thank you for taking part.'\n );\n onSubmitted?.();\n onClose();\n } catch (err) {\n setError(describeError(err));\n }\n };\n\n return (\n <ResponsiveDialog\n open\n onOpenChange={(next) => {\n if (!next && !busy) onClose();\n }}\n >\n <ResponsiveDialogContent className=\"max-h-[90vh] overflow-y-auto sm:max-w-2xl\">\n <ResponsiveDialogHeader>\n <ResponsiveDialogTitle>{consultation.title}</ResponsiveDialogTitle>\n <ResponsiveDialogDescription>\n {consultation.description ?? 'Answer the questions below to take part.'}\n </ResponsiveDialogDescription>\n </ResponsiveDialogHeader>\n\n <div className=\"flex flex-col gap-5 py-2\">\n {questions.length === 0 ? (\n <p className=\"text-sm text-text-muted\">\n This consultation has no published questions yet, so there is nothing to answer.\n </p>\n ) : (\n questions.map((question, index) => (\n <fieldset\n key={question.id}\n className=\"rounded-xl border border-border-seam bg-bg-surface p-4\"\n >\n <legend className=\"px-1 text-sm font-semibold text-text-primary\">\n {index + 1}. {question.label}\n {question.required && (\n <span className=\"ml-1 text-status-error-text\" aria-label=\"required\">\n *\n </span>\n )}\n </legend>\n\n {question.type === 'SINGLE_CHOICE' && (\n <div\n role=\"radiogroup\"\n aria-label={question.label}\n className=\"mt-3 flex flex-col gap-2\"\n >\n {question.options.map((option) => {\n const selected = singleValues[question.id] === option;\n return (\n <button\n key={option}\n type=\"button\"\n role=\"radio\"\n aria-checked={selected}\n onClick={() => setSingle(question.id, option)}\n className={cn(\n 'flex w-full items-center gap-2.5 rounded-lg border px-3 py-2 text-left text-sm transition-colors',\n selected\n ? 'border-action-primary-bg bg-[var(--color-accent-soft)] text-text-primary'\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={cn(\n 'size-4 shrink-0 rounded-full border-2',\n selected\n ? 'border-[5px] border-action-primary-bg'\n : 'border-border-strong'\n )}\n />\n {option}\n </button>\n );\n })}\n </div>\n )}\n\n {question.type === 'MULTI_CHOICE' && (\n <div className=\"mt-3 flex flex-col gap-2\">\n {question.options.map((option) => {\n const checkboxId = `${question.id}-${option}`;\n const chosen = (multiValues[question.id] ?? []).includes(option);\n return (\n <label\n key={option}\n htmlFor={checkboxId}\n className=\"flex cursor-pointer items-center gap-2.5 rounded-lg border border-border-seam bg-bg-surface px-3 py-2 text-sm text-text-secondary transition-colors hover:bg-bg-sunken hover:text-text-primary\"\n >\n <Checkbox\n id={checkboxId}\n checked={chosen}\n onCheckedChange={(next) =>\n toggleMulti(question.id, option, next === true)\n }\n />\n {option}\n </label>\n );\n })}\n </div>\n )}\n\n {question.type === 'RATING' && (\n <RatingField\n question={question}\n value={singleValues[question.id] ?? ''}\n onChange={(value) => setSingle(question.id, value)}\n />\n )}\n\n {question.type === 'TEXT' && (\n <Textarea\n className=\"mt-3\"\n rows={3}\n value={singleValues[question.id] ?? ''}\n onChange={(event) => setSingle(question.id, event.target.value)}\n placeholder=\"Your answer\"\n aria-label={question.label}\n />\n )}\n\n {question.type === 'BUDGET_ALLOCATION' && (\n <BudgetAllocationField\n question={question}\n pot={pot}\n currency={currency}\n values={budgetValues[question.id] ?? {}}\n total={allocationTotal(question)}\n onChange={(option, value) => setAllocation(question.id, option, value)}\n />\n )}\n </fieldset>\n ))\n )}\n\n {questions.length > 0 && (\n <div className=\"grid gap-1.5\">\n <Label>Overall sentiment (optional)</Label>\n <Select\n value={sentiment}\n onValueChange={(value) => setSentiment(value as SentimentChoice)}\n >\n <SelectTrigger aria-label=\"Overall sentiment\">\n <SelectValue />\n </SelectTrigger>\n <SelectContent>\n {(['NONE', 'POSITIVE', 'NEUTRAL', 'NEGATIVE'] as const).map((entry) => (\n <SelectItem key={entry} value={entry}>\n {SENTIMENT_LABELS[entry]}\n </SelectItem>\n ))}\n </SelectContent>\n </Select>\n </div>\n )}\n\n {consultation.allowAnonymous && questions.length > 0 && (\n <div className=\"flex items-start gap-3 rounded-xl border border-border-seam bg-bg-sunken/40 p-4\">\n <Switch\n id=\"consultation-anonymous\"\n checked={anonymous}\n onCheckedChange={(next) => setAnonymous(next === true)}\n />\n <div className=\"min-w-0\">\n <Label htmlFor=\"consultation-anonymous\" className=\"cursor-pointer\">\n Submit anonymously\n </Label>\n <p className=\"mt-1 flex items-start gap-1.5 text-xs text-text-muted\">\n <ShieldOff className=\"mt-0.5 size-3.5 shrink-0\" aria-hidden=\"true\" />\n No respondent id is stored. Because nothing links the response back to you, you\n will not be able to view or change it afterwards.\n </p>\n </div>\n </div>\n )}\n\n {issues.length > 0 && (\n <div\n className=\"rounded-xl border border-border-seam bg-status-warning-bg-subtle p-3\"\n role=\"status\"\n >\n <p className=\"flex items-center gap-1.5 text-sm font-medium text-status-warning-text\">\n <AlertTriangle className=\"size-4 shrink-0\" aria-hidden=\"true\" /> Before you can\n submit\n </p>\n <ul className=\"mt-1.5 list-inside list-disc text-sm text-status-warning-text\">\n {issues.map((issue) => (\n <li key={issue}>{issue}</li>\n ))}\n </ul>\n </div>\n )}\n\n {error && <p className=\"text-sm text-status-error-text\">{error}</p>}\n </div>\n\n <ResponsiveDialogFooter>\n <Button variant=\"outline\" onClick={onClose} disabled={busy}>\n Cancel\n </Button>\n <Button\n disabled={!canSubmit}\n onClick={() => {\n void submit();\n }}\n >\n <Send className=\"mr-1.5 h-4 w-4\" aria-hidden=\"true\" />\n {busy ? 'Submitting…' : 'Submit response'}\n </Button>\n </ResponsiveDialogFooter>\n </ResponsiveDialogContent>\n </ResponsiveDialog>\n );\n}\n\ninterface RatingFieldProps {\n question: ConsultationQuestion;\n value: string;\n onChange: (value: string) => void;\n}\n\n/** A min..max scale — buttons for a short scale, a number field for a long one. */\nfunction RatingField({ question, value, onChange }: RatingFieldProps): ReactElement {\n const min = question.min;\n const max = question.max;\n\n if (min === null || max === null || max - min + 1 > MAX_RATING_BUTTONS) {\n return (\n <div className=\"mt-3\">\n <Input\n type=\"number\"\n value={value}\n min={min ?? undefined}\n max={max ?? undefined}\n onChange={(event) => onChange(event.target.value)}\n aria-label={question.label}\n placeholder={min !== null && max !== null ? `${min} to ${max}` : 'Your rating'}\n />\n {min !== null && max !== null && (\n <p className=\"mt-1 text-xs text-text-muted\">\n Rate between {formatNumber(min)} and {formatNumber(max)}.\n </p>\n )}\n </div>\n );\n }\n\n const steps: number[] = [];\n for (let step = min; step <= max; step += 1) steps.push(step);\n\n return (\n <div className=\"mt-3\">\n <div role=\"radiogroup\" aria-label={question.label} className=\"flex flex-wrap gap-1.5\">\n {steps.map((step) => {\n const selected = value === String(step);\n return (\n <button\n key={step}\n type=\"button\"\n role=\"radio\"\n aria-checked={selected}\n onClick={() => onChange(String(step))}\n className={cn(\n 'inline-flex size-10 items-center justify-center rounded-lg border text-sm font-medium tabular-nums transition-colors',\n selected\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 {step}\n </button>\n );\n })}\n </div>\n <p className=\"mt-1.5 text-xs text-text-muted\">\n {formatNumber(min)} is the lowest, {formatNumber(max)} the highest.\n </p>\n </div>\n );\n}\n\ninterface BudgetAllocationFieldProps {\n question: ConsultationQuestion;\n /** The consultation's pot. Null when the author has not recorded one. */\n pot: number | null;\n currency?: string | null;\n values: Record<string, string>;\n total: number;\n onChange: (option: string, value: string) => void;\n}\n\n/**\n * An amount per option with a live running total and a remaining-balance\n * indicator. The submit button stays disabled until the balance is settled —\n * the same rule `validateConsultationAnswers` enforces server-side.\n */\nfunction BudgetAllocationField({\n question,\n pot,\n currency,\n values,\n total,\n onChange,\n}: BudgetAllocationFieldProps): ReactElement {\n if (pot === null || pot <= 0) {\n return (\n <p className=\"mt-3 text-sm text-status-error-text\">\n This question cannot be answered: no budget pot has been recorded for the consultation.\n </p>\n );\n }\n\n const remaining = pot - total;\n const settled = Math.abs(remaining) <= BUDGET_SUM_TOLERANCE;\n const overAllocated = remaining < -BUDGET_SUM_TOLERANCE;\n const filled = Math.max(0, Math.min(100, (total / pot) * 100));\n\n return (\n <div className=\"mt-3 flex flex-col gap-3\">\n <div className=\"flex flex-col gap-2\">\n {question.options.map((option) => (\n <div key={option} className=\"flex flex-wrap items-center gap-2\">\n <Label\n htmlFor={`${question.id}-${option}`}\n className=\"min-w-0 flex-1 text-sm font-normal text-text-secondary\"\n >\n {option}\n </Label>\n <Input\n id={`${question.id}-${option}`}\n type=\"number\"\n min=\"0\"\n step=\"any\"\n inputMode=\"decimal\"\n className=\"w-40\"\n value={values[option] ?? ''}\n onChange={(event) => onChange(option, event.target.value)}\n placeholder=\"0\"\n />\n </div>\n ))}\n </div>\n\n <div className=\"rounded-xl border border-border-seam bg-bg-sunken/40 p-3\">\n <div className=\"flex flex-wrap items-baseline justify-between gap-2 text-sm\">\n <span className=\"text-text-secondary\">Allocated</span>\n <span className=\"font-semibold tabular-nums text-text-primary\">\n {formatCurrency(total, currency)} of {formatCurrency(pot, currency)}\n </span>\n </div>\n <div\n className=\"mt-2 h-2 w-full overflow-hidden rounded-full bg-bg-sunken\"\n role=\"progressbar\"\n aria-valuemin={0}\n aria-valuemax={pot}\n aria-valuenow={total}\n aria-label=\"Budget allocated\"\n >\n <div\n className={cn(\n 'h-full rounded-full transition-[width] duration-200',\n overAllocated\n ? 'bg-status-error-bg'\n : settled\n ? 'bg-status-success-bg'\n : 'bg-action-primary-bg'\n )}\n style={{ width: `${filled}%` }}\n />\n </div>\n <p\n className={cn(\n 'mt-2 text-sm tabular-nums',\n overAllocated\n ? 'text-status-error-text'\n : settled\n ? 'text-status-success-text'\n : 'text-text-secondary'\n )}\n >\n {overAllocated\n ? `Over by ${formatCurrency(Math.abs(remaining), currency)} — reduce an allocation to continue.`\n : settled\n ? 'The full pot is allocated.'\n : `${formatCurrency(remaining, currency)} still to allocate.`}\n </p>\n </div>\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;;AAsDA,IAAM,IAAqB,IAIrB,IAAoD;CACxD,MAAM;CACN,UAAU;CACV,SAAS;CACT,UAAU;AACZ;AASA,SAAgB,EAA8B,EAC5C,iBACA,YACA,kBACmD;CACnD,IAAM,IAAY,QACV,EAA2B,EAAa,SAAS,GACvD,CAAC,EAAa,SAAS,CACzB,GAGM,CAAC,GAAc,KAAmB,EAAiC,CAAC,CAAC,GACrE,CAAC,GAAa,KAAkB,EAAmC,CAAC,CAAC,GACrE,CAAC,GAAc,KAAmB,EAAiD,CAAC,CAAC,GACrF,CAAC,GAAW,KAAgB,EAAS,EAAK,GAC1C,CAAC,GAAW,KAAgB,EAA0B,MAAM,GAC5D,CAAC,GAAO,KAAY,EAAwB,IAAI,GAEhD,IAAiB,EAAiC,GAClD,IAAM,EAAa,gBAAgB,MACnC,IAAW,EAAa,cAExB,KAAa,GAAoB,MAAwB;EAC7D,GAAiB,OAAa;GAAE,GAAG;IAAU,IAAa;EAAM,EAAE;CACpE,GAEM,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IAAI,GAAG,EAAS,GAAG,GAAG;KACtB,MAAK;KACL,KAAI;KACJ,MAAK;KACL,WAAU;KACV,WAAU;KACV,OAAO,EAAO,MAAW;KACzB,WAAW,MAAU,EAAS,GAAQ,EAAM,OAAO,KAAK;KACxD,aAAY;IACb,CAAA,CACE;MAlBK,CAkBL,CACN;EACE,CAAA,GAEL,kBAAC,OAAD;GAAK,WAAU;aAAf;IACE,kBAAC,OAAD;KAAK,WAAU;eAAf,CACE,kBAAC,QAAD;MAAM,WAAU;gBAAsB;KAAe,CAAA,GACrD,kBAAC,QAAD;MAAM,WAAU;gBAAhB;OACG,EAAe,GAAO,CAAQ;OAAE;OAAK,EAAe,GAAK,CAAQ;MAC9D;OACH;;IACL,kBAAC,OAAD;KACE,WAAU;KACV,MAAK;KACL,iBAAe;KACf,iBAAe;KACf,iBAAe;KACf,cAAW;eAEX,kBAAC,OAAD;MACE,WAAW,EACT,uDACA,IACI,uBACA,IACE,yBACA,sBACR;MACA,OAAO,EAAE,OAAO,GAAG,EAAO,GAAG;KAC9B,CAAA;IACE,CAAA;IACL,kBAAC,KAAD;KACE,WAAW,EACT,6BACA,IACI,2BACA,IACE,6BACA,qBACR;eAEC,IACG,WAAW,EAAe,KAAK,IAAI,CAAS,GAAG,CAAQ,EAAE,wCACzD,IACE,+BACA,GAAG,EAAe,GAAW,CAAQ,EAAE;IAC5C,CAAA;GACA;IACF;;AAET"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConsultationResultsPanel.d.ts","sourceRoot":"","sources":["../../../../src/govcitizenhub/pages/intelligence/ConsultationResultsPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAgB,MAAM,OAAO,CAAC;AAqB9C,OAAO,KAAK,EAAE,eAAe,EAAiC,MAAM,aAAa,CAAC;AAKlF,MAAM,WAAW,6BAA6B;IAC5C,YAAY,EAAE,eAAe,CAAC;CAC/B;AAED,eAAO,MAAM,wBAAwB,EAAE,EAAE,CAAC,6BAA6B,
|
|
1
|
+
{"version":3,"file":"ConsultationResultsPanel.d.ts","sourceRoot":"","sources":["../../../../src/govcitizenhub/pages/intelligence/ConsultationResultsPanel.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,OAAO,KAAK,EAAE,EAAE,EAAgB,MAAM,OAAO,CAAC;AAqB9C,OAAO,KAAK,EAAE,eAAe,EAAiC,MAAM,aAAa,CAAC;AAKlF,MAAM,WAAW,6BAA6B;IAC5C,YAAY,EAAE,eAAe,CAAC;CAC/B;AAED,eAAO,MAAM,wBAAwB,EAAE,EAAE,CAAC,6BAA6B,CAqFtE,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConsultationResultsPanel.js","names":[],"sources":["../../../../src/govcitizenhub/pages/intelligence/ConsultationResultsPanel.tsx"],"sourcesContent":["/**\n * ConsultationResultsPanel — the publishable aggregate for one consultation.\n * @module govcitizenhub/pages/intelligence\n *\n * Reads `govConsultationResults`, which publishes AGGREGATES ONLY: option\n * counts, a rating distribution and mean, a free-text answered-count (never the\n * text) and mean budget allocations.\n *\n * Suppression is a first-class state, not an empty chart. The service returns\n * `isSuppressed: true` with NO aggregates in two cases — the consultation has\n * not closed yet, or too few people have responded for the aggregate to be\n * non-identifying. This panel says which of the two it is and shows the real\n * response count, instead of rendering empty axes that would read as \"nobody\n * agreed with anything\".\n */\n\nimport type { FC, ReactElement } from 'react';\nimport { BarChart3, EyeOff, Lock } from 'lucide-react';\n\nimport { EmptyState } from '../../components/EmptyState';\nimport { ErrorView, LoadingView } from '../../components/StateViews';\nimport {\n CHART_SERIES_COLORS,\n ChartLegend,\n GovBarChart,\n GovDonutChart,\n type ChartLegendItem,\n} from '../../components/GovCharts';\nimport {\n readAggregateNumber,\n readCountMap,\n readNumericBuckets,\n QUESTION_TYPE_LABELS,\n CONSULTATION_QUESTION_TYPES,\n} from './consultationQuestions';\nimport { useGovConsultationResults } from '../../hooks';\nimport { formatCurrency, formatDateTime, formatNumber } from '../../utils/formatters';\nimport type { GovConsultation, GovConsultationQuestionResult } from '../../types';\n\n/** Statuses whose aggregate the service will compute at all. */\nconst RESULT_READABLE_STATUSES = new Set(['CLOSED', 'PUBLISHED']);\n\nexport interface ConsultationResultsPanelProps {\n consultation: GovConsultation;\n}\n\nexport const ConsultationResultsPanel: FC<ConsultationResultsPanelProps> = ({ consultation }) => {\n const { data, isLoading, isError, refetch } = useGovConsultationResults(consultation.id);\n\n if (isLoading) {\n return <LoadingView label=\"Loading results…\" className=\"min-h-[12rem]\" />;\n }\n\n if (isError) {\n return (\n <ErrorView\n className=\"min-h-[12rem]\"\n message=\"We couldn't load the results for this consultation.\"\n onRetry={() => {\n void refetch();\n }}\n />\n );\n }\n\n if (!data) {\n return (\n <EmptyState\n icon={<BarChart3 className=\"size-8\" aria-hidden=\"true\" />}\n title=\"No result set yet\"\n description=\"This consultation has no computed results.\"\n />\n );\n }\n\n if (data.isSuppressed) {\n const notClosedYet = !RESULT_READABLE_STATUSES.has(data.status);\n return (\n <div className=\"rounded-xl border border-border-seam bg-bg-sunken/40 p-5\">\n <p className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n {notClosedYet ? (\n <Lock className=\"size-4 shrink-0 text-text-muted\" aria-hidden=\"true\" />\n ) : (\n <EyeOff className=\"size-4 shrink-0 text-text-muted\" aria-hidden=\"true\" />\n )}\n Results are withheld\n </p>\n <p className=\"mt-2 text-sm text-text-secondary\">\n {notClosedYet\n ? 'Aggregates are computed once the consultation closes, so nobody can watch the tally move while responses are still being collected.'\n : 'Too few responses have been received for the aggregate to be published: with a small number of respondents the totals themselves would identify who said what. Results are released once enough people have taken part.'}\n </p>\n <p className=\"mt-2 text-sm text-text-secondary tabular-nums\">\n {formatNumber(data.responseCount)} response\n {data.responseCount === 1 ? '' : 's'} received so far.\n </p>\n </div>\n );\n }\n\n return (\n <div className=\"flex flex-col gap-5\">\n <div className=\"flex flex-wrap items-center gap-x-6 gap-y-1 text-sm text-text-secondary\">\n <span className=\"tabular-nums\">\n <span className=\"font-semibold text-text-primary\">{formatNumber(data.responseCount)}</span>{' '}\n response{data.responseCount === 1 ? '' : 's'}\n </span>\n {data.resultsPublishedAt && (\n <span>Published {formatDateTime(data.resultsPublishedAt)}</span>\n )}\n </div>\n\n {data.questions.length === 0 ? (\n <EmptyState\n icon={<BarChart3 className=\"size-8\" aria-hidden=\"true\" />}\n title=\"Nothing to aggregate\"\n description=\"The published result set carries no questions.\"\n />\n ) : (\n data.questions.map((question) => (\n <QuestionResult\n key={question.questionId}\n result={question}\n currency={consultation.currencyCode}\n />\n ))\n )}\n </div>\n );\n};\n\ninterface QuestionResultProps {\n result: GovConsultationQuestionResult;\n currency?: string | null;\n}\n\n/** One question's aggregate, rendered per its declared type. */\nfunction QuestionResult({ result, currency }: QuestionResultProps): ReactElement {\n const type = CONSULTATION_QUESTION_TYPES.find((candidate) => candidate === result.type);\n\n return (\n <section className=\"rounded-xl border border-border-seam bg-bg-surface p-4\">\n <header className=\"mb-3 flex flex-wrap items-baseline justify-between gap-2\">\n <h4 className=\"text-sm font-semibold text-text-primary\">{result.label}</h4>\n <span className=\"text-xs text-text-muted\">\n {type ? QUESTION_TYPE_LABELS[type] : result.type} ·{' '}\n <span className=\"tabular-nums\">{formatNumber(result.responseCount)}</span> answered\n </span>\n </header>\n\n {type === 'SINGLE_CHOICE' && <SingleChoiceResult result={result} />}\n {type === 'MULTI_CHOICE' && (\n <GovBarChart data={readCountMap(result.aggregate, 'counts')} height={220} />\n )}\n {type === 'RATING' && <RatingResult result={result} />}\n {type === 'TEXT' && <TextResult result={result} />}\n {type === 'BUDGET_ALLOCATION' && <BudgetResult result={result} currency={currency} />}\n {type === undefined && (\n <p className=\"text-sm text-text-muted\">\n This question uses a type this build does not know how to chart.\n </p>\n )}\n </section>\n );\n}\n\nfunction SingleChoiceResult({ result }: { result: GovConsultationQuestionResult }): ReactElement {\n const counts = readCountMap(result.aggregate, 'counts');\n const legend: ChartLegendItem[] = counts.map((entry, index) => ({\n label: entry.name,\n color: CHART_SERIES_COLORS[index % CHART_SERIES_COLORS.length],\n value: entry.value,\n }));\n\n return (\n <div className=\"grid gap-4 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)] sm:items-center\">\n <GovDonutChart\n data={counts.map((entry) => ({ name: entry.name, value: entry.value }))}\n height={200}\n centerValue={formatNumber(result.responseCount)}\n centerLabel=\"answered\"\n />\n <ChartLegend items={legend} />\n </div>\n );\n}\n\nfunction RatingResult({ result }: { result: GovConsultationQuestionResult }): ReactElement {\n const distribution = readNumericBuckets(result.aggregate, 'distribution');\n const mean = readAggregateNumber(result.aggregate, 'mean');\n const min = readAggregateNumber(result.aggregate, 'min');\n const max = readAggregateNumber(result.aggregate, 'max');\n\n return (\n <div className=\"flex flex-col gap-3\">\n <div className=\"flex flex-wrap items-baseline gap-x-6 gap-y-1 text-sm text-text-secondary\">\n <span>\n Mean{' '}\n <span className=\"font-semibold tabular-nums text-text-primary\">\n {mean === null ? 'not available' : formatNumber(mean)}\n </span>\n </span>\n {min !== null && max !== null && (\n <span className=\"tabular-nums\">\n Scale {formatNumber(min)}–{formatNumber(max)}\n </span>\n )}\n </div>\n <GovBarChart data={distribution} height={200} emptyLabel=\"No ratings recorded\" />\n </div>\n );\n}\n\nfunction TextResult({ result }: { result: GovConsultationQuestionResult }): ReactElement {\n const answered = readAggregateNumber(result.aggregate, 'answeredCount');\n\n return (\n <div className=\"rounded-lg border border-border-seam bg-bg-sunken/40 p-3\">\n <p className=\"text-sm text-text-secondary tabular-nums\">\n <span className=\"font-semibold text-text-primary\">\n {answered === null ? '—' : formatNumber(answered)}\n </span>{' '}\n free-text answer{answered === 1 ? '' : 's'} received.\n </p>\n <p className=\"mt-1 text-xs text-text-muted\">\n The text itself is never published — respondents wrote it for their government, not for the\n public record.\n </p>\n </div>\n );\n}\n\nfunction BudgetResult({\n result,\n currency,\n}: {\n result: GovConsultationQuestionResult;\n currency?: string | null;\n}): ReactElement {\n const meanAllocation = readCountMap(result.aggregate, 'meanAllocation');\n const totalPot = readAggregateNumber(result.aggregate, 'totalPot');\n const legend: ChartLegendItem[] = meanAllocation.map((entry, index) => ({\n label: entry.name,\n color: CHART_SERIES_COLORS[index % CHART_SERIES_COLORS.length],\n value: formatCurrency(entry.value, currency),\n }));\n\n return (\n <div className=\"flex flex-col gap-3\">\n {totalPot !== null && (\n <p className=\"text-sm text-text-secondary\">\n Average allocation per respondent of a{' '}\n <span className=\"font-semibold text-text-primary\">\n {formatCurrency(totalPot, currency)}\n </span>{' '}\n pot.\n </p>\n )}\n <GovBarChart data={meanAllocation} height={200} emptyLabel=\"No allocations recorded\" />\n <ChartLegend items={legend} />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAwCA,IAAM,IAA2B,IAAI,IAAI,CAAC,UAAU,WAAW,CAAC,GAMnD,KAA+D,EAAE,sBAAmB;CAC/F,IAAM,EAAE,SAAM,cAAW,YAAS,eAAY,EAA0B,EAAa,EAAE;CAEvF,IAAI,GACF,OAAO,kBAAC,GAAD;EAAa,OAAM;EAAmB,WAAU;CAAiB,CAAA;CAG1E,IAAI,GACF,OACE,kBAAC,GAAD;EACE,WAAU;EACV,SAAQ;EACR,eAAe;GACb,EAAa;EACf;CACD,CAAA;CAIL,IAAI,CAAC,GACH,OACE,kBAAC,GAAD;EACE,MAAM,kBAAC,GAAD;GAAW,WAAU;GAAS,eAAY;EAAQ,CAAA;EACxD,OAAM;EACN,aAAY;CACb,CAAA;CAIL,IAAI,EAAK,cAAc;EACrB,IAAM,IAAe,CAAC,EAAyB,IAAI,EAAK,MAAM;EAC9D,OACE,kBAAC,OAAD;GAAK,WAAU;aAAf;IACE,kBAAC,KAAD;KAAG,WAAU;eAAb,CAEI,EADD,IACE,IAEA,GAFD;MAAM,WAAU;MAAkC,eAAY;KAAQ,CAEE,GACxE,sBAED;;IACH,kBAAC,KAAD;KAAG,WAAU;eACV,IACG,wIAC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AAG;KAAE;KAAE,EAAa,CAAG;IACvC;KAEL;MACL,kBAAC,GAAD;GAAa,MAAM;GAAc,QAAQ;GAAK,YAAW;EAAuB,CAAA,CAC7E;;AAET;AAEA,SAAS,EAAW,EAAE,aAAmE;CACvF,IAAM,IAAW,EAAoB,EAAO,WAAW,eAAe;CAEtE,OACE,kBAAC,OAAD;EAAK,WAAU;YAAf,CACE,kBAAC,KAAD;GAAG,WAAU;aAAb;IACE,kBAAC,QAAD;KAAM,WAAU;eACb,MAAa,OAAO,MAAM,EAAa,CAAQ;IAC5C,CAAA;IAAE;IAAI;IACK,MAAa,IAAI,KAAK;IAAI;GAC1C;MACH,kBAAC,KAAD;GAAG,WAAU;aAA+B;EAGzC,CAAA,CACA;;AAET;AAEA,SAAS,EAAa,EACpB,WACA,eAIe;CACf,IAAM,IAAiB,EAAa,EAAO,WAAW,gBAAgB,GAChE,IAAW,EAAoB,EAAO,WAAW,UAAU,GAC3D,IAA4B,EAAe,KAAK,GAAO,OAAW;EACtE,OAAO,EAAM;EACb,OAAO,EAAoB,IAAQ,EAAoB;EACvD,OAAO,EAAe,EAAM,OAAO,CAAQ;CAC7C,EAAE;CAEF,OACE,kBAAC,OAAD;EAAK,WAAU;YAAf;GACG,MAAa,QACZ,kBAAC,KAAD;IAAG,WAAU;cAAb;KAA2C;KACF;KACvC,kBAAC,QAAD;MAAM,WAAU;gBACb,EAAe,GAAU,CAAQ;KAC9B,CAAA;KAAE;KAAI;IAEX;;GAEL,kBAAC,GAAD;IAAa,MAAM;IAAgB,QAAQ;IAAK,YAAW;GAA2B,CAAA;GACtF,kBAAC,GAAD,EAAa,OAAO,EAAS,CAAA;EAC1B;;AAET"}
|
|
1
|
+
{"version":3,"file":"ConsultationResultsPanel.js","names":[],"sources":["../../../../src/govcitizenhub/pages/intelligence/ConsultationResultsPanel.tsx"],"sourcesContent":["/**\n * ConsultationResultsPanel — the publishable aggregate for one consultation.\n * @module govcitizenhub/pages/intelligence\n *\n * Reads `govConsultationResults`, which publishes AGGREGATES ONLY: option\n * counts, a rating distribution and mean, a free-text answered-count (never the\n * text) and mean budget allocations.\n *\n * Suppression is a first-class state, not an empty chart. The service returns\n * `isSuppressed: true` with NO aggregates in two cases — the consultation has\n * not closed yet, or too few people have responded for the aggregate to be\n * non-identifying. This panel says which of the two it is and shows the real\n * response count, instead of rendering empty axes that would read as \"nobody\n * agreed with anything\".\n */\n\nimport type { FC, ReactElement } from 'react';\nimport { BarChart3, EyeOff, Lock } from 'lucide-react';\n\nimport { EmptyState } from '../../components/EmptyState';\nimport { ErrorView, LoadingView } from '../../components/StateViews';\nimport {\n CHART_SERIES_COLORS,\n ChartLegend,\n GovBarChart,\n GovDonutChart,\n type ChartLegendItem,\n} from '../../components/GovCharts';\nimport {\n readAggregateNumber,\n readCountMap,\n readNumericBuckets,\n QUESTION_TYPE_LABELS,\n CONSULTATION_QUESTION_TYPES,\n} from './consultationQuestions';\nimport { useGovConsultationResults } from '../../hooks';\nimport { formatCurrency, formatDateTime, formatNumber } from '../../utils/formatters';\nimport type { GovConsultation, GovConsultationQuestionResult } from '../../types';\n\n/** Statuses whose aggregate the service will compute at all. */\nconst RESULT_READABLE_STATUSES = new Set(['CLOSED', 'PUBLISHED']);\n\nexport interface ConsultationResultsPanelProps {\n consultation: GovConsultation;\n}\n\nexport const ConsultationResultsPanel: FC<ConsultationResultsPanelProps> = ({ consultation }) => {\n const { data, isLoading, isError, refetch } = useGovConsultationResults(consultation.id);\n\n if (isLoading) {\n return <LoadingView label=\"Loading results…\" className=\"min-h-[12rem]\" />;\n }\n\n if (isError) {\n return (\n <ErrorView\n className=\"min-h-[12rem]\"\n message=\"We couldn't load the results for this consultation.\"\n onRetry={() => {\n void refetch();\n }}\n />\n );\n }\n\n if (!data) {\n return (\n <EmptyState\n icon={<BarChart3 className=\"size-8\" aria-hidden=\"true\" />}\n title=\"No result set yet\"\n description=\"This consultation has no computed results.\"\n />\n );\n }\n\n if (data.isSuppressed) {\n const notClosedYet = !RESULT_READABLE_STATUSES.has(data.status);\n return (\n <div className=\"rounded-xl border border-border-seam bg-bg-sunken/40 p-5\">\n <p className=\"flex items-center gap-2 text-sm font-semibold text-text-primary\">\n {notClosedYet ? (\n <Lock className=\"size-4 shrink-0 text-text-muted\" aria-hidden=\"true\" />\n ) : (\n <EyeOff className=\"size-4 shrink-0 text-text-muted\" aria-hidden=\"true\" />\n )}\n Results are withheld\n </p>\n <p className=\"mt-2 text-sm text-text-secondary\">\n {notClosedYet\n ? 'Aggregates are computed once the consultation closes, so nobody can watch the tally move while responses are still being collected.'\n : 'Too few responses have been received for the aggregate to be published: with a small number of respondents the totals themselves would identify who said what. Results are released once enough people have taken part.'}\n </p>\n <p className=\"mt-2 text-sm text-text-secondary tabular-nums\">\n {formatNumber(data.responseCount)} response\n {data.responseCount === 1 ? '' : 's'} received so far.\n </p>\n </div>\n );\n }\n\n return (\n <div className=\"flex flex-col gap-5\">\n <div className=\"flex flex-wrap items-center gap-x-6 gap-y-1 text-sm text-text-secondary\">\n <span className=\"tabular-nums\">\n <span className=\"font-semibold text-text-primary\">\n {formatNumber(data.responseCount)}\n </span>{' '}\n response{data.responseCount === 1 ? '' : 's'}\n </span>\n {data.resultsPublishedAt && (\n <span>Published {formatDateTime(data.resultsPublishedAt)}</span>\n )}\n </div>\n\n {data.questions.length === 0 ? (\n <EmptyState\n icon={<BarChart3 className=\"size-8\" aria-hidden=\"true\" />}\n title=\"Nothing to aggregate\"\n description=\"The published result set carries no questions.\"\n />\n ) : (\n data.questions.map((question) => (\n <QuestionResult\n key={question.questionId}\n result={question}\n currency={consultation.currencyCode}\n />\n ))\n )}\n </div>\n );\n};\n\ninterface QuestionResultProps {\n result: GovConsultationQuestionResult;\n currency?: string | null;\n}\n\n/** One question's aggregate, rendered per its declared type. */\nfunction QuestionResult({ result, currency }: QuestionResultProps): ReactElement {\n const type = CONSULTATION_QUESTION_TYPES.find((candidate) => candidate === result.type);\n\n return (\n <section className=\"rounded-xl border border-border-seam bg-bg-surface p-4\">\n <header className=\"mb-3 flex flex-wrap items-baseline justify-between gap-2\">\n <h4 className=\"text-sm font-semibold text-text-primary\">{result.label}</h4>\n <span className=\"text-xs text-text-muted\">\n {type ? QUESTION_TYPE_LABELS[type] : result.type} ·{' '}\n <span className=\"tabular-nums\">{formatNumber(result.responseCount)}</span> answered\n </span>\n </header>\n\n {type === 'SINGLE_CHOICE' && <SingleChoiceResult result={result} />}\n {type === 'MULTI_CHOICE' && (\n <GovBarChart data={readCountMap(result.aggregate, 'counts')} height={220} />\n )}\n {type === 'RATING' && <RatingResult result={result} />}\n {type === 'TEXT' && <TextResult result={result} />}\n {type === 'BUDGET_ALLOCATION' && <BudgetResult result={result} currency={currency} />}\n {type === undefined && (\n <p className=\"text-sm text-text-muted\">\n This question uses a type this build does not know how to chart.\n </p>\n )}\n </section>\n );\n}\n\nfunction SingleChoiceResult({ result }: { result: GovConsultationQuestionResult }): ReactElement {\n const counts = readCountMap(result.aggregate, 'counts');\n const legend: ChartLegendItem[] = counts.map((entry, index) => ({\n label: entry.name,\n color: CHART_SERIES_COLORS[index % CHART_SERIES_COLORS.length],\n value: entry.value,\n }));\n\n return (\n <div className=\"grid gap-4 sm:grid-cols-[minmax(0,1fr)_minmax(0,1fr)] sm:items-center\">\n <GovDonutChart\n data={counts.map((entry) => ({ name: entry.name, value: entry.value }))}\n height={200}\n centerValue={formatNumber(result.responseCount)}\n centerLabel=\"answered\"\n />\n <ChartLegend items={legend} />\n </div>\n );\n}\n\nfunction RatingResult({ result }: { result: GovConsultationQuestionResult }): ReactElement {\n const distribution = readNumericBuckets(result.aggregate, 'distribution');\n const mean = readAggregateNumber(result.aggregate, 'mean');\n const min = readAggregateNumber(result.aggregate, 'min');\n const max = readAggregateNumber(result.aggregate, 'max');\n\n return (\n <div className=\"flex flex-col gap-3\">\n <div className=\"flex flex-wrap items-baseline gap-x-6 gap-y-1 text-sm text-text-secondary\">\n <span>\n Mean{' '}\n <span className=\"font-semibold tabular-nums text-text-primary\">\n {mean === null ? 'not available' : formatNumber(mean)}\n </span>\n </span>\n {min !== null && max !== null && (\n <span className=\"tabular-nums\">\n Scale {formatNumber(min)}–{formatNumber(max)}\n </span>\n )}\n </div>\n <GovBarChart data={distribution} height={200} emptyLabel=\"No ratings recorded\" />\n </div>\n );\n}\n\nfunction TextResult({ result }: { result: GovConsultationQuestionResult }): ReactElement {\n const answered = readAggregateNumber(result.aggregate, 'answeredCount');\n\n return (\n <div className=\"rounded-lg border border-border-seam bg-bg-sunken/40 p-3\">\n <p className=\"text-sm text-text-secondary tabular-nums\">\n <span className=\"font-semibold text-text-primary\">\n {answered === null ? '—' : formatNumber(answered)}\n </span>{' '}\n free-text answer{answered === 1 ? '' : 's'} received.\n </p>\n <p className=\"mt-1 text-xs text-text-muted\">\n The text itself is never published — respondents wrote it for their government, not for the\n public record.\n </p>\n </div>\n );\n}\n\nfunction BudgetResult({\n result,\n currency,\n}: {\n result: GovConsultationQuestionResult;\n currency?: string | null;\n}): ReactElement {\n const meanAllocation = readCountMap(result.aggregate, 'meanAllocation');\n const totalPot = readAggregateNumber(result.aggregate, 'totalPot');\n const legend: ChartLegendItem[] = meanAllocation.map((entry, index) => ({\n label: entry.name,\n color: CHART_SERIES_COLORS[index % CHART_SERIES_COLORS.length],\n value: formatCurrency(entry.value, currency),\n }));\n\n return (\n <div className=\"flex flex-col gap-3\">\n {totalPot !== null && (\n <p className=\"text-sm text-text-secondary\">\n Average allocation per respondent of a{' '}\n <span className=\"font-semibold text-text-primary\">\n {formatCurrency(totalPot, currency)}\n </span>{' '}\n pot.\n </p>\n )}\n <GovBarChart data={meanAllocation} height={200} emptyLabel=\"No allocations recorded\" />\n <ChartLegend items={legend} />\n </div>\n );\n}\n"],"mappings":";;;;;;;;;;AAwCA,IAAM,IAA2B,IAAI,IAAI,CAAC,UAAU,WAAW,CAAC,GAMnD,KAA+D,EAAE,sBAAmB;CAC/F,IAAM,EAAE,SAAM,cAAW,YAAS,eAAY,EAA0B,EAAa,EAAE;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AoB,IAAQ,EAAoB;EACvD,OAAO,EAAe,EAAM,OAAO,CAAQ;CAC7C,EAAE;CAEF,OACE,kBAAC,OAAD;EAAK,WAAU;YAAf;GACG,MAAa,QACZ,kBAAC,KAAD;IAAG,WAAU;cAAb;KAA2C;KACF;KACvC,kBAAC,QAAD;MAAM,WAAU;gBACb,EAAe,GAAU,CAAQ;KAC9B,CAAA;KAAE;KAAI;IAEX;;GAEL,kBAAC,GAAD;IAAa,MAAM;IAAgB,QAAQ;IAAK,YAAW;GAA2B,CAAA;GACtF,kBAAC,GAAD,EAAa,OAAO,EAAS,CAAA;EAC1B;;AAET"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ConsultationsPage.d.ts","sourceRoot":"","sources":["../../../../src/govcitizenhub/pages/intelligence/ConsultationsPage.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AA4G7D,wBAAgB,iBAAiB,IAAI,YAAY,
|
|
1
|
+
{"version":3,"file":"ConsultationsPage.d.ts","sourceRoot":"","sources":["../../../../src/govcitizenhub/pages/intelligence/ConsultationsPage.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAqB,KAAK,YAAY,EAAE,MAAM,OAAO,CAAC;AA4G7D,wBAAgB,iBAAiB,IAAI,YAAY,CAsShD"}
|