|
@@ -1,10 +1,11 @@
|
|
|
"use client";
|
|
"use client";
|
|
|
|
|
|
|
|
import {useState, useLayoutEffect, useEffect} from "react";
|
|
import {useState, useLayoutEffect, useEffect} from "react";
|
|
|
|
|
+import Link from "next/link";
|
|
|
import { useRouter } from 'next/navigation';
|
|
import { useRouter } from 'next/navigation';
|
|
|
import { signIn } from "next-auth/react";
|
|
import { signIn } from "next-auth/react";
|
|
|
import clsx from "clsx";
|
|
import clsx from "clsx";
|
|
|
-import { useForm, Controller } from "react-hook-form";
|
|
|
|
|
|
|
+import { useForm, Controller, type FieldErrors } from "react-hook-form";
|
|
|
import { EMAIL_REGEX, IS_VALID_INPUT, IS_VALID_FULL_PHONE } from "@utils/constants";
|
|
import { EMAIL_REGEX, IS_VALID_INPUT, IS_VALID_FULL_PHONE } from "@utils/constants";
|
|
|
import {mergeCartAction} from "@/actions";
|
|
import {mergeCartAction} from "@/actions";
|
|
|
import { useAppDispatch } from "@/store/hooks";
|
|
import { useAppDispatch } from "@/store/hooks";
|
|
@@ -186,6 +187,15 @@ export default function LoginModal({
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
};
|
|
};
|
|
|
|
|
+
|
|
|
|
|
+ const onRegisterInvalid = (errors: FieldErrors<RegisterFormData>) => {
|
|
|
|
|
+ const message = errors.isAgree?.message;
|
|
|
|
|
+
|
|
|
|
|
+ if (message) {
|
|
|
|
|
+ showToast(message, "warning");
|
|
|
|
|
+ }
|
|
|
|
|
+ };
|
|
|
|
|
+
|
|
|
return (<>
|
|
return (<>
|
|
|
<CommonModal
|
|
<CommonModal
|
|
|
isOpen={isShow}
|
|
isOpen={isShow}
|
|
@@ -230,7 +240,7 @@ export default function LoginModal({
|
|
|
className={clsx("relative box-border px-6",{
|
|
className={clsx("relative box-border px-6",{
|
|
|
"hidden": activeTab !== 'register'
|
|
"hidden": activeTab !== 'register'
|
|
|
})}
|
|
})}
|
|
|
- onSubmit={registerForm.handleSubmit(registerSubmit)}
|
|
|
|
|
|
|
+ onSubmit={registerForm.handleSubmit(registerSubmit,onRegisterInvalid)}
|
|
|
>
|
|
>
|
|
|
|
|
|
|
|
<div className="w-full flex justify-between">
|
|
<div className="w-full flex justify-between">
|
|
@@ -381,13 +391,7 @@ export default function LoginModal({
|
|
|
id="is_agree"
|
|
id="is_agree"
|
|
|
className="absolute opacity-0"
|
|
className="absolute opacity-0"
|
|
|
{...registerForm.register("isAgree", {
|
|
{...registerForm.register("isAgree", {
|
|
|
- validate: (value: boolean) => {
|
|
|
|
|
- if(!value) {
|
|
|
|
|
- showToast('Please Agree To The Terms & Conditions And Privacy Policy.', "warning");
|
|
|
|
|
- return 'Please Agree To The Terms & Conditions And Privacy Policy.';
|
|
|
|
|
- }
|
|
|
|
|
- return true;
|
|
|
|
|
- },
|
|
|
|
|
|
|
+ required: 'Please Agree To The Terms & Conditions And Privacy Policy.'
|
|
|
})}
|
|
})}
|
|
|
/>
|
|
/>
|
|
|
<span className="flex-none mr-2">
|
|
<span className="flex-none mr-2">
|
|
@@ -396,9 +400,9 @@ export default function LoginModal({
|
|
|
</span>
|
|
</span>
|
|
|
<span className="text-ly-12 text-[#666666]">
|
|
<span className="text-ly-12 text-[#666666]">
|
|
|
I Agree To The
|
|
I Agree To The
|
|
|
- Terms & Conditions
|
|
|
|
|
|
|
+ <Link className="underline" href="/terms-conditions">Terms & Conditions</Link>
|
|
|
And
|
|
And
|
|
|
- Privacy Policy
|
|
|
|
|
|
|
+ <Link className="underline" href="/privacy-policy">Privacy Policy</Link>
|
|
|
Of asteriahair.com
|
|
Of asteriahair.com
|
|
|
</span>
|
|
</span>
|
|
|
|
|
|