cal.pub0.org/packages/features/users/components/VerifyEmailBanner.tsx

41 lines
1.2 KiB
TypeScript
Raw Normal View History

import { useSession } from "next-auth/react";
import { APP_NAME } from "@calcom/lib/constants";
import { useLocale } from "@calcom/lib/hooks/useLocale";
import { trpc } from "@calcom/trpc";
import useEmailVerifyCheck from "@calcom/trpc/react/hooks/useEmailVerifyCheck";
import { Button, TopBanner, showToast } from "@calcom/ui";
import { useFlagMap } from "../../flags/context/provider";
function VerifyEmailBanner() {
const flags = useFlagMap();
const { t } = useLocale();
2023-06-15 06:11:32 +00:00
const { data, isLoading } = useEmailVerifyCheck();
const mutation = trpc.viewer.auth.resendVerifyEmail.useMutation();
const session = useSession();
const isLoggedIn = session?.data?.user;
if (!isLoggedIn || isLoading || data?.isVerified || !flags["email-verification"]) return null;
return (
<>
<TopBanner
text={t("verify_email_banner_body", { appName: APP_NAME })}
variant="warning"
actions={
<Button
onClick={() => {
mutation.mutate();
showToast(t("email_sent"), "success");
}}>
{t("send_email")}
</Button>
}
/>
</>
);
}
export default VerifyEmailBanner;