2022-10-10 22:14:23 +02:00
|
|
|
import { Button, Group, Stack, Text, Title } from "@mantine/core";
|
2022-04-25 15:15:17 +02:00
|
|
|
import { useModals } from "@mantine/modals";
|
|
|
|
import { ModalsContextProps } from "@mantine/modals/lib/context";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
|
2022-05-08 14:16:19 +02:00
|
|
|
const showErrorModal = (
|
|
|
|
modals: ModalsContextProps,
|
|
|
|
title: string,
|
|
|
|
text: string
|
|
|
|
) => {
|
2022-04-25 15:15:17 +02:00
|
|
|
return modals.openModal({
|
|
|
|
closeOnClickOutside: false,
|
|
|
|
withCloseButton: false,
|
|
|
|
closeOnEscape: false,
|
2022-05-08 14:16:19 +02:00
|
|
|
title: <Title order={4}>{title}</Title>,
|
2022-04-25 15:15:17 +02:00
|
|
|
|
2022-05-08 14:16:19 +02:00
|
|
|
children: <Body text={text} />,
|
2022-04-25 15:15:17 +02:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
2022-05-08 14:16:19 +02:00
|
|
|
const Body = ({ text }: { text: string }) => {
|
2022-04-25 15:15:17 +02:00
|
|
|
const modals = useModals();
|
|
|
|
const router = useRouter();
|
|
|
|
return (
|
|
|
|
<>
|
2022-10-10 22:14:23 +02:00
|
|
|
<Stack align="stretch">
|
2022-05-08 14:16:19 +02:00
|
|
|
<Text size="sm">{text}</Text>
|
2022-04-25 15:15:17 +02:00
|
|
|
<Button
|
|
|
|
onClick={() => {
|
|
|
|
modals.closeAll();
|
|
|
|
router.back();
|
|
|
|
}}
|
|
|
|
>
|
|
|
|
Go back
|
|
|
|
</Button>
|
2022-10-10 22:14:23 +02:00
|
|
|
</Stack>
|
2022-04-25 15:15:17 +02:00
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-05-08 14:16:19 +02:00
|
|
|
export default showErrorModal;
|