2023-08-01 15:20:05 -05:00
|
|
|
import CenteredForm from "@/layouts/CenteredForm";
|
2024-05-20 18:23:11 -05:00
|
|
|
import { signIn } from "next-auth/react";
|
|
|
|
import { useRouter } from "next/router";
|
|
|
|
import React, { useState } from "react";
|
|
|
|
import toast from "react-hot-toast";
|
2024-06-04 15:59:49 -05:00
|
|
|
import { useTranslation } from "next-i18next";
|
|
|
|
import getServerSideProps from "@/lib/client/getServerSideProps";
|
2023-07-12 13:26:34 -05:00
|
|
|
|
2023-07-12 15:34:05 -05:00
|
|
|
export default function EmailConfirmaion() {
|
2024-05-20 18:23:11 -05:00
|
|
|
const router = useRouter();
|
|
|
|
|
2024-06-04 15:59:49 -05:00
|
|
|
const { t } = useTranslation();
|
|
|
|
|
2024-05-20 18:23:11 -05:00
|
|
|
const [submitLoader, setSubmitLoader] = useState(false);
|
|
|
|
|
|
|
|
const resend = async () => {
|
2024-06-04 15:59:49 -05:00
|
|
|
if (submitLoader) return;
|
|
|
|
else if (!router.query.email) return;
|
|
|
|
|
2024-05-20 18:23:11 -05:00
|
|
|
setSubmitLoader(true);
|
|
|
|
|
2024-06-04 15:59:49 -05:00
|
|
|
const load = toast.loading(t("authenticating"));
|
2024-05-20 18:23:11 -05:00
|
|
|
|
|
|
|
const res = await signIn("email", {
|
|
|
|
email: decodeURIComponent(router.query.email as string),
|
|
|
|
callbackUrl: "/",
|
|
|
|
redirect: false,
|
|
|
|
});
|
|
|
|
|
|
|
|
toast.dismiss(load);
|
|
|
|
|
|
|
|
setSubmitLoader(false);
|
|
|
|
|
2024-06-04 15:59:49 -05:00
|
|
|
toast.success(t("verification_email_sent"));
|
2024-05-20 18:23:11 -05:00
|
|
|
};
|
|
|
|
|
2023-07-12 13:26:34 -05:00
|
|
|
return (
|
2023-08-01 15:20:05 -05:00
|
|
|
<CenteredForm>
|
2023-11-26 04:17:08 -06:00
|
|
|
<div className="p-4 max-w-[30rem] min-w-80 w-full rounded-2xl shadow-md mx-auto border border-neutral-content bg-base-200">
|
2023-10-24 14:57:37 -05:00
|
|
|
<p className="text-center text-2xl sm:text-3xl font-extralight mb-2 ">
|
2024-06-04 15:59:49 -05:00
|
|
|
{t("check_your_email")}
|
2023-08-01 15:20:05 -05:00
|
|
|
</p>
|
|
|
|
|
2023-12-01 11:01:56 -06:00
|
|
|
<div className="divider my-3"></div>
|
2023-10-24 14:57:37 -05:00
|
|
|
|
2024-06-04 15:59:49 -05:00
|
|
|
<p>{t("verification_email_sent_desc")}</p>
|
2024-05-20 18:23:11 -05:00
|
|
|
|
|
|
|
<div className="mx-auto w-fit mt-3">
|
|
|
|
<div className="btn btn-ghost btn-sm" onClick={resend}>
|
2024-06-04 15:59:49 -05:00
|
|
|
{t("resend_email")}
|
2024-05-20 18:23:11 -05:00
|
|
|
</div>
|
|
|
|
</div>
|
2023-07-12 13:26:34 -05:00
|
|
|
</div>
|
2023-08-01 15:20:05 -05:00
|
|
|
</CenteredForm>
|
2023-07-12 13:26:34 -05:00
|
|
|
);
|
|
|
|
}
|
2024-06-04 15:59:49 -05:00
|
|
|
|
|
|
|
export { getServerSideProps };
|