colouring-montreal/app/src/frontend/building/building-view.tsx

54 lines
1.4 KiB
TypeScript
Raw Normal View History

import React from 'react';
import { useAuth } from '../auth-context';
2018-09-11 15:59:59 -04:00
import { categoriesConfig, Category } from '../config/categories-config';
import { categoryUiConfig } from '../config/category-ui-config';
import { Building, UserVerified } from '../models/building';
2019-08-14 06:36:38 -04:00
2019-11-07 02:39:26 -05:00
import BuildingNotFound from './building-not-found';
interface BuildingViewProps {
cat: Category;
mode: 'view' | 'edit';
building?: Building;
building_like?: boolean;
user_verified?: any;
onBuildingUpdate: (buildingId: number, updatedData: Building) => void;
onBuildingLikeUpdate: (buildingId: number, updatedData: boolean) => void;
onUserVerifiedUpdate: (buildingId: number, updatedData: UserVerified) => void;
}
2019-08-14 06:36:38 -04:00
/**
* Top-level container for building view/edit form
*
* @param props
*/
const BuildingView: React.FunctionComponent<BuildingViewProps> = (props) => {
const { user } = useAuth();
const DataContainer = categoryUiConfig[props.cat];
const categoryConfig = categoriesConfig[props.cat];
if(categoryConfig == undefined) {
return <BuildingNotFound mode="view" />;
}
const {
name,
aboutUrl,
intro,
inactive = false
} = categoryConfig;
return <DataContainer
{...props}
title={name}
help={aboutUrl}
intro={intro}
inactive={inactive}
user={user}
/>;
2019-11-07 03:13:30 -05:00
};
export default BuildingView;