2023-06-07 07:27:48 +00:00
|
|
|
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();
|
2023-06-07 07:27:48 +00:00
|
|
|
const mutation = trpc.viewer.auth.resendVerifyEmail.useMutation();
|
|
|
|
|
2023-06-15 06:11:32 +00:00
|
|
|
if (isLoading || data?.isVerified || !flags["email-verification"]) return null;
|
2023-06-07 07:27:48 +00:00
|
|
|
|
|
|
|
return (
|
|
|
|
<>
|
|
|
|
<TopBanner
|
|
|
|
text={t("verify_email_banner_body", { appName: APP_NAME })}
|
|
|
|
variant="warning"
|
|
|
|
actions={
|
|
|
|
<Button
|
|
|
|
onClick={() => {
|
|
|
|
mutation.mutate();
|
|
|
|
showToast(t("email_sent"), "success");
|
|
|
|
}}>
|
2023-06-08 13:37:54 +00:00
|
|
|
{t("send_email")}
|
2023-06-07 07:27:48 +00:00
|
|
|
</Button>
|
|
|
|
}
|
|
|
|
/>
|
|
|
|
</>
|
|
|
|
);
|
|
|
|
}
|
|
|
|
|
|
|
|
export default VerifyEmailBanner;
|