bugfix - fixed deployment
This commit is contained in:
parent
7fa3a2034a
commit
ead5e4a1ff
|
@ -1,13 +1,12 @@
|
||||||
import React from "react";
|
import React, { useRef } from "react";
|
||||||
import Icon from "@/components/Icons/Icon";
|
import Icon from "@/components/Icons/Icon";
|
||||||
import { useForm } from "react-hook-form";
|
import { useForm } from "react-hook-form";
|
||||||
import { yupResolver } from "@hookform/resolvers/yup";
|
import { yupResolver } from "@hookform/resolvers/yup";
|
||||||
import { signInValidationSchema } from "@/utils/form";
|
import { signInValidationSchema } from "@/utils/form";
|
||||||
import { login } from "@/app/actions";
|
|
||||||
import { toast } from "react-toastify";
|
import { toast } from "react-toastify";
|
||||||
import pb from "@/lib/pocketbase";
|
import pb from "@/lib/pocketbase";
|
||||||
|
|
||||||
function ModalPasswordReset() {
|
function ModalEmailChange() {
|
||||||
const {
|
const {
|
||||||
register,
|
register,
|
||||||
handleSubmit,
|
handleSubmit,
|
||||||
|
@ -18,12 +17,12 @@ function ModalPasswordReset() {
|
||||||
});
|
});
|
||||||
|
|
||||||
const onSubmit = async (data: any) => {
|
const onSubmit = async (data: any) => {
|
||||||
|
console.log(data);
|
||||||
try {
|
try {
|
||||||
//login user
|
//login user
|
||||||
if (
|
if (await pb.collection("user").requestPasswordReset(data.email)) {
|
||||||
(await login({ email: data.email, password: data.password })).success
|
|
||||||
) {
|
|
||||||
reset();
|
reset();
|
||||||
|
document.getElementById("password-reset-modal")?.click();
|
||||||
document.getElementById("sign-in-modal")?.click();
|
document.getElementById("sign-in-modal")?.click();
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
@ -45,17 +44,17 @@ function ModalPasswordReset() {
|
||||||
<>
|
<>
|
||||||
<input
|
<input
|
||||||
type="checkbox"
|
type="checkbox"
|
||||||
id="sign-in-modal"
|
id="password-reset-modal"
|
||||||
className="modal-toggle"
|
className="modal-toggle"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
reset();
|
reset();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
<label htmlFor="sign-in-modal" className="modal cursor-pointer">
|
<label htmlFor="password-reset-modal" className="modal cursor-pointer">
|
||||||
<label className="modal-box relative bg-base-100 max-w-full md:max-w-[550px] py-4 px-3 md:p-6">
|
<label className="modal-box relative bg-base-100 max-w-full md:max-w-[450px] py-4 px-3 md:p-6">
|
||||||
<div className="flex justify-end pb-2 select-none">
|
<div className="flex justify-end pb-2 select-none">
|
||||||
<label
|
<label
|
||||||
htmlFor="sign-in-modal"
|
htmlFor="password-reset-modal"
|
||||||
className="cursor-pointer text-base-content"
|
className="cursor-pointer text-base-content"
|
||||||
>
|
>
|
||||||
<Icon name="Dismiss20Filled" size="medium" />
|
<Icon name="Dismiss20Filled" size="medium" />
|
||||||
|
@ -64,9 +63,9 @@ function ModalPasswordReset() {
|
||||||
<div>
|
<div>
|
||||||
<div className="w-[100%] bg-gradient-to-r from-primary to-secondary px-6 pt-2 mt-3 pb-6 rounded-lg text-primary-content">
|
<div className="w-[100%] bg-gradient-to-r from-primary to-secondary px-6 pt-2 mt-3 pb-6 rounded-lg text-primary-content">
|
||||||
<h3 className="pb-1 text-3xl font-bold md:text-3xl pt-6">
|
<h3 className="pb-1 text-3xl font-bold md:text-3xl pt-6">
|
||||||
Welcome back!
|
Reset Your Password
|
||||||
</h3>
|
</h3>
|
||||||
<p className="text-sm md:text-base">Lets kick some more ass?</p>
|
<p className="text-sm md:text-base">Enter in your email</p>
|
||||||
</div>
|
</div>
|
||||||
<form onSubmit={handleSubmit(onSubmit)} className="w-full">
|
<form onSubmit={handleSubmit(onSubmit)} className="w-full">
|
||||||
<div className="relative mt-6">
|
<div className="relative mt-6">
|
||||||
|
@ -82,35 +81,15 @@ function ModalPasswordReset() {
|
||||||
{errors.email?.message}
|
{errors.email?.message}
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="relative mt-1 mb-2 ">
|
|
||||||
<input
|
|
||||||
type="password"
|
|
||||||
className="py-3 px-4 block w-full bg-base-200 text-base-content border-primary/40 rounded-lg text-sm focus:border-secondary focus:ring-secondary disabled:opacity-50 disabled:pointer-events-none "
|
|
||||||
placeholder="Your password..."
|
|
||||||
aria-label="Your password..."
|
|
||||||
{...register("password")}
|
|
||||||
/>
|
|
||||||
<div className="text-start text-sm italic text-error-content">
|
|
||||||
{errors.password?.message}
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div className="flex flex-row w-full justify-between">
|
<div className="flex flex-row w-full justify-between">
|
||||||
<button
|
<button
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
type="submit"
|
type="submit"
|
||||||
className="btn btn-primary"
|
className="btn btn-primary"
|
||||||
>
|
|
||||||
Sign In
|
|
||||||
{isSubmitting && <div className="loading"></div>}
|
|
||||||
</button>
|
|
||||||
<button
|
|
||||||
onClick={() =>
|
|
||||||
pb.collection("user").requestPasswordReset(user.email)
|
|
||||||
}
|
|
||||||
className="btn btn-secondary text-primary-content capitalize border-none"
|
|
||||||
>
|
>
|
||||||
Reset Password
|
Reset Password
|
||||||
|
{isSubmitting && <div className="loading"></div>}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
|
@ -121,4 +100,4 @@ function ModalPasswordReset() {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
export default ModalPasswordReset;
|
export default ModalEmailChange;
|
||||||
|
|
Loading…
Reference in New Issue