import React, { Fragment } from 'react'; import InfoBox from '../../components/info-box'; import CheckboxDataEntry from '../data-components/checkbox-data-entry'; interface PlanningDataOfficialDataEntryProps { shownData: { uprn: string; building_id: number; status?: string, status_before_aliasing?: string, 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; address?: string; }[]; allEntryCount: number, } const {useState} = React; const LongText = ({ content,limit}) => { const [showAll, setShowAll] = useState(false); const showMore = () => setShowAll(true); const showLess = () => setShowAll(false); if (content == null) { return
{MissingData}
} if (content.length <= limit) { return
{content}
} if (showAll) { return
{content}
Shorten description
} const toShow = content.substring(0, limit).trim() + "... "; return
{toShow}
Show full description
} const Disclaimer = () => { return
Disclaimer: Not all applications for London are displayed. Some boroughs do not yet provide planning data to the GLA. For comprehensive information on applications please visit the relevant local authority's planning website.
} const MissingData = "not provided by data source" function ShowIfAvailable(data) { return <>{data ? data.toString() : MissingData } } const LinkIfAvailable = (link) => { return <>{link ? {link.toString()} : MissingData } } const StatusInfo = ({status, statusBeforeAliasing}) => { if(status == null) { return <>{LinkIfAvailable(null)} } if(status != statusBeforeAliasing) { return <>{status} - status in data source was: {statusBeforeAliasing} } return <>{status} } const PlanningDataOfficialDataEntry: React.FC = (props) => { const data = props.shownData || []; if(data.length == 0) { if (props.allEntryCount == 0) { return (
No live planning data available currently for this building polygon via the Planning London DataHub.
); } else { return (
No live planning data for this date range, but this building has associated planning data not shown here.
); } } return <>
{/* TODO: data[0] is problematic here... Compute it from listed elements and show all distinct variants? Error if they are not distinct? Hardcode it? */}
Planning application status is streamed using live data uploaded by local authorities to {data[0]["data_source_link"] ? {data[0]["data_source"]} : data[0]["data_source"] }.
{data.map((item) => (
Current planning application status for this site:
{item["status_explanation_note"] ?
Explanation: {item["status_explanation_note"]}
: <>}
Planning application ID: {ShowIfAvailable(item["planning_application_id"])}
Date registered by the planning authority (validation date): {ShowIfAvailable(item["registered_with_local_authority_date"])}
Decision date: {ShowIfAvailable(item["decision_date"])}
Planning application link: {LinkIfAvailable(item["planning_application_link"])}
Description of proposed work: {item["description"] ? : MissingData}
Address of the location as provided by local authority: {ShowIfAvailable(item["address"])}
Most recent update by data provider: {ShowIfAvailable(item["decision_date"])}
) ) } }; export default PlanningDataOfficialDataEntry;