Display additional region information on summary step

This commit is contained in:
Dana Lambert 2021-12-01 09:48:06 +13:00 committed by Alistair McIntyre
parent a22b1dfb38
commit f25c7bb7df
2 changed files with 20 additions and 2 deletions

View file

@ -3,6 +3,7 @@ import Accordion from '@mui/material/Accordion';
import AccordionSummary from '@mui/material/AccordionSummary'; import AccordionSummary from '@mui/material/AccordionSummary';
import AccordionDetails from '@mui/material/AccordionDetails'; import AccordionDetails from '@mui/material/AccordionDetails';
import Typography from '@mui/material/Typography'; import Typography from '@mui/material/Typography';
import Box from '@mui/material/Box';
import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; import ExpandMoreIcon from '@mui/icons-material/ExpandMore';
import SummaryTable from './SummaryTable' import SummaryTable from './SummaryTable'
@ -51,6 +52,14 @@ export default function SummaryContent(props) {
createData('Zone Refined Variant', (props.filters.zone && props.filters.zone.refined_variant) ?? "") createData('Zone Refined Variant', (props.filters.zone && props.filters.zone.refined_variant) ?? "")
]; ];
const regionInformation = () => {
if (locationDetails.in_chch) {
return <Typography variant='body2'>Your location falls within the ecosystem type covered by the Christchurch Council ecosystem maps - further information can be obtained from <a href="https://ccc.govt.nz/environment/land/ecosystem-map" target="blank" >Ōtautahi/Christchurch ecosystems map</a>.</Typography>
} else if (locationDetails.in_auckland) {
return <Typography variant='body2'>"Your location falls within the ecosystem type covered by the Auckland Council Tiaki Tāmaki Makaurau Conservation map - further information can be obtained from <a href="https://www.tiakitamakimakaurau.nz/conservation-map/" target="blank" >tiaki Tāmaki Makaurau conservation Auckland</a></Typography>
}
}
return ( return (
<div className='summary-content'> <div className='summary-content'>
<Typography mb={2} mt={2} >Please review your choices presented below: </Typography> <Typography mb={2} mt={2} >Please review your choices presented below: </Typography>
@ -62,6 +71,9 @@ export default function SummaryContent(props) {
</AccordionSummary> </AccordionSummary>
<AccordionDetails> <AccordionDetails>
<SummaryTable rows={locationData} /> <SummaryTable rows={locationData} />
<Box ml={2} mt={2}>
{regionInformation()}
</Box>
</AccordionDetails> </AccordionDetails>
</Accordion> </Accordion>
<Accordion expanded={expanded === 'panel2'} onChange={handleChange('panel2')} > <Accordion expanded={expanded === 'panel2'} onChange={handleChange('panel2')} >

View file

@ -11,21 +11,27 @@ const LocationRepsostory = {
return API.get(`/ecologicaldistrict/`, { params: filters }); return API.get(`/ecologicaldistrict/`, { params: filters });
}, },
getRegionDetails(filters) {
return API.get(`/region/`, { params: filters });
},
getPropertyDetails(filters) { getPropertyDetails(filters) {
return API.get(`/address/`, { params: filters }); return API.get(`/address/`, { params: filters });
}, },
async getLocationData(filters) { async getLocationData(filters) {
const [soilDetails, ecologicalDistrictDetails, propertyDetails] = await Promise.all([ const [soilDetails, ecologicalDistrictDetails, propertyDetails, regionDetails] = await Promise.all([
this.getSoilDetails(filters), this.getSoilDetails(filters),
this.getEcologicalDistrictDetails(filters), this.getEcologicalDistrictDetails(filters),
this.getPropertyDetails(filters) this.getPropertyDetails(filters),
this.getRegionDetails(filters)
]); ]);
let locationData = {}; let locationData = {};
locationData = soilDetails.status === 200 ? Object.assign(locationData, soilDetails.data[0]) : locationData; locationData = soilDetails.status === 200 ? Object.assign(locationData, soilDetails.data[0]) : locationData;
locationData = ecologicalDistrictDetails.status === 200 ? Object.assign(locationData, ecologicalDistrictDetails.data[0]) : locationData; locationData = ecologicalDistrictDetails.status === 200 ? Object.assign(locationData, ecologicalDistrictDetails.data[0]) : locationData;
locationData = propertyDetails.status === 200 ? Object.assign(locationData, propertyDetails.data) : locationData; locationData = propertyDetails.status === 200 ? Object.assign(locationData, propertyDetails.data) : locationData;
locationData = regionDetails.status === 200 ? Object.assign(locationData, regionDetails.data) : locationData;
return locationData return locationData
} }