2022-10-05 13:52:14 -04:00
import React , { Fragment } from 'react' ;
import InfoBox from '../../components/info-box' ;
import CheckboxDataEntry from '../data-components/checkbox-data-entry' ;
interface PlanningDataOfficialDataEntryProps {
2022-11-04 06:37:13 -04:00
shownData : {
2022-11-03 09:17:38 -04:00
uprn : string ;
building_id : number ;
2022-11-05 04:11:25 -04:00
status? : string ,
2022-11-05 05:06:10 -04:00
status_before_aliasing? : string ,
2022-11-03 09:17:38 -04:00
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 ;
2022-11-23 02:59:10 -05:00
address? : string ;
2022-11-03 09:17:38 -04:00
} [ ] ;
2022-11-04 06:37:13 -04:00
allEntryCount : number ,
2022-10-05 13:52:14 -04:00
}
const { useState } = React ;
const LongText = ( { content , limit } ) = > {
const [ showAll , setShowAll ] = useState ( false ) ;
const showMore = ( ) = > setShowAll ( true ) ;
const showLess = ( ) = > setShowAll ( false ) ;
2022-10-31 03:49:13 -04:00
if ( content == null ) {
return < div > { MissingData } < / div >
}
2022-10-05 13:52:14 -04:00
if ( content . length <= limit ) {
return < div > { content } < / div >
}
if ( showAll ) {
return < div >
{ content }
2022-08-29 07:28:06 -04:00
< br / >
< b onClick = { showLess } > Shorten description < / b >
2022-10-05 13:52:14 -04:00
< / div >
}
const toShow = content . substring ( 0 , limit ) . trim ( ) + "... " ;
return < div >
{ toShow }
2022-08-29 07:28:06 -04:00
< br / >
< b onClick = { showMore } > Show full description < / b >
2022-10-05 13:52:14 -04:00
< / div >
}
2022-12-08 13:33:40 -05:00
const Disclaimer = ( ) = > { return < Fragment > < i > < div > < u > Disclaimer < / u > : 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 . < / div > < / i > < / Fragment > }
2022-08-30 06:25:20 -04:00
2022-10-31 07:34:19 -04:00
const MissingData = "not provided by data source"
2022-10-31 03:49:13 -04:00
function ShowIfAvailable ( data ) {
return < > { data ? data . toString ( ) : MissingData } < / >
}
2022-10-31 05:32:37 -04:00
const LinkIfAvailable = ( link ) = > {
return < > { link ? < a href = { link . toString ( ) } > { link . toString ( ) } < / a > : MissingData } < / >
}
2022-11-05 05:06:10 -04:00
const StatusInfo = ( { status , statusBeforeAliasing } ) = > {
if ( status == null ) {
2022-11-07 04:03:29 -05:00
return < > { LinkIfAvailable ( null ) } < / >
2022-11-05 05:06:10 -04:00
}
if ( status != statusBeforeAliasing ) {
2022-11-23 04:04:46 -05:00
return < > { status } - status in data source was : { statusBeforeAliasing } < / >
2022-11-05 05:06:10 -04:00
}
2022-11-07 04:03:29 -05:00
return < > { status } < / >
2022-11-05 05:06:10 -04:00
}
2022-10-05 13:52:14 -04:00
const PlanningDataOfficialDataEntry : React.FC < PlanningDataOfficialDataEntryProps > = ( props ) = > {
2022-11-04 06:37:13 -04:00
const data = props . shownData || [ ] ;
2022-10-05 13:52:14 -04:00
if ( data . length == 0 ) {
2022-11-04 06:37:13 -04:00
if ( props . allEntryCount == 0 ) {
2022-10-05 13:52:14 -04:00
return ( < Fragment >
2022-12-08 14:11:00 -05:00
< div className = { ` alert alert-dark ` } role = "alert" style = { { fontSize : 13 , backgroundColor : "#f6f8f9" } } >
2022-11-29 05:28:04 -05:00
< Disclaimer / >
2022-12-08 12:19:03 -05:00
< / div >
2022-12-07 11:15:57 -05:00
< InfoBox type = 'success' >
2022-11-29 05:03:34 -05:00
No live planning data available currently for this building polygon via the Planning London DataHub .
2022-10-05 13:52:14 -04:00
< / InfoBox >
< / Fragment > ) ;
2022-11-04 06:37:13 -04:00
} else {
return ( < Fragment >
2022-12-08 14:11:00 -05:00
< div className = { ` alert alert-dark ` } role = "alert" style = { { fontSize : 13 , backgroundColor : "#f6f8f9" } } >
2022-11-29 05:28:04 -05:00
< Disclaimer / >
2022-12-08 12:19:03 -05:00
< / div >
2022-12-07 11:15:57 -05:00
< InfoBox type = 'success' >
2022-11-29 05:03:34 -05:00
No live planning data for this date range , but this building has associated planning data now shown here .
2022-11-04 06:37:13 -04:00
< / InfoBox >
< / Fragment > ) ;
2022-10-05 13:52:14 -04:00
}
2022-11-04 06:37:13 -04:00
}
2022-11-29 05:28:04 -05:00
return < >
2022-12-07 11:15:57 -05:00
< InfoBox type = 'info' >
2022-12-07 11:17:10 -05:00
To see planning applications visualised for different periods click on the map key dropdown .
2022-12-07 08:12:55 -05:00
< / InfoBox >
2022-12-08 14:11:00 -05:00
< div className = { ` alert alert-dark ` } role = "alert" style = { { fontSize : 13 , backgroundColor : "#f6f8f9" } } >
2022-12-06 11:31:56 -05:00
{ /* TODO: data[0] is problematic here... Compute it from listed elements and show all distinct variants? Error if they are not distinct? Hardcode it? */ }
< div >
Planning application status is streamed using live data uploaded by local authorities to { data [ 0 ] [ "data_source_link" ] ? < a href = { data [ 0 ] [ "data_source_link" ] } > { data [ 0 ] [ "data_source" ] } < / a > : data [ 0 ] [ "data_source" ] } .
< / div >
2022-11-29 05:28:04 -05:00
< Disclaimer / >
2022-12-08 12:19:03 -05:00
< / div >
2022-11-29 05:28:04 -05:00
{ data . map ( ( item ) = > (
2022-10-05 13:52:14 -04:00
< Fragment >
2022-12-07 11:15:57 -05:00
< InfoBox type = 'success' >
2022-09-14 06:57:47 -04:00
< Fragment >
2022-11-05 05:06:10 -04:00
< div > < b > Current planning application status for this site : < / b > < StatusInfo
statusBeforeAliasing = { item [ "status_before_aliasing" ] }
status = { item [ "status" ] }
/ > < / d i v >
2022-11-13 03:01:34 -05:00
{ item [ "status_explanation_note" ] ? < div > < b > Explanation < / b > : { item [ "status_explanation_note" ] } < / div > : < > < / > }
2022-10-31 05:20:41 -04:00
< div > < b > Planning application ID : < / b > { ShowIfAvailable ( item [ "planning_application_id" ] ) } < / div >
< div > < b > Date registered by the planning authority ( validation date ) < / b > : { ShowIfAvailable ( item [ "registered_with_local_authority_date" ] ) } < / div >
< div > < b > Decision date < / b > : { ShowIfAvailable ( item [ "decision_date" ] ) } < / div >
2022-10-31 05:32:37 -04:00
< div > < b > Planning application link < / b > : { LinkIfAvailable ( item [ "planning_application_link" ] ) } < / div >
2022-10-31 05:20:41 -04:00
< div > < b > Description of proposed work < / b > : { item [ "description" ] ? < LongText content = { item [ "description" ] } limit = { 400 } / > : MissingData } < / div >
2022-12-02 09:39:20 -05:00
< div > < b > Address of the location as provided by local authority : < / b > { ShowIfAvailable ( item [ "address" ] ) } < / div >
2022-10-31 05:20:41 -04:00
< div > < b > Most recent update by data provider : < / b > { ShowIfAvailable ( item [ "decision_date" ] ) } < / div >
2022-09-15 07:34:09 -04:00
< / Fragment >
< / InfoBox >
2022-10-05 13:52:14 -04:00
< / Fragment >
2022-10-31 05:20:41 -04:00
)
)
2022-11-03 09:17:38 -04:00
} < / >
2022-10-05 13:52:14 -04:00
} ;
export default PlanningDataOfficialDataEntry ;