mirror of
https://github.com/stonith404/pingvin-share.git
synced 2025-02-05 01:38:56 -05:00
fix: only show not signed in warning if not signed in
This commit is contained in:
parent
c8021a42b7
commit
c6e1f07f51
3 changed files with 13 additions and 46 deletions
|
@ -29,6 +29,7 @@ const { publicRuntimeConfig } = getConfig();
|
||||||
|
|
||||||
const showCreateUploadModal = (
|
const showCreateUploadModal = (
|
||||||
modals: ModalsContextProps,
|
modals: ModalsContextProps,
|
||||||
|
isSignedIn: boolean,
|
||||||
uploadCallback: (
|
uploadCallback: (
|
||||||
id: string,
|
id: string,
|
||||||
expiration: string,
|
expiration: string,
|
||||||
|
@ -37,18 +38,25 @@ const showCreateUploadModal = (
|
||||||
) => {
|
) => {
|
||||||
return modals.openModal({
|
return modals.openModal({
|
||||||
title: <Title order={4}>Share</Title>,
|
title: <Title order={4}>Share</Title>,
|
||||||
children: <CreateUploadModalBody uploadCallback={uploadCallback} />,
|
children: (
|
||||||
|
<CreateUploadModalBody
|
||||||
|
isSignedIn={isSignedIn}
|
||||||
|
uploadCallback={uploadCallback}
|
||||||
|
/>
|
||||||
|
),
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const CreateUploadModalBody = ({
|
const CreateUploadModalBody = ({
|
||||||
uploadCallback,
|
uploadCallback,
|
||||||
|
isSignedIn,
|
||||||
}: {
|
}: {
|
||||||
uploadCallback: (
|
uploadCallback: (
|
||||||
id: string,
|
id: string,
|
||||||
expiration: string,
|
expiration: string,
|
||||||
security: ShareSecurity
|
security: ShareSecurity
|
||||||
) => void;
|
) => void;
|
||||||
|
isSignedIn: boolean;
|
||||||
}) => {
|
}) => {
|
||||||
const modals = useModals();
|
const modals = useModals();
|
||||||
|
|
||||||
|
@ -80,10 +88,9 @@ const CreateUploadModalBody = ({
|
||||||
},
|
},
|
||||||
validate: yupResolver(validationSchema),
|
validate: yupResolver(validationSchema),
|
||||||
});
|
});
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group>
|
<Group>
|
||||||
{showNotSignedInAlert && (
|
{showNotSignedInAlert && !isSignedIn && (
|
||||||
<Alert
|
<Alert
|
||||||
withCloseButton
|
withCloseButton
|
||||||
onClose={() => setShowNotSignedInAlert(false)}
|
onClose={() => setShowNotSignedInAlert(false)}
|
||||||
|
|
|
@ -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;
|
|
|
@ -99,7 +99,9 @@ const Upload = () => {
|
||||||
<Button
|
<Button
|
||||||
loading={isUploading}
|
loading={isUploading}
|
||||||
disabled={files.length <= 0}
|
disabled={files.length <= 0}
|
||||||
onClick={() => showCreateUploadModal(modals, uploadFiles)}
|
onClick={() =>
|
||||||
|
showCreateUploadModal(modals, user ? true : false, uploadFiles)
|
||||||
|
}
|
||||||
>
|
>
|
||||||
Share
|
Share
|
||||||
</Button>
|
</Button>
|
||||||
|
|
Loading…
Add table
Reference in a new issue