1
0
mirror of https://github.com/stonith404/pingvin-share.git synced 2024-11-19 05:40:12 +01:00
pingvin-share/frontend/src/components/share/showErrorModal.tsx

42 lines
937 B
TypeScript
Raw Normal View History

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;