2022-04-25 15:15:17 +02:00
|
|
|
import {
|
|
|
|
|
ActionIcon,
|
|
|
|
|
Button,
|
|
|
|
|
Group,
|
|
|
|
|
Text,
|
|
|
|
|
TextInput,
|
|
|
|
|
Title,
|
|
|
|
|
} from "@mantine/core";
|
|
|
|
|
import { useClipboard } from "@mantine/hooks";
|
|
|
|
|
import { useModals } from "@mantine/modals";
|
|
|
|
|
import { ModalsContextProps } from "@mantine/modals/lib/context";
|
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
|
import { Copy } from "tabler-icons-react";
|
2022-05-05 10:24:10 +02:00
|
|
|
import toast from "../../utils/toast.util";
|
2022-04-25 15:15:17 +02:00
|
|
|
|
|
|
|
|
const showCompletedUploadModal = (
|
|
|
|
|
modals: ModalsContextProps,
|
|
|
|
|
link: string,
|
2022-05-06 10:25:10 +02:00
|
|
|
expiresAt: string,
|
|
|
|
|
mode: "email" | "standard"
|
2022-04-25 15:15:17 +02:00
|
|
|
) => {
|
|
|
|
|
return modals.openModal({
|
|
|
|
|
closeOnClickOutside: false,
|
|
|
|
|
withCloseButton: false,
|
|
|
|
|
closeOnEscape: false,
|
2022-05-06 10:25:10 +02:00
|
|
|
title: (
|
|
|
|
|
<Group grow direction="column" spacing={0}>
|
|
|
|
|
<Title order={4}>Share ready</Title>
|
|
|
|
|
{mode == "email" && (
|
|
|
|
|
<Text size="sm"> Emails were sent to the to invited users.</Text>
|
|
|
|
|
)}
|
|
|
|
|
</Group>
|
|
|
|
|
),
|
2022-04-25 15:15:17 +02:00
|
|
|
children: <Body link={link} expiresAt={expiresAt} />,
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
const Body = ({ link, expiresAt }: { link: string; expiresAt: string }) => {
|
|
|
|
|
const clipboard = useClipboard({ timeout: 500 });
|
|
|
|
|
const modals = useModals();
|
|
|
|
|
const router = useRouter();
|
|
|
|
|
return (
|
|
|
|
|
<Group grow direction="column">
|
|
|
|
|
<TextInput
|
|
|
|
|
variant="filled"
|
|
|
|
|
value={link}
|
|
|
|
|
rightSection={
|
2022-05-05 10:24:10 +02:00
|
|
|
<ActionIcon
|
|
|
|
|
onClick={() => {
|
|
|
|
|
clipboard.copy(link);
|
|
|
|
|
toast.success("Your link was copied to the keyboard.");
|
|
|
|
|
}}
|
|
|
|
|
>
|
2022-04-25 15:15:17 +02:00
|
|
|
<Copy />
|
|
|
|
|
</ActionIcon>
|
|
|
|
|
}
|
|
|
|
|
/>
|
|
|
|
|
<Text
|
|
|
|
|
size="xs"
|
|
|
|
|
sx={(theme) => ({
|
|
|
|
|
color: theme.colors.gray[6],
|
|
|
|
|
})}
|
|
|
|
|
>
|
|
|
|
|
Your share expires at {expiresAt}{" "}
|
|
|
|
|
</Text>
|
|
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
onClick={() => {
|
|
|
|
|
modals.closeAll();
|
|
|
|
|
router.push("/upload");
|
|
|
|
|
}}
|
|
|
|
|
>
|
|
|
|
|
Done
|
|
|
|
|
</Button>
|
|
|
|
|
</Group>
|
|
|
|
|
);
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
export default showCompletedUploadModal;
|