import React from 'react' import { Box, Button, Modal, Stack, SxProps, Typography } from '@mui/material' import CloseIcon from '@mui/icons-material/Close' import ErrorOutline from '@mui/icons-material/ErrorOutline' import InfoOutlinedIcon from '@mui/icons-material/InfoOutlined' import ArrowBackIosNewIcon from '@mui/icons-material/ArrowBackIosNew' import { useIsMobile } from '@/app/hooks/useIsMobile' export const modalStyle = (width: number | string = 600) => ({ position: 'absolute' as 'absolute', top: '50%', left: '50%', width, transform: 'translate(-50%, -50%)', bgcolor: 'background.paper', boxShadow: 24, borderRadius: '16px', p: 4, }) export const StyledBackButton = ({ onBack, label, fullWidth, sx, }: { onBack: () => void label?: string fullWidth?: boolean sx?: SxProps }) => ( ) export const SimpleModal: FCWithChildren<{ open: boolean hideCloseIcon?: boolean displayErrorIcon?: boolean displayInfoIcon?: boolean headerStyles?: SxProps subHeaderStyles?: SxProps buttonFullWidth?: boolean onClose?: () => void onOk?: () => Promise onBack?: () => void header: string | React.ReactNode subHeader?: string okLabel: string backLabel?: string backButtonFullWidth?: boolean okDisabled?: boolean sx?: SxProps children?: React.ReactNode }> = ({ open, hideCloseIcon, displayErrorIcon, displayInfoIcon, headerStyles, buttonFullWidth, onClose, okDisabled, onOk, onBack, header, subHeader, okLabel, backLabel, backButtonFullWidth, sx, children, }) => { const isMobile = useIsMobile() return ( {displayErrorIcon && } {displayInfoIcon && } {typeof header === 'string' ? ( {header} ) : ( header )} {!hideCloseIcon && } theme.palette.text.secondary} > {subHeader} {children} {(onOk || onBack) && ( {onBack && ( )} {onOk && ( )} )} ) }