import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown'; import WarningAmberRoundedIcon from '@mui/icons-material/WarningAmberRounded'; import { Button, Menu, MenuItem, Stack } from '@mui/material'; import { memo, useEffect, useState } from 'react'; const warningColors = { bg: '#fff7e6', text: '#b54708', border: '#FCD99C', hover: '#fff1d6', }; const ValidationErrorsAlert = ({ errors = [], onNavigateToColumn }) => { const [anchorEl, setAnchorEl] = useState(null); const isOpen = Boolean(anchorEl); useEffect(() => { if (errors.length === 0) { setAnchorEl(null); } }, [errors.length]); if (errors.length === 0) return null; const handleNavigate = (columnId) => { onNavigateToColumn?.(columnId); setAnchorEl(null); }; return ( <> setAnchorEl(null)} anchorOrigin={{ vertical: 'bottom', horizontal: 'left' }} transformOrigin={{ vertical: 'top', horizontal: 'left' }} slotProps={{ paper: { 'data-validation-errors-menu': true, sx: { mt: 0.5, bgcolor: warningColors.bg, color: warningColors.text, border: `1px solid ${warningColors.border}`, borderRadius: '0.5rem', boxShadow: 'none', minWidth: anchorEl?.offsetWidth, maxWidth: 420, }, }, }}> {errors.map((error) => ( handleNavigate(error.columnId)} sx={{ whiteSpace: 'normal', color: warningColors.text, cursor: 'pointer', '&:hover': { bgcolor: warningColors.hover, }, }}> {error.message} ))} ); }; export default memo(ValidationErrorsAlert);