import Dialog from '@mui/material/Dialog'; import DialogActions from '@mui/material/DialogActions'; import DialogContent from '@mui/material/DialogContent'; import DialogTitle from '@mui/material/DialogTitle'; import CheckCircle from '@mui/icons-material/CheckCircle'; import WarningIcon from '@mui/icons-material/Warning'; import clsx from 'clsx'; import { Fragment, KeyboardEvent, memo, useMemo } from 'react'; import { Button } from '../../Button/Button'; import { ModalProps, ModalQAs } from '../Modal'; import css from './ConfirmationModal.module.scss'; export interface ConfirmationModalQAs extends ModalQAs { /** Data-qa applied to the modal actions */ actions?: string; /** Data-qa applied to the action confirm button */ actionConfirm?: string; /** Data-qa applied to the action cancel button */ actionCancel?: string; } export interface ConfirmationModalProps extends ModalProps { /** Object of data-qa tags to pass to the modal */ modalqas?: ConfirmationModalQAs; /** Text to show in the confirm button */ okButtonText: string; /** Text to show in the cancel button */ cancelButtonText: string; /** Whether the icon for this modal should be a Warning triangle or a Check Circle */ modalType: 'warning' | 'check'; /** Action performed when the cancel button is clicked */ closeAction(): void; /** Action performed when the confirm button is clicked */ confirmAction(): void; } /** * Constructs a confirmation modal using pre-defined Rijkswaterstaat styling * @param props Props to pass to the confirmation modal * @example * ```jsx *
SAMPLE
} * /> * ``` */ export const ConfirmationModal = memo((props: ConfirmationModalProps) => { const handleConfirmKeyPress = (event: KeyboardEvent) => { return event.key.toLowerCase() === 'enter' ? props.confirmAction() : undefined; }; const renderModalActions = useMemo(() => { return (