ConceptPortal-public/rsconcept/frontend/src/app/mutation-errors.tsx
Ivan a69a26bb7b
Some checks are pending
Backend CI / build (3.12) (push) Waiting to run
Backend CI / notify-failure (push) Blocked by required conditions
Frontend CI / build (22.x) (push) Waiting to run
Frontend CI / notify-failure (push) Blocked by required conditions
F: Implementing block UI pt1
2025-04-21 20:37:11 +03:00

49 lines
1.5 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import clsx from 'clsx';
import { useMutationErrors } from '@/backend/use-mutation-errors';
import { Button } from '@/components/control';
import { DescribeError } from '@/components/info-error';
import { ModalBackdrop } from '@/components/modal/modal-backdrop';
import { useEscapeKey } from '@/hooks/use-escape-key';
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 (
<div className='cc-modal-wrapper'>
<ModalBackdrop onHide={resetErrors} />
<div
className={clsx(
'z-pop', //
'flex flex-col px-10 py-3 items-center',
'border rounded-xl bg-background'
)}
role='alertdialog'
>
<h1 className='py-2 select-none'>Ошибка при обработке</h1>
<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'
)}
>
<DescribeError error={mutationErrors[0]} />
</div>
<Button onClick={resetErrors} className='w-fit' text='Закрыть' />
</div>
</div>
);
}