2020-03-31 05:35:44 -08:00
|
|
|
import React from 'react'
|
2020-03-31 13:02:22 -08:00
|
|
|
import { useDispatch, useSelector } from 'react-redux'
|
|
|
|
|
import { Card, CardContent, MenuItem, Select } from '@material-ui/core'
|
|
|
|
|
import { Title, useTranslate } from 'react-admin'
|
2020-03-31 05:35:44 -08:00
|
|
|
import { makeStyles } from '@material-ui/core/styles'
|
|
|
|
|
import { changeTheme } from './actions'
|
2020-03-31 13:02:22 -08:00
|
|
|
import themes from '../themes'
|
2020-03-31 05:35:44 -08:00
|
|
|
|
|
|
|
|
const useStyles = makeStyles({
|
|
|
|
|
label: { width: '10em', display: 'inline-block' },
|
2020-03-31 14:43:54 -08:00
|
|
|
select: { minWidth: 200 }
|
2020-03-31 05:35:44 -08:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
const Configuration = () => {
|
|
|
|
|
const translate = useTranslate()
|
|
|
|
|
const classes = useStyles()
|
|
|
|
|
const theme = useSelector((state) => state.theme)
|
|
|
|
|
const dispatch = useDispatch()
|
2020-03-31 13:02:22 -08:00
|
|
|
const themeNames = Object.keys(themes).sort()
|
|
|
|
|
|
2020-03-31 05:35:44 -08:00
|
|
|
return (
|
|
|
|
|
<Card>
|
|
|
|
|
<Title title={translate('menu.configuration')} />
|
|
|
|
|
<CardContent>
|
2020-03-31 13:02:22 -08:00
|
|
|
<div className={classes.label}>{translate('menu.theme')}</div>
|
|
|
|
|
<Select
|
2020-03-31 14:43:54 -08:00
|
|
|
className={classes.select}
|
2020-03-31 13:02:22 -08:00
|
|
|
value={theme}
|
|
|
|
|
variant="filled"
|
|
|
|
|
onChange={(event) => {
|
|
|
|
|
dispatch(changeTheme(event.target.value))
|
|
|
|
|
}}
|
2020-03-31 05:35:44 -08:00
|
|
|
>
|
2020-03-31 13:02:22 -08:00
|
|
|
{themeNames.map((t) => (
|
2020-03-31 15:36:45 -08:00
|
|
|
<MenuItem value={t}>{themes[t].themeName}</MenuItem>
|
2020-03-31 13:02:22 -08:00
|
|
|
))}
|
|
|
|
|
</Select>
|
2020-03-31 05:35:44 -08:00
|
|
|
</CardContent>
|
|
|
|
|
</Card>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export default Configuration
|