import * as React from 'react'; import Accordion from '@mui/material/Accordion'; import AccordionSummary from '@mui/material/AccordionSummary'; import AccordionDetails from '@mui/material/AccordionDetails'; import Typography from '@mui/material/Typography'; import ExpandMoreIcon from '@mui/icons-material/ExpandMore'; import SummaryTable from './SummaryTable' import LocationRepository from '../../../repository/LocationRepository' export default function SummaryContent(props) { const [expanded, setExpanded] = React.useState(null); const [locationDetails, setLocationDetails] = React.useState({}) const getLocationDetails = () => { LocationRepository.getLocationData(props.filters).then(result => { setLocationDetails(result); }) } const handleChange = (panel) => (event, isExpanded) => { setExpanded(isExpanded ? panel : false); }; React.useEffect(() => { props.setNextDisabled(false); !Object.keys(locationDetails).length && getLocationDetails() }); function createData(name, value) { return { name, value }; } const locationData = [ createData('Geographical Coordinates (latitude, longitude)', `(${props.filters.coordinates.lat}, ${props.filters.coordinates.lng})`), createData('Ecological Region', locationDetails.ecological_region || ''), createData('Ecological District', locationDetails.ecological_district || ''), createData('Property Name', locationDetails.full_address || ''), ]; const soilData = [ createData('Soil Order', `${locationDetails.soil_name} (${locationDetails.soil_code})` || ''), createData('Soil Variant', props.filters.soilVariant) ]; const siteData = [ createData('Habitat', ''), createData('Zone', '') ]; const projectSpecificsData = [ createData('Requrements', '') ]; return (