import React, { Fragment } from 'react';
import { Link, NavLink } from 'react-router-dom';
import Sidebar from './sidebar';
import Tooltip from './tooltip';
import InfoBox from './info-box';
import { EditIcon } from './icons';
import CONFIG from './fields-config.json';
const BuildingView = (props) => {
if (!props.building_id){
return (
Back to maps
);
}
const cat = get_cat(props.match.url);
return (
{
CONFIG.map(section_props => (
{
section_props.fields.map(field_props => {
return (field_props.slug === 'uprns')?
:
})
}
))
}
);
}
function get_cat(url) {
if (url === "/") {
return "age"
}
const matches = /^\/(view|edit)\/([^\/.]+)/.exec(url);
const cat = (matches && matches.length > 2)? matches[2] : "age";
return cat;
}
const DataSection = (props) => {
const match = props.cat === props.slug;
return (
match}>
{props.title}
{ match? {props.children}
: null }
);
}
const DataEntry = (props) => (
{ props.title }
{ props.tooltip? : null }
{(props.value != null)? props.value : '\u00A0'}
);
const UPRNsDataEntry = (props) => {
const uprns = props.value || [];
const no_parent = uprns.filter(uprn => uprn.parent_uprn == null);
const with_parent = uprns.filter(uprn => uprn.parent_uprn != null);
return (
{ props.title }
{ props.tooltip? : null }
{
no_parent.length?
no_parent.map(uprn => (
- {uprn.uprn}
))
: '\u00A0'
}
{
with_parent.length?
Children
{
with_parent.map(uprn => (
- {uprn.uprn} (child of {uprn.parent_uprn})
))
}
: null
}
)
}
export default BuildingView;