mirror of
https://github.com/swissmakers/swiss-datashare.git
synced 2026-04-25 06:48:58 +02:00
Improve share error handling
This commit is contained in:
@@ -3,26 +3,28 @@ import { useModals } from "@mantine/modals";
|
||||
import { ModalsContextProps } from "@mantine/modals/lib/context";
|
||||
import { useRouter } from "next/router";
|
||||
|
||||
const showShareNotFoundModal = (modals: ModalsContextProps) => {
|
||||
const showErrorModal = (
|
||||
modals: ModalsContextProps,
|
||||
title: string,
|
||||
text: string
|
||||
) => {
|
||||
return modals.openModal({
|
||||
closeOnClickOutside: false,
|
||||
withCloseButton: false,
|
||||
closeOnEscape: false,
|
||||
title: <Title order={4}>Not found</Title>,
|
||||
title: <Title order={4}>{title}</Title>,
|
||||
|
||||
children: <Body />,
|
||||
children: <Body text={text} />,
|
||||
});
|
||||
};
|
||||
|
||||
const Body = () => {
|
||||
const Body = ({ text }: { text: string }) => {
|
||||
const modals = useModals();
|
||||
const router = useRouter();
|
||||
return (
|
||||
<>
|
||||
<Group grow direction="column">
|
||||
<Text size="sm">
|
||||
This share can't be found. Please check your link.
|
||||
</Text>
|
||||
<Text size="sm">{text}</Text>
|
||||
<Button
|
||||
onClick={() => {
|
||||
modals.closeAll();
|
||||
@@ -36,4 +38,4 @@ const Body = () => {
|
||||
);
|
||||
};
|
||||
|
||||
export default showShareNotFoundModal;
|
||||
export default showErrorModal;
|
||||
@@ -1,39 +0,0 @@
|
||||
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";
|
||||
|
||||
const showVisitorLimitExceededModal = (modals: ModalsContextProps) => {
|
||||
return modals.openModal({
|
||||
closeOnClickOutside: false,
|
||||
withCloseButton: false,
|
||||
closeOnEscape: false,
|
||||
title: <Title order={4}>Visitor limit exceeded</Title>,
|
||||
|
||||
children: <Body />,
|
||||
});
|
||||
};
|
||||
|
||||
const Body = () => {
|
||||
const modals = useModals();
|
||||
const router = useRouter();
|
||||
return (
|
||||
<>
|
||||
<Group grow direction="column">
|
||||
<Text size="sm">
|
||||
The visitor count limit from this share has been exceeded.
|
||||
</Text>
|
||||
<Button
|
||||
onClick={() => {
|
||||
modals.closeAll();
|
||||
router.back();
|
||||
}}
|
||||
>
|
||||
Go back
|
||||
</Button>
|
||||
</Group>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default showVisitorLimitExceededModal;
|
||||
Reference in New Issue
Block a user