diff --git a/components/Modal.tsx b/components/Modal.tsx deleted file mode 100644 index 5f8daf9f..00000000 --- a/components/Modal.tsx +++ /dev/null @@ -1,85 +0,0 @@ -import { Dialog, Transition } from "@headlessui/react"; -import { CheckIcon, InformationCircleIcon } from "@heroicons/react/outline"; -import { Fragment, ReactNode } from "react"; - -import classNames from "@lib/classNames"; - -/** - * @deprecated please refactor to use only - */ -export default function Modal(props: { - heading: ReactNode; - description: ReactNode; - handleClose: () => void; - open: boolean; - variant?: "success" | "warning"; -}) { - const { variant = "success" } = props; - return ( - - -
- - - - - {/* This element is to trick the browser into centering the modal contents. */} - - -
-
-
- {variant === "success" && ( -
-
- - {props.heading} - -
-

{props.description}

-
-
-
-
- -
-
-
-
-
-
- ); -} diff --git a/components/security/ChangePasswordSection.tsx b/components/security/ChangePasswordSection.tsx index f64dc628..492f132c 100644 --- a/components/security/ChangePasswordSection.tsx +++ b/components/security/ChangePasswordSection.tsx @@ -2,13 +2,11 @@ import React, { SyntheticEvent, useState } from "react"; import { ErrorCode } from "@lib/auth"; import { useLocale } from "@lib/hooks/useLocale"; - -import Modal from "@components/Modal"; +import showToast from "@lib/notification"; const ChangePasswordSection = () => { const [oldPassword, setOldPassword] = useState(""); const [newPassword, setNewPassword] = useState(""); - const [successModalOpen, setSuccessModalOpen] = useState(false); const [errorMessage, setErrorMessage] = useState(null); const [isSubmitting, setIsSubmitting] = useState(false); const { t } = useLocale(); @@ -18,10 +16,6 @@ const ChangePasswordSection = () => { [ErrorCode.NewPasswordMatchesOld]: t("new_password_matches_old_password"), }; - const closeSuccessModal = () => { - setSuccessModalOpen(false); - }; - async function changePasswordHandler(e: SyntheticEvent) { e.preventDefault(); @@ -44,7 +38,7 @@ const ChangePasswordSection = () => { if (response.status === 200) { setOldPassword(""); setNewPassword(""); - setSuccessModalOpen(true); + showToast(t("password_has_been_changed"), "success"); return; } @@ -112,12 +106,6 @@ const ChangePasswordSection = () => {
- ); }; diff --git a/components/team/EditTeam.tsx b/components/team/EditTeam.tsx index 7e9bcf61..709208d4 100644 --- a/components/team/EditTeam.tsx +++ b/components/team/EditTeam.tsx @@ -3,11 +3,11 @@ import React, { useEffect, useRef, useState } from "react"; import { useLocale } from "@lib/hooks/useLocale"; import { Member } from "@lib/member"; +import showToast from "@lib/notification"; import { Team } from "@lib/team"; import { Dialog, DialogTrigger } from "@components/Dialog"; import ImageUploader from "@components/ImageUploader"; -import Modal from "@components/Modal"; import ConfirmationDialogContent from "@components/dialog/ConfirmationDialogContent"; import MemberInvitationModal from "@components/team/MemberInvitationModal"; import Avatar from "@components/ui/Avatar"; @@ -26,7 +26,6 @@ export default function EditTeam(props: { team: Team | undefined | null; onClose const hideBrandingRef = useRef() as React.MutableRefObject; const logoRef = useRef() as React.MutableRefObject; const [hasErrors, setHasErrors] = useState(false); - const [successModalOpen, setSuccessModalOpen] = useState(false); const [showMemberInvitationModal, setShowMemberInvitationModal] = useState(false); const [inviteModalTeam, setInviteModalTeam] = useState(); const [errorMessage, setErrorMessage] = useState(""); @@ -96,7 +95,7 @@ export default function EditTeam(props: { team: Team | undefined | null; onClose }) .then(handleError) .then(() => { - setSuccessModalOpen(true); + showToast(t("your_team_updated_successfully"), "success"); setHasErrors(false); // dismiss any open errors }) .catch((err) => { @@ -110,10 +109,6 @@ export default function EditTeam(props: { team: Team | undefined | null; onClose setShowMemberInvitationModal(false); }; - const closeSuccessModal = () => { - setSuccessModalOpen(false); - }; - const handleLogoChange = (newLogo: string) => { logoRef.current.value = newLogo; const nativeInputValueSetter = Object.getOwnPropertyDescriptor(HTMLInputElement?.prototype, "value").set; @@ -288,12 +283,6 @@ export default function EditTeam(props: { team: Team | undefined | null; onClose - {showMemberInvitationModal && ( )} diff --git a/pages/event-types/[type].tsx b/pages/event-types/[type].tsx index 56e0c7a8..a2b61091 100644 --- a/pages/event-types/[type].tsx +++ b/pages/event-types/[type].tsx @@ -50,7 +50,6 @@ import { AdvancedOptions, EventTypeInput } from "@lib/types/event-type"; import { inferSSRProps } from "@lib/types/inferSSRProps"; import { Dialog, DialogContent, DialogTrigger } from "@components/Dialog"; -import Modal from "@components/Modal"; import Shell from "@components/Shell"; import ConfirmationDialogContent from "@components/dialog/ConfirmationDialogContent"; import CustomInputTypeForm from "@components/eventtype/CustomInputTypeForm"; @@ -87,7 +86,6 @@ const EventTypePage = (props: inferSSRProps) => { const { t } = useLocale(); const router = useRouter(); - const [successModalOpen, setSuccessModalOpen] = useState(false); const updateMutation = useMutation(updateEventType, { onSuccess: async ({ eventType }) => { @@ -210,10 +208,6 @@ const EventTypePage = (props: inferSSRProps) => { setShowLocationModal(false); }; - const closeSuccessModal = () => { - setSuccessModalOpen(false); - }; - const updateLocations = (e: React.FormEvent) => { e.preventDefault(); const newLocation = e.currentTarget.location.value; @@ -954,12 +948,6 @@ const EventTypePage = (props: inferSSRProps) => { -