2022-04-25 15:15:17 +02:00
|
|
|
import { Button, Group, Text, Title } from "@mantine/core";
|
|
|
|
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 (
|
|
|
|
<>
|
|
|
|
<Group grow direction="column">
|
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>
|
|
|
|
</Group>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2022-05-08 14:16:19 +02:00
|
|
|
export default showErrorModal;
|