From 0871f5edf885705743d579a23a5eb5bff2e6b021 Mon Sep 17 00:00:00 2001 From: Anton Podviaznikov Date: Tue, 12 Oct 2021 12:43:22 -0700 Subject: [PATCH] Refactor two modals (#861) * refactor one modal into dialog. save profile --- pages/settings/profile.tsx | 47 ++++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 22 deletions(-) diff --git a/pages/settings/profile.tsx b/pages/settings/profile.tsx index 66698310..c49cda1a 100644 --- a/pages/settings/profile.tsx +++ b/pages/settings/profile.tsx @@ -1,3 +1,4 @@ +import { InformationCircleIcon } from "@heroicons/react/outline"; import crypto from "crypto"; import { GetServerSidePropsContext } from "next"; import { serverSideTranslations } from "next-i18next/serverSideTranslations"; @@ -14,12 +15,13 @@ import { OptionType, } from "@lib/core/i18n/i18n.utils"; import { isBrandingHidden } from "@lib/isBrandingHidden"; +import showToast from "@lib/notification"; import prisma from "@lib/prisma"; import { trpc } from "@lib/trpc"; import { inferSSRProps } from "@lib/types/inferSSRProps"; +import { DialogClose, Dialog, DialogContent } from "@components/Dialog"; import ImageUploader from "@components/ImageUploader"; -import Modal from "@components/Modal"; import SettingsShell from "@components/SettingsShell"; import Shell from "@components/Shell"; import { Alert } from "@components/ui/Alert"; @@ -62,11 +64,18 @@ function HideBrandingInput(props: { setModalOpen(true); }} /> - - + +
+
+
+
+ +
+

In order to remove the Cal branding from your booking pages, you need to upgrade to a paid @@ -82,10 +91,15 @@ function HideBrandingInput(props: { .

- } - open={modelOpen} - handleClose={() => setModalOpen(false)} - /> +
+ + + +
+
+ ); } @@ -93,7 +107,6 @@ function HideBrandingInput(props: { export default function Settings(props: Props) { const mutation = trpc.useMutation("viewer.updateProfile"); - const [successModalOpen, setSuccessModalOpen] = useState(false); const usernameRef = useRef(null); const nameRef = useRef(null); const descriptionRef = useRef(); @@ -123,10 +136,6 @@ export default function Settings(props: Props) { setSelectedLanguage({ value: props.localeProp, label: props.localeLabels[props.localeProp] }); }, []); - const closeSuccessModal = () => { - setSuccessModalOpen(false); - }; - const handleAvatarChange = (newAvatar) => { avatarRef.current.value = newAvatar; const nativeInputValueSetter = Object.getOwnPropertyDescriptor( @@ -167,7 +176,7 @@ export default function Settings(props: Props) { locale: enteredLanguage, }) .then(() => { - setSuccessModalOpen(true); + showToast("Your user profile has been updated successfully", "success"); setHasErrors(false); // dismiss any open errors }) .catch((err) => { @@ -411,12 +420,6 @@ export default function Settings(props: Props) { - );