From c6e1f07f51e9cdd914bb70fb19dd81b90a470563 Mon Sep 17 00:00:00 2001 From: Elias Schneider Date: Sat, 29 Oct 2022 22:55:46 +0200 Subject: [PATCH] fix: only show not signed in warning if not signed in --- .../upload/modals/showCreateUploadModal.tsx | 13 ++++-- .../showNotAuthenticatedWarningModal.tsx | 42 ------------------- frontend/src/pages/upload.tsx | 4 +- 3 files changed, 13 insertions(+), 46 deletions(-) delete mode 100644 frontend/src/components/upload/modals/showNotAuthenticatedWarningModal.tsx diff --git a/frontend/src/components/upload/modals/showCreateUploadModal.tsx b/frontend/src/components/upload/modals/showCreateUploadModal.tsx index cec8bc45..48f6809e 100644 --- a/frontend/src/components/upload/modals/showCreateUploadModal.tsx +++ b/frontend/src/components/upload/modals/showCreateUploadModal.tsx @@ -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: Share, - children: , + children: ( + + ), }); }; 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 ( - {showNotSignedInAlert && ( + {showNotSignedInAlert && !isSignedIn && ( setShowNotSignedInAlert(false)} diff --git a/frontend/src/components/upload/modals/showNotAuthenticatedWarningModal.tsx b/frontend/src/components/upload/modals/showNotAuthenticatedWarningModal.tsx deleted file mode 100644 index bb50378c..00000000 --- a/frontend/src/components/upload/modals/showNotAuthenticatedWarningModal.tsx +++ /dev/null @@ -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: , - }); -}; - -const Body = () => { - const modals = useModals(); - const router = useRouter(); - return ( - <> - - } - 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. - - - - ); -}; - -export default showNotAuthenticatedWarningModal; diff --git a/frontend/src/pages/upload.tsx b/frontend/src/pages/upload.tsx index 5e5993b0..9cc6084f 100644 --- a/frontend/src/pages/upload.tsx +++ b/frontend/src/pages/upload.tsx @@ -99,7 +99,9 @@ const Upload = () => {