From f54fcf0cc4b2d0d432e51b1245ab0d6dc2dcc576 Mon Sep 17 00:00:00 2001 From: Maciej Ziarkowski Date: Thu, 17 Oct 2019 17:38:44 +0100 Subject: [PATCH] Improve types for Building across app --- app/src/frontend/building/data-components/data-entry.tsx | 6 +++--- app/src/frontend/map-app.tsx | 7 ++++--- app/src/frontend/map/map.tsx | 3 ++- app/src/frontend/models/building.ts | 4 ++++ 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/app/src/frontend/building/data-components/data-entry.tsx b/app/src/frontend/building/data-components/data-entry.tsx index c554654a..fb35b842 100644 --- a/app/src/frontend/building/data-components/data-entry.tsx +++ b/app/src/frontend/building/data-components/data-entry.tsx @@ -8,9 +8,9 @@ interface BaseDataEntryProps { title: string; tooltip?: string; disabled?: boolean; - copy: any; // CopyProps clashes with propTypes - mode: 'view' | 'edit' | 'multi-edit'; - onChange: (key: string, value: any) => void; + copy?: any; // CopyProps clashes with propTypes + mode?: 'view' | 'edit' | 'multi-edit'; + onChange?: (key: string, value: any) => void; } interface DataEntryProps extends BaseDataEntryProps { diff --git a/app/src/frontend/map-app.tsx b/app/src/frontend/map-app.tsx index e3e62eb4..b6c756d3 100644 --- a/app/src/frontend/map-app.tsx +++ b/app/src/frontend/map-app.tsx @@ -9,6 +9,7 @@ import MultiEdit from './building/multi-edit'; import BuildingView from './building/building-view'; import ColouringMap from './map/map'; import { parse } from 'query-string'; +import { Building } from './models/building'; interface MapAppRouteParams { mode: 'view' | 'edit' | 'multi-edit'; @@ -17,7 +18,7 @@ interface MapAppRouteParams { } interface MapAppProps extends RouteComponentProps { - building: any; + building: Building; building_like: boolean; user: any; } @@ -25,7 +26,7 @@ interface MapAppProps extends RouteComponentProps { interface MapAppState { category: string; revision_id: number; - building: any; + building: Building; building_like: boolean; } @@ -76,7 +77,7 @@ class MapApp extends React.Component { } } - selectBuilding(building) { + selectBuilding(building: Building) { const mode = this.props.match.params.mode || 'view'; const category = this.props.match.params.category || 'age'; diff --git a/app/src/frontend/map/map.tsx b/app/src/frontend/map/map.tsx index 90f99c64..d2782320 100644 --- a/app/src/frontend/map/map.tsx +++ b/app/src/frontend/map/map.tsx @@ -11,11 +11,12 @@ import Legend from './legend'; import { parseCategoryURL } from '../../parse'; import SearchBox from './search-box'; import ThemeSwitcher from './theme-switcher'; +import { Building } from '../models/building'; const OS_API_KEY = 'NVUxtY5r8eA6eIfwrPTAGKrAAsoeI9E9'; interface ColouringMapProps { - building: any; + building: Building; mode: 'basic' | 'view' | 'edit' | 'multi-edit'; category: string; revision_id: number; diff --git a/app/src/frontend/models/building.ts b/app/src/frontend/models/building.ts index ddad22e9..5b81ed05 100644 --- a/app/src/frontend/models/building.ts +++ b/app/src/frontend/models/building.ts @@ -1,5 +1,9 @@ interface Building { building_id: number; + geometry_id: number; + revision_id: number; + + uprns: string[]; // TODO: add other fields as needed }