-
Notifications
You must be signed in to change notification settings - Fork 6.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor two modals #861
Refactor two modals #861
Changes from all commits
2e63b24
4b37893
6d7069c
389b4fd
54d4721
34257bf
3e9c04b
4641ae0
aec883a
ab6d34a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); | ||
}} | ||
/> | ||
|
||
<Modal | ||
heading="This feature is only available in paid plan" | ||
variant="warning" | ||
description={ | ||
<Dialog open={modelOpen}> | ||
<DialogContent> | ||
<div className="mx-auto flex items-center justify-center h-12 w-12 rounded-full bg-yellow-100 mb-4"> | ||
<InformationCircleIcon className="h-6 w-6 text-yellow-400" aria-hidden="true" /> | ||
</div> | ||
<div className="sm:flex sm:items-start mb-4"> | ||
<div className="mt-3 sm:mt-0 sm:text-left"> | ||
<h3 className="font-cal text-lg leading-6 font-bold text-gray-900" id="modal-title"> | ||
This feature is only available in paid plan | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should probably be "Pro plan". Not technically related to this PR There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. agree |
||
</h3> | ||
</div> | ||
</div> | ||
<div className="flex flex-col space-y-3"> | ||
<p> | ||
In order to remove the Cal branding from your booking pages, you need to upgrade to a paid | ||
|
@@ -82,18 +91,22 @@ function HideBrandingInput(props: { | |
. | ||
</p> | ||
</div> | ||
} | ||
open={modelOpen} | ||
handleClose={() => setModalOpen(false)} | ||
/> | ||
<div className="mt-5 sm:mt-4 sm:flex sm:flex-row-reverse gap-x-2"> | ||
<DialogClose asChild> | ||
<Button className="btn-wide btn-primary text-center" onClick={() => setModalOpen(false)}> | ||
<span className="m-auto">Dismiss</span> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this span needed? |
||
</Button> | ||
</DialogClose> | ||
</div> | ||
</DialogContent> | ||
</Dialog> | ||
</> | ||
); | ||
} | ||
|
||
export default function Settings(props: Props) { | ||
const mutation = trpc.useMutation("viewer.updateProfile"); | ||
|
||
const [successModalOpen, setSuccessModalOpen] = useState(false); | ||
const usernameRef = useRef<HTMLInputElement>(null); | ||
const nameRef = useRef<HTMLInputElement>(null); | ||
const descriptionRef = useRef<HTMLTextAreaElement>(); | ||
|
@@ -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) { | |
</div> | ||
</div> | ||
</form> | ||
<Modal | ||
heading="Profile updated successfully" | ||
description="Your user profile has been updated successfully." | ||
open={successModalOpen} | ||
handleClose={closeSuccessModal} | ||
/> | ||
</SettingsShell> | ||
</Shell> | ||
); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if it is possible to wrap the
<input>
with<DialogTrigger asChild>
with e.stopPropagation(); like:In no way something that needs doing; but one can be curious.