ConceptPortal-public/rsconcept/frontend/src/app/mutation-errors.tsx
2025-03-12 12:04:50 +03:00

33 lines
1.2 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 { 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='z-pop px-10 py-3 flex flex-col items-center border rounded-xl bg-prim-100' role='alertdialog'>
<h1 className='py-2 select-none'>Ошибка при обработке</h1>
<div className='px-3 flex flex-col text-warn-600 text-sm font-semibold select-text'>
<DescribeError error={mutationErrors[0]} />
</div>
<Button onClick={resetErrors} className='w-fit' text='Закрыть' />
</div>
</div>
);
}