import React, { useState } from 'react'; import { makeStyles, Typography, AppBar, Toolbar, IconButton, } from '@material-ui/core'; import ArrowBackIcon from '@material-ui/icons/ArrowBack'; import { useHistory, useParams } from 'react-router-dom'; import ContainerDimensions from 'react-container-dimensions'; import { useEffectAsync } from './reactHelper'; import { useTranslation } from './LocalizationProvider'; import Map from './map/core/Map'; import PositionsMap from './map/PositionsMap'; const useStyles = makeStyles(() => ({ root: { height: '100%', display: 'flex', flexDirection: 'column', }, mapContainer: { flexGrow: 1, }, })); const EventPage = () => { const classes = useStyles(); const history = useHistory(); const t = useTranslation(); const { id } = useParams(); const [event, setEvent] = useState(); const [position, setPosition] = useState(); useEffectAsync(async () => { if (id) { const response = await fetch(`/api/events/${id}`); if (response.ok) { setEvent(await response.json()); } } }, [id]); useEffectAsync(async () => { if (event && event.positionId) { const response = await fetch(`/api/positions?id=${event.positionId}`); if (response.ok) { const positions = await response.json(); if (positions.length > 0) { setPosition(positions[0]); } } } }, [event]); return (