2025-04-21 20:37:11 +03:00
|
|
|
|
import clsx from 'clsx';
|
|
|
|
|
|
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-04-21 20:37:11 +03:00
|
|
|
|
<div
|
|
|
|
|
className={clsx(
|
|
|
|
|
'z-pop', //
|
|
|
|
|
'flex flex-col px-10 py-3 items-center',
|
|
|
|
|
'border rounded-xl bg-background'
|
|
|
|
|
)}
|
|
|
|
|
role='alertdialog'
|
|
|
|
|
>
|
2025-02-19 19:26:29 +03:00
|
|
|
|
<h1 className='py-2 select-none'>Ошибка при обработке</h1>
|
2025-04-21 20:37:11 +03:00
|
|
|
|
<div
|
|
|
|
|
className={clsx(
|
|
|
|
|
'max-h-[calc(100svh-8rem)] max-w-[calc(100svw-2rem)]',
|
|
|
|
|
'px-3 flex flex-col',
|
|
|
|
|
'text-destructive text-sm font-semibold select-text',
|
|
|
|
|
'overflow-auto'
|
|
|
|
|
)}
|
|
|
|
|
>
|
2025-02-19 19:26:29 +03:00
|
|
|
|
<DescribeError error={mutationErrors[0]} />
|
|
|
|
|
</div>
|
|
|
|
|
<Button onClick={resetErrors} className='w-fit' text='Закрыть' />
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
);
|
|
|
|
|
}
|