Skip to content

Commit

Permalink
fix: reload Verify email page (#1851)
Browse files Browse the repository at this point in the history
Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
  • Loading branch information
Dhruwang and mattinannt committed Jan 3, 2024
1 parent 60c7713 commit 0d74921
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";

import { resendVerificationEmail } from "@/app/lib/users/users";
import { useEffect } from "react";
import toast from "react-hot-toast";

import { Button } from "@formbricks/ui/Button";
Expand All @@ -10,6 +11,20 @@ interface RequestEmailVerificationProps {
}

export const RequestVerificationEmail = ({ email }: RequestEmailVerificationProps) => {
useEffect(() => {
const handleVisibilityChange = () => {
if (document.visibilityState === "visible") {
location.reload();
}
};

document.addEventListener("visibilitychange", handleVisibilityChange);

return () => {
document.removeEventListener("visibilitychange", handleVisibilityChange);
};
}, []);

const requestVerificationEmail = async () => {
try {
if (!email) throw new Error("No email provided");
Expand All @@ -19,6 +34,7 @@ export const RequestVerificationEmail = ({ email }: RequestEmailVerificationProp
toast.error(`Error: ${e.message}`);
}
};

return (
<>
<Button variant="secondary" onClick={requestVerificationEmail} className="w-full justify-center">
Expand Down

2 comments on commit 0d74921

@vercel
Copy link

@vercel vercel bot commented on 0d74921 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

formbricks-com – ./apps/formbricks-com

formbricks-com-formbricks.vercel.app
formbricks-com.vercel.app
formbricks-com-git-main-formbricks.vercel.app
www.formbricks.com
formbricks.com

@vercel
Copy link

@vercel vercel bot commented on 0d74921 Jan 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

formbricks-cloud – ./apps/web

formbricks-cloud-formbricks.vercel.app
formbricks-cloud-git-main-formbricks.vercel.app

Please sign in to comment.