diff --git a/editor.planx.uk/src/@planx/components/List/Public/Fields.tsx b/editor.planx.uk/src/@planx/components/List/Public/Fields.tsx index 3b19862859..d4524c20e1 100644 --- a/editor.planx.uk/src/@planx/components/List/Public/Fields.tsx +++ b/editor.planx.uk/src/@planx/components/List/Public/Fields.tsx @@ -234,10 +234,7 @@ export const ChecklistFieldInput: React.FC> = (props) => { ); }; -export const DateFieldInput: React.FC> = ({ - id, - data, -}) => { +export const DateFieldInput: React.FC> = ({ id, data }) => { const { formik, activeIndex } = useListContext(); return ( @@ -247,7 +244,10 @@ export const DateFieldInput: React.FC> = ({ value={formik.values.userData[activeIndex][data.fn] as string} bordered onChange={(newDate: string, eventType: string) => { - formik.setFieldValue(`userData[${activeIndex}]['${data.fn}']`, paddedDate(newDate, eventType)); + formik.setFieldValue( + `userData[${activeIndex}]['${data.fn}']`, + paddedDate(newDate, eventType), + ); }} error={get(formik.errors, ["userData", activeIndex, data.fn])} id={id} @@ -267,7 +267,7 @@ export const MapFieldInput: React.FC> = (props) => { const teamSettings = useStore.getState().teamSettings; const passport = useStore((state) => state.computePassport()); - const [features, setFeatures] = useState(undefined); + const [_features, setFeatures] = useState(undefined); useEffect(() => { const geojsonChangeHandler = async ({ detail: geojson }: any) => { @@ -275,15 +275,14 @@ export const MapFieldInput: React.FC> = (props) => { setFeatures(geojson["EPSG:3857"].features); await formik.setFieldValue( `userData[${activeIndex}]['${fn}']`, - features, + geojson["EPSG:3857"].features, ); - console.log(features, formik); } else { // if the user clicks 'reset' on the map, geojson will be empty object, so set features to undefined setFeatures(undefined); await formik.setFieldValue( `userData[${activeIndex}]['${fn}']`, - features, + undefined, ); } }; @@ -328,5 +327,5 @@ export const MapFieldInput: React.FC> = (props) => { - ) + ); }; diff --git a/editor.planx.uk/src/@planx/components/List/model.ts b/editor.planx.uk/src/@planx/components/List/model.ts index abfb462456..baec5aa601 100644 --- a/editor.planx.uk/src/@planx/components/List/model.ts +++ b/editor.planx.uk/src/@planx/components/List/model.ts @@ -120,14 +120,14 @@ export const parseContent = (data: Record | undefined): List => ({ ...parseMoreInformation(data), }); -const mapValidationSchema = ({ drawMany }: MapField["data"]) => +const mapValidationSchema = ({ drawType }: MapField["data"]) => array() .required() .test({ name: "atLeastOneFeature", - message: "Add at least one feature to the map", + message: `Draw at least one ${drawType?.toLocaleLowerCase()} on the map`, test: (features?: Array) => { - return Boolean(drawMany && features && features?.length > 0); + return Boolean(features && features?.length > 0); }, });