Files
calendar/apps/web/modules/auth/verify-email-change-view.tsx
T
853f9bc436 perf: do not import from @calcom/ui barrel file (#20184)
* Icon and IconName

* Button and ButtonGroup

* UserAvatar

* AvatarGroup

* Avatar

* WizardLayout

* Dialogs

* EmptyScreen

* showToast and TextField

* Editor

* Skeleton

* Skeleton

* TopBanner and showToast

* Button again

* more

* perf: Remove app-store reference from @calcom/ui

* more

* Fixing types

* Icon

* Fixed casing

* dropdown

* more

* Select

* more

* Badge

* List

* more

* Divider

* more

* fix

* fix type check

* refactor

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix type check

* fix

* fix

* fix

* fix

* more

* more

* more

* more

* add index file to components/command

* fix

* fix

* fix

* fix imports

* fix

* fix

* fix

* fix

* fix

* fix

* fix

* fix build errors

* fix build errors

* fix

---------

Co-authored-by: Keith Williams <keithwillcode@gmail.com>
2025-03-19 19:00:55 -03:00

49 lines
1.5 KiB
TypeScript

"use client";
import { useSession } from "next-auth/react";
import { useRouter } from "next/navigation";
import { useEffect } from "react";
import React from "react";
import { Toaster } from "sonner";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import type { inferSSRProps } from "@calcom/types/inferSSRProps";
import { showToast } from "@calcom/ui/components/toast";
import type { getServerSideProps } from "@server/lib/auth/verify-email-change/getServerSideProps";
export type PageProps = inferSSRProps<typeof getServerSideProps>;
function VerifyEmailChange(props: PageProps) {
const { update } = useSession();
const { t, isLocaleReady } = useLocale();
const router = useRouter();
useEffect(() => {
async function updateSessionAndDisplayToast() {
await update({ email: props.updatedEmail });
if (isLocaleReady) {
showToast(t("verify_email_change_success_toast", { email: props.updatedEmail }), "success");
}
router.push("/event-types");
}
if (props.updateSession) {
updateSessionAndDisplayToast();
} else {
if (isLocaleReady) {
showToast(t("verify_email_change_failure_toast"), "error");
}
}
// We only need this to run on initial mount. These props can't and won't change due to it being fetched serverside.
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);
return (
<div className="flex h-screen w-full items-center justify-center">
<Toaster position="bottom-right" />
</div>
);
}
export default VerifyEmailChange;