colouring-montreal/app/src/frontend/building/multi-edit.tsx

53 lines
1.9 KiB
TypeScript
Raw Normal View History

import React from 'react';
import { Link } from 'react-router-dom';
2019-05-09 04:16:36 -04:00
import { useMultiEditData } from '../hooks/use-multi-edit-data';
2019-11-26 07:09:27 -05:00
import ErrorBox from '../components/error-box';
import InfoBox from '../components/info-box';
import { allFieldsConfig } from '../config/data-fields-config';
2019-05-09 04:16:36 -04:00
2019-11-07 02:39:26 -05:00
import DataEntry from './data-components/data-entry';
2019-11-26 07:09:27 -05:00
interface MultiEditProps {
category: string;
}
const MultiEdit: React.FC<MultiEditProps> = (props) => {
const [data, error] = useMultiEditData();
2019-05-09 04:16:36 -04:00
return (
<section className='data-section'>
<header className={`section-header view ${props.category} background-${props.category}`}>
<h2 className="h2">Paste {props.category} data</h2>
</header>
<div className="section-body">
<form>
2019-11-26 07:09:27 -05:00
{
error ?
<ErrorBox msg={error} /> :
<InfoBox msg='Click buildings one at a time to colour using the data below' />
2019-11-26 07:09:27 -05:00
}
2020-02-03 17:35:32 -05:00
{
data &&
Object.keys(data).map((key => (
2020-02-03 17:35:32 -05:00
<DataEntry
key={key}
title={allFieldsConfig[key]?.title ?? `Unknown field (${key})`}
2020-02-03 17:35:32 -05:00
slug={key}
disabled={true}
value={data[key]}
/>
)))
2020-02-03 17:35:32 -05:00
}
</form>
<form className='buttons-container'>
<Link to={`/view/${props.category}`} className='btn btn-secondary'>Back to view</Link>
<Link to={`/edit/${props.category}`} className='btn btn-secondary'>Back to edit</Link>
</form>
</div>
</section>
2019-05-09 04:16:36 -04:00
);
2019-11-07 03:13:30 -05:00
};
2019-05-09 04:16:36 -04:00
export default MultiEdit;