diff options
author | Anton Tananaev <anton.tananaev@gmail.com> | 2021-09-08 20:59:18 -0700 |
---|---|---|
committer | Anton Tananaev <anton.tananaev@gmail.com> | 2021-09-08 20:59:18 -0700 |
commit | a7b243a894f9b1b09cc9478104b920ec47a94380 (patch) | |
tree | 253a511b4ef409de126fb5c93a83c949252399f3 /modern/src/settings | |
parent | 514843d04a1253f583612797a1947790c43717c3 (diff) | |
download | trackermap-web-a7b243a894f9b1b09cc9478104b920ec47a94380.tar.gz trackermap-web-a7b243a894f9b1b09cc9478104b920ec47a94380.tar.bz2 trackermap-web-a7b243a894f9b1b09cc9478104b920ec47a94380.zip |
Add calendar file upload
Diffstat (limited to 'modern/src/settings')
-rw-r--r-- | modern/src/settings/CalendarPage.js | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/modern/src/settings/CalendarPage.js b/modern/src/settings/CalendarPage.js index de714c36..60d4ef76 100644 --- a/modern/src/settings/CalendarPage.js +++ b/modern/src/settings/CalendarPage.js @@ -4,6 +4,7 @@ import { Accordion, AccordionSummary, AccordionDetails, makeStyles, Typography, } from '@material-ui/core'; import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; +import { DropzoneArea } from 'material-ui-dropzone'; import EditItemView from '../EditItemView'; import EditAttributesView from '../attributes/EditAttributesView'; import { useTranslation } from '../LocalizationProvider'; @@ -20,6 +21,19 @@ const CalendarPage = () => { const [item, setItem] = useState(); + const handleFiles = (files) => { + if (files.length > 0) { + const reader = new FileReader(); + reader.onload = (event) => { + const { result } = event.target; + setItem({ ...item, data: result.substr(result.indexOf(',') + 1) }); + }; + reader.readAsDataURL(files[0]); + } else { + setItem({ ...item, data: null }); + } + }; + return ( <EditItemView endpoint="calendars" item={item} setItem={setItem}> {item @@ -39,6 +53,10 @@ const CalendarPage = () => { label={t('sharedName')} variant="filled" /> + <DropzoneArea + filesLimit={1} + onChange={handleFiles} + /> </AccordionDetails> </Accordion> <Accordion> |