1
0
mirror of https://github.com/stonith404/pingvin-share.git synced 2024-10-01 09:00:12 +02:00
pingvin-share/frontend/src/components/share/showErrorModal.tsx

42 lines
929 B
TypeScript
Raw Normal View History

2022-10-12 22:59:04 +02:00
import { Button, 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;