From 8fb2e6f72353ebc1f97f180efe37cb07f82fe0de Mon Sep 17 00:00:00 2001 From: Jessica McInchak Date: Sun, 17 Nov 2024 12:20:20 +0100 Subject: [PATCH] fix build errors --- .../components/PlanningConstraints/Editor.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/editor.planx.uk/src/@planx/components/PlanningConstraints/Editor.tsx b/editor.planx.uk/src/@planx/components/PlanningConstraints/Editor.tsx index d147db4616..6f1215cdfe 100644 --- a/editor.planx.uk/src/@planx/components/PlanningConstraints/Editor.tsx +++ b/editor.planx.uk/src/@planx/components/PlanningConstraints/Editor.tsx @@ -42,10 +42,10 @@ function PlanningConstraintsComponent(props: Props) { }); const changeSelectAll = - (vals: string[]) => + (vals: string[] | undefined) => (_event: ChangeEvent, _checked: boolean) => { let newCheckedVals: string[]; - if (vals.length !== availableDatasets.length) { + if (vals?.length !== availableDatasets.length) { newCheckedVals = availableDatasets.map((d) => d.val); } else { newCheckedVals = []; @@ -58,12 +58,13 @@ function PlanningConstraintsComponent(props: Props) { (val: string) => (_event: ChangeEvent, _checked: boolean) => { let newCheckedVals; - if (formik.values.dataValues.includes(val)) { + if (formik.values.dataValues?.includes(val)) { newCheckedVals = formik.values.dataValues.filter((dv) => dv !== val); } else { - newCheckedVals = [...formik.values.dataValues, val]; + newCheckedVals = formik.values.dataValues + ? [...formik.values.dataValues, val] + : [val]; } - formik.setFieldValue("dataValues", newCheckedVals); }; @@ -122,7 +123,7 @@ function PlanningConstraintsComponent(props: Props) { color="primary" checked={ availableDatasets.length === - formik.values.dataValues.length + formik.values.dataValues?.length } onChange={changeSelectAll(formik.values.dataValues)} inputProps={{ @@ -143,7 +144,7 @@ function PlanningConstraintsComponent(props: Props) {