finalized password reset + code refactoring

This commit is contained in:
daniel31x13
2024-05-20 19:23:11 -04:00
parent 73dda21573
commit 329019b34e
12 changed files with 239 additions and 118 deletions
+35 -9
View File
@@ -1,8 +1,33 @@
import CenteredForm from "@/layouts/CenteredForm";
import { signIn } from "next-auth/react";
import Link from "next/link";
import React from "react";
import { useRouter } from "next/router";
import React, { useState } from "react";
import toast from "react-hot-toast";
export default function EmailConfirmaion() {
const router = useRouter();
const [submitLoader, setSubmitLoader] = useState(false);
const resend = async () => {
setSubmitLoader(true);
const load = toast.loading("Authenticating...");
const res = await signIn("email", {
email: decodeURIComponent(router.query.email as string),
callbackUrl: "/",
redirect: false,
});
toast.dismiss(load);
setSubmitLoader(false);
toast.success("Verification email sent.");
};
return (
<CenteredForm>
<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">
@@ -12,15 +37,16 @@ export default function EmailConfirmaion() {
<div className="divider my-3"></div>
<p>A sign in link has been sent to your email address.</p>
<p className="mt-3">
Didn&apos;t see the email? Check your spam folder or visit the{" "}
<Link href="/forgot" className="font-bold underline">
Password Recovery
</Link>{" "}
page to resend the link.
<p>
A sign in link has been sent to your email address. If you don't see
the email, check your spam folder.
</p>
<div className="mx-auto w-fit mt-3">
<div className="btn btn-ghost btn-sm" onClick={resend}>
Resend Email
</div>
</div>
</div>
</CenteredForm>
);