50 lines
1.9 KiB
JavaScript
50 lines
1.9 KiB
JavaScript
import { Box, FormControlLabel, Checkbox, Typography } from "@mui/material";
|
|
|
|
import Modal from "../../components/Modal/Modal";
|
|
import { CheckBoxOutlineBlank, CheckBoxOutlined } from "@mui/icons-material";
|
|
|
|
const SettingsModal = ({ isOpen, close, submit, selectedValues, possibleValues, onChange }) => {
|
|
const handleCheckboxChange = (type, isChecked) => {
|
|
const updatedTypes = possibleValues.filter(v => {
|
|
if (v === type) return isChecked
|
|
return selectedValues.includes(v)
|
|
})
|
|
onChange(updatedTypes);
|
|
};
|
|
|
|
return (
|
|
<Modal
|
|
key="SettingsModal"
|
|
maxWidth="320px"
|
|
minHeight="200px"
|
|
open={isOpen}
|
|
headerText="Settings"
|
|
onClose={() => close()}
|
|
>
|
|
<Box display="flex" flexDirection="column" justifyContent="space-between" gap="5px">
|
|
{possibleValues.map((type, i) => {
|
|
const isChecked = selectedValues.includes(type);
|
|
return (
|
|
<FormControlLabel
|
|
key={i}
|
|
control={
|
|
<Checkbox
|
|
inputProps={{ "data-testid": `history-type-${type}` }}
|
|
id={`history-type-${type}`}
|
|
checked={isChecked}
|
|
onChange={event => handleCheckboxChange(type, event.target.checked)}
|
|
icon={<CheckBoxOutlineBlank viewBox="0 0 24 24" />}
|
|
checkedIcon={<CheckBoxOutlined viewBox="0 0 24 24" />}
|
|
/>
|
|
}
|
|
label={<Typography variant="body1">{type} History</Typography>}
|
|
/>
|
|
)
|
|
})}
|
|
</Box>
|
|
</Modal>
|
|
)
|
|
}
|
|
|
|
export default SettingsModal;
|