import React, { useState } from 'react'; import TextField from '@material-ui/core/TextField'; import t from './common/localization'; import EditItemView from './EditItemView'; import { Accordion, AccordionSummary, AccordionDetails, makeStyles, Typography, FormControl, InputLabel, Select, FormControlLabel, Checkbox } from '@material-ui/core'; import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; import { useEffectAsync } from './reactHelper'; import EditAttributesView from './attributes/EditAttributesView'; import deviceAttributes from './attributes/deviceAttributes'; const useStyles = makeStyles(() => ({ details: { flexDirection: 'column', }, })); const deviceCategories = [ 'default', 'animal', 'bicycle', 'boat', 'bus', 'car', 'crane', 'helicopter', 'motorcycle', 'offroad', 'person', 'pickup', 'plane', 'ship', 'tractor', 'train', 'tram', 'trolleybus', 'truck', 'van', 'scooter', ]; const DevicePage = () => { const classes = useStyles(); const [item, setItem] = useState(); const [groups, setGroups] = useState(); useEffectAsync(async () => { const response = await fetch('/api/groups'); if (response.ok) { setGroups(await response.json()); } }, []); return ( {item && <> }> {t('sharedRequired')} setItem({...item, name: event.target.value})} label={t('sharedName')} variant="filled" /> setItem({...item, uniqueId: event.target.value})} label={t('deviceIdentifier')} variant="filled" /> }> {t('sharedExtra')} {groups && {t('groupParent')} } setItem({...item, phone: event.target.value})} label={t('sharedPhone')} variant="filled" /> setItem({...item, model: event.target.value})} label={t('deviceModel')} variant="filled" /> setItem({...item, contact: event.target.value})} label={t('deviceContact')} variant="filled" /> {t('deviceCategory')} setItem({...item, disabled: event.target.checked})} />} label={t('sharedDisabled')} /> }> {t('sharedAttributes')} setItem({...item, attributes})} definitions={deviceAttributes} /> } ); } export default DevicePage;