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
2022-10-12 16:59:04 -04:00

42 lines
929 B
TypeScript

import { Button, Stack, Text, Title } from "@mantine/core";
import { useModals } from "@mantine/modals";
import { ModalsContextProps } from "@mantine/modals/lib/context";
import { useRouter } from "next/router";
const showErrorModal = (
modals: ModalsContextProps,
title: string,
text: string
) => {
return modals.openModal({
closeOnClickOutside: false,
withCloseButton: false,
closeOnEscape: false,
title: <Title order={4}>{title}</Title>,
children: <Body text={text} />,
});
};
const Body = ({ text }: { text: string }) => {
const modals = useModals();
const router = useRouter();
return (
<>
<Stack align="stretch">
<Text size="sm">{text}</Text>
<Button
onClick={() => {
modals.closeAll();
router.back();
}}
>
Go back
</Button>
</Stack>
</>
);
};
export default showErrorModal;