import React, { Fragment } from 'react'; import { Link } from 'react-router-dom'; import InfoBox from '../../components/info-box'; import CheckboxDataEntry from '../data-components/checkbox-data-entry'; import NumericDataEntryWithFormattedLink from '../data-components/numeric-data-entry-with-formatted-link'; import { buildingUserFields, dataFields } from '../../config/data-fields-config'; import NumericDataEntry from '../data-components/numeric-data-entry'; import UserOpinionEntry from '../data-components/user-opinion-data-entry'; import DataEntry from '../data-components/data-entry'; import { DataEntryGroup } from '../data-components/data-entry-group'; import SelectDataEntry from '../data-components/select-data-entry'; import Verification from '../data-components/verification'; import withCopyEdit from '../data-container'; import PlanningDataOfficialDataEntry from '../data-components/planning-data-entry'; import DataTitle from '../data-components/data-title'; import { CategoryViewProps } from './category-view-props'; import { Category } from '../../config/categories-config'; const currentYear = new Date().getFullYear(); const currentTimestamp = new Date().valueOf(); const milisecondsInYear = 1000 * 60 * 60 * 24 * 365; // TODO: there is already "parseDate" in helpers function parseDate(isoUtcDate: string): Date { const [year, month, day] = isoUtcDate.match(/^(\d{4})-(\d\d)-(\d\d)$/) .splice(1) .map(x => parseInt(x, 10)); return new Date(Date.UTC(year, month-1, day)); } function isArchived(item) { const decisionDate = item.decision_date; if(decisionDate != null) { if ((currentTimestamp - parseDate(decisionDate).valueOf()) > milisecondsInYear) { return true; } } if(item.registered_with_local_authority_date != null) { if ((currentTimestamp - parseDate(item.registered_with_local_authority_date).valueOf()) > milisecondsInYear) { return true; } } return false; } const PlanningView: React.FunctionComponent = (props) => { const communityLinkUrl = `/${props.mode}/${Category.Community}/${props.building.building_id}`; return ( This section is under development as part of the project CLPV Tool. For more details and progress read here. isArchived(item) == false) : []} allEntryCount={props.building.planning_data ? props.building.planning_data.length : 0} /> isArchived(item)) : []} allEntryCount={props.building.planning_data ? props.building.planning_data.length : 0} /> { return "https://historicengland.org.uk/listing/the-list/list-entry/" + id + "?section=official-list-entry" } } linkDescriptionFunction={(id: String) => { return "ID Link" } } /> { return "https://whc.unesco.org/en/list/" + id } } linkDescriptionFunction={(id: String) => { return "ID Link" } } /> )}; const PlanningContainer = withCopyEdit(PlanningView); export default PlanningContainer;