2025-03-12 11:55:43 +03:00
|
|
|
|
import { useMutationErrors } from '@/backend/use-mutation-errors';
|
2025-03-12 12:04:50 +03:00
|
|
|
|
import { Button } from '@/components/control';
|
2025-03-12 11:55:43 +03:00
|
|
|
|
import { DescribeError } from '@/components/info-error';
|
2025-03-12 12:04:50 +03:00
|
|
|
|
import { ModalBackdrop } from '@/components/modal/modal-backdrop';
|
2025-03-12 11:55:43 +03:00
|
|
|
|
import { useEscapeKey } from '@/hooks/use-escape-key';
|
2025-02-19 19:26:29 +03:00
|
|
|
|
import { useDialogsStore } from '@/stores/dialogs';
|
|
|
|
|
|
|
|
|
|
export function MutationErrors() {
|
|
|
|
|
const { mutationErrors, resetErrors } = useMutationErrors();
|
|
|
|
|
const hideDialog = useDialogsStore(state => state.hideDialog);
|
|
|
|
|
|
|
|
|
|
useEscapeKey(resetErrors, mutationErrors.length > 0);
|
|
|
|
|
|
|
|
|
|
if (mutationErrors.length === 0) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
hideDialog();
|
|
|
|
|
|
|
|
|
|
return (
|
2025-03-10 16:02:53 +03:00
|
|
|
|
<div className='cc-modal-wrapper'>
|
|
|
|
|
<ModalBackdrop onHide={resetErrors} />
|
2025-03-11 11:01:19 +03:00
|
|
|
|
<div className='z-pop px-10 py-3 flex flex-col items-center border rounded-xl bg-prim-100' role='alertdialog'>
|
2025-02-19 19:26:29 +03:00
|
|
|
|
<h1 className='py-2 select-none'>Ошибка при обработке</h1>
|
2025-03-10 16:02:53 +03:00
|
|
|
|
<div className='px-3 flex flex-col text-warn-600 text-sm font-semibold select-text'>
|
2025-02-19 19:26:29 +03:00
|
|
|
|
<DescribeError error={mutationErrors[0]} />
|
|
|
|
|
</div>
|
|
|
|
|
<Button onClick={resetErrors} className='w-fit' text='Закрыть' />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|