0
Fork 0
mirror of https://github.com/stonith404/pingvin-share.git synced 2025-01-29 01:28:59 -05:00

fix: only show not signed in warning if not signed in

This commit is contained in:
Elias Schneider 2022-10-29 22:55:46 +02:00
parent c8021a42b7
commit c6e1f07f51
3 changed files with 13 additions and 46 deletions

View file

@ -29,6 +29,7 @@ const { publicRuntimeConfig } = getConfig();
const showCreateUploadModal = (
modals: ModalsContextProps,
isSignedIn: boolean,
uploadCallback: (
id: string,
expiration: string,
@ -37,18 +38,25 @@ const showCreateUploadModal = (
) => {
return modals.openModal({
title: <Title order={4}>Share</Title>,
children: <CreateUploadModalBody uploadCallback={uploadCallback} />,
children: (
<CreateUploadModalBody
isSignedIn={isSignedIn}
uploadCallback={uploadCallback}
/>
),
});
};
const CreateUploadModalBody = ({
uploadCallback,
isSignedIn,
}: {
uploadCallback: (
id: string,
expiration: string,
security: ShareSecurity
) => void;
isSignedIn: boolean;
}) => {
const modals = useModals();
@ -80,10 +88,9 @@ const CreateUploadModalBody = ({
},
validate: yupResolver(validationSchema),
});
return (
<Group>
{showNotSignedInAlert && (
{showNotSignedInAlert && !isSignedIn && (
<Alert
withCloseButton
onClose={() => setShowNotSignedInAlert(false)}

View file

@ -1,42 +0,0 @@
import { Alert, Button, Stack } from "@mantine/core";
import { useModals } from "@mantine/modals";
import { ModalsContextProps } from "@mantine/modals/lib/context";
import { useRouter } from "next/router";
import { TbAlertCircle } from "react-icons/tb";
const showNotAuthenticatedWarningModal = (
modals: ModalsContextProps,
onConfirm: (...any: any) => any
) => {
return modals.openConfirmModal({
closeOnClickOutside: false,
withCloseButton: false,
closeOnEscape: false,
labels: { confirm: "Continue", cancel: "Sign in" },
onConfirm: onConfirm,
onCancel: () => {},
children: <Body />,
});
};
const Body = () => {
const modals = useModals();
const router = useRouter();
return (
<>
<Stack align="stretch">
<Alert
icon={<TbAlertCircle size={16} />}
title="You're not signed in"
color="yellow"
>
You will be unable to delete your share manually and view the visitor
count if you're not signed in.
</Alert>
</Stack>
</>
);
};
export default showNotAuthenticatedWarningModal;

View file

@ -99,7 +99,9 @@ const Upload = () => {
<Button
loading={isUploading}
disabled={files.length <= 0}
onClick={() => showCreateUploadModal(modals, uploadFiles)}
onClick={() =>
showCreateUploadModal(modals, user ? true : false, uploadFiles)
}
>
Share
</Button>