properly record how data is structured

less likely to keep changing
This commit is contained in:
Mateusz Konieczny 2022-11-03 14:17:38 +01:00
parent f2078aecb0
commit dc49ff5833
2 changed files with 18 additions and 6 deletions

View File

@ -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<PlanningDataOfficialDataEntryProps> = (props) => {
const data = props.value || [];
if(data.length == 0) {
return (<Fragment>
@ -62,7 +70,7 @@ const PlanningDataOfficialDataEntry: React.FC<PlanningDataOfficialDataEntryProps
</InfoBox>
</Fragment>);
}
return (data.map((item) => (
return <>{data.map((item) => (
<Fragment>
<InfoBox type='success'>
<Fragment>
@ -82,7 +90,7 @@ const PlanningDataOfficialDataEntry: React.FC<PlanningDataOfficialDataEntryProps
</Fragment>
)
)
)
}</>
};
export default PlanningDataOfficialDataEntry;

View File

@ -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: ""},
],
},