import React, { useState } from 'react'; import TextField from '@material-ui/core/TextField'; import t, { findStringKeys } from '../common/localization'; import EditItemView from '../EditItemView'; import { Accordion, AccordionSummary, AccordionDetails, makeStyles, Typography, FormControlLabel, Checkbox, FormControl, InputLabel, Select, MenuItem } from '@material-ui/core'; import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; import { useEffectAsync } from '../reactHelper'; import { prefixString, unprefixString } from '../common/stringUtils'; const useStyles = makeStyles(() => ({ details: { flexDirection: 'column', }, })); const NotificationPage = () => { const classes = useStyles(); const [item, setItem] = useState(); const [types, setTypes] = useState(); const [notificators, setNotificators] = useState(); const alarms = findStringKeys(it => it.startsWith('alarm')).map(it => ({ key: unprefixString('alarm', it), name: t(it), })); useEffectAsync(async () => { const response = await fetch('/api/notifications/types'); if (response.ok) { setTypes(await response.json()); } }, []); useEffectAsync(async () => { const response = await fetch('/api/notifications/notificators'); if (response.ok) { setNotificators(await response.json()); } }, []); return ( {item && <> }> {t('sharedRequired')} {types && {t('sharedType')} } {notificators && {t('notificationNotificators')} } {item.type === 'alarm' && {t('sharedAlarms')} } setItem({...item, always: event.target.checked})} /> } label={t('notificationAlways')} /> } ); } export default NotificationPage;