import { DialogActions, DialogContent, TextField, Theme, Typography, Checkbox, FormControlLabel, } from '@mui/material'; import { ChangeEvent, FC, useContext, useState } from 'react'; import { useTranslation } from 'react-i18next'; import CustomButton from '@/components/customButton/CustomButton'; import CustomDialogTitle from '@/components/customDialog/CustomDialogTitle'; import { DeleteDialogContentType } from '@/components/customDialog/Types'; import { rootContext } from '@/context'; import { makeStyles } from '@mui/styles'; const useStyles = makeStyles((theme: Theme) => ({ root: { maxWidth: 540, backgroundColor: theme.palette.background.paper, }, info: { marginBottom: theme.spacing(0.5), color: theme.palette.text.secondary, }, mb: { marginBottom: theme.spacing(2.5), }, btnWrapper: { display: 'flex', }, label: { display: 'none', }, btnLabel: { fontWeight: 'bold', }, input: { padding: '10px 12px', }, cancelBtn: { color: theme.palette.text.secondary, }, checkBox: {}, })); const DeleteTemplate: FC = props => { const { title, text, label, compare, handleDelete, handleCancel, forceDelLabel, } = props; const { handleCloseDialog } = useContext(rootContext); const classes = useStyles(); const { t: dialogTrans } = useTranslation('dialog'); const { t: btnTrans } = useTranslation('btn'); const [value, setValue] = useState(''); const [force, setForce] = useState(false); const [deleteReady, setDeleteReady] = useState(false); const onCancelClick = () => { handleCloseDialog(); handleCancel && handleCancel(); }; const onDeleteClick = (event: React.FormEvent) => { handleDelete(force); event.preventDefault(); }; const onChange = (event: ChangeEvent) => { const value = event.target.value; setValue(value); setDeleteReady(value.toLowerCase() === (compare || label).toLowerCase()); }; return (
{title} {dialogTrans('deleteTipAction')} {` ${( compare || label ).toLowerCase()} `} {dialogTrans('deleteTipPurpose')} {forceDelLabel ? ( , checked: boolean ) => { setForce(checked); }} /> } key={'force'} label={forceDelLabel} value={true} checked={force} className={classes.checkBox} /> ) : null} {btnTrans('cancel')} {label}
); }; export default DeleteTemplate;