From dc49ff58338b4b88a8ac80988bfeca9434d04bbb Mon Sep 17 00:00:00 2001 From: Mateusz Konieczny Date: Thu, 3 Nov 2022 14:17:38 +0100 Subject: [PATCH] properly record how data is structured less likely to keep changing --- .../data-components/planning-data-entry.tsx | 18 +++++++++++++----- app/src/frontend/config/data-fields-config.ts | 6 +++++- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/app/src/frontend/building/data-components/planning-data-entry.tsx b/app/src/frontend/building/data-components/planning-data-entry.tsx index e5fab912..73982936 100644 --- a/app/src/frontend/building/data-components/planning-data-entry.tsx +++ b/app/src/frontend/building/data-components/planning-data-entry.tsx @@ -3,9 +3,18 @@ import React, { Fragment } from 'react'; import InfoBox from '../../components/info-box'; import CheckboxDataEntry from '../data-components/checkbox-data-entry'; - interface PlanningDataOfficialDataEntryProps { - value: any; // TODO: proper structuring! + value: { + uprn: string; + building_id: number; + description?: string; + planning_application_link?: string; + registered_with_local_authority_date?: string; + decision_date?: string; + last_synced_date?: string; + data_source: string; + data_source_link?: string; + }[]; } const {useState} = React; @@ -51,7 +60,6 @@ const LinkIfAvailable = (link) => { } const PlanningDataOfficialDataEntry: React.FC = (props) => { - const data = props.value || []; if(data.length == 0) { return ( @@ -62,7 +70,7 @@ const PlanningDataOfficialDataEntry: React.FC ); } - return (data.map((item) => ( + return <>{data.map((item) => ( @@ -82,7 +90,7 @@ const PlanningDataOfficialDataEntry: React.FC ) ) - ) + } }; export default PlanningDataOfficialDataEntry; diff --git a/app/src/frontend/config/data-fields-config.ts b/app/src/frontend/config/data-fields-config.ts index a15ccfc4..f45ef04d 100644 --- a/app/src/frontend/config/data-fields-config.ts +++ b/app/src/frontend/config/data-fields-config.ts @@ -50,6 +50,8 @@ export interface DataFieldDefinition { * * Making it semantically correct is useful but not necessary. * E.g. for building attachment form, you could use "Detached" as example + * + * This field is later processed by AttributesBasedOnExample */ example: any; @@ -174,7 +176,9 @@ export const dataFields = { /* eslint-disable @typescript-eslint/camelcase */ category: Category.Location, title: "PLANNING DATA", tooltip: "PLANNING DATA", - example: [{}], + example: [{uprn: "", building_id: 1, "data_source": ""}, + {uprn: "", building_id: 1, "data_source": "", decision_date: "", description: "", planning_application_link: "", registered_with_local_authority_date: "", last_synced_date: "", data_source_link: ""}, + ], },