diff --git a/app/layout.tsx b/app/layout.tsx index 14a8401..7f4216c 100644 --- a/app/layout.tsx +++ b/app/layout.tsx @@ -1,9 +1,8 @@ import type { Metadata } from "next"; import { Inter } from "next/font/google"; import "./globals.css"; -import { Toaster } from "@/components/ui/toaster"; -import Provider from "../utils/ReactQuery/Provider"; -import { Toaster as SonnerToaster } from "@/components/ui/sonner"; +import { Toaster } from '@/components/ui/sonner' +import Provider from "../utils/ReactQuery/Provider"; const inter = Inter({ subsets: ["latin"] }); @@ -22,8 +21,7 @@ export default function RootLayout({ {children} - - + diff --git a/components/SignIn/LoginForm.tsx b/components/SignIn/LoginForm.tsx index 960744a..41d4d67 100644 --- a/components/SignIn/LoginForm.tsx +++ b/components/SignIn/LoginForm.tsx @@ -53,26 +53,23 @@ function LoginForm() { const loginMutation = useMutation({ mutationFn: logisterCitizen, onSuccess: (res: any | string) => { + router.push("/Verify"); localStorage.setItem("VerifyRole", "citizen"); localStorage.setItem("verificationToken", res); }, onError: (err: any | string) => { - if (err.response.status == 428) { - router.push("/Verify"); - } - }, + refetch(); + toast.error(err.response.data.detail); + + form.reset({ + phoneNumber:"", + captcha: "", + }); - // onSuccess: (res: any | string) => { - // router.push("/Verify"); - // localStorage.setItem("VerifyRole", "citizen"); - // localStorage.setItem("verificationToken", res); - // }, - // onError: (err: any | string) => { - // refetch(); - // toast(<>{err.response.data.detail}, { - // className: "!bg-red-500 !text-white", - // }); - // }, + console.log(err); + console.log(err.message); + console.log(err.detail); + }, }); // 1. Define your form. @@ -111,12 +108,12 @@ function LoginForm() { name="phoneNumber" render={({ field }) => ( - تلفن همراه + تلفن همراه @@ -135,7 +132,7 @@ function LoginForm() { @@ -162,7 +159,7 @@ function LoginForm() { alt="icon" src={srcForImage as string} // src={img1} - className="h-10 rounded-md shadow-md" + className="h-10 rounded-sm shadow-md" width={150} height={20} quality={100} @@ -178,9 +175,23 @@ function LoginForm() { diff --git a/components/Verify/Verify.tsx b/components/Verify/Verify.tsx index b8594c1..cc77bc4 100644 --- a/components/Verify/Verify.tsx +++ b/components/Verify/Verify.tsx @@ -1,14 +1,22 @@ +"use client" import React from 'react' import { YellowSection } from '../SignIn/YellowSection' +import { VerifyInput } from './VerifyInput' +import { Phone } from 'lucide-react'; +import useData from "@/store/useData"; const Verify = () => { + const data = useData((state) => state.data); + + + console.log(data); + return (
{/* Right Section */}
- {/* */} - OTP Section +
{/* Left Section */} diff --git a/components/Verify/VerifyInput.tsx b/components/Verify/VerifyInput.tsx index 1bb818e..643a027 100644 --- a/components/Verify/VerifyInput.tsx +++ b/components/Verify/VerifyInput.tsx @@ -1,7 +1,28 @@ -import React from 'react' +"use client" +import React, { useState ,useEffect } from 'react' +import OtpInput from "react-otp-input"; +import { useMutation } from "@tanstack/react-query"; +import { useRouter } from "next/navigation"; +import useData from "@/store/useData"; +import { setCookie } from "cookies-next"; +import { Oval, Triangle } from "react-loader-spinner"; +import useToken from "@/store/useToken"; +import { toast } from "sonner"; + export const VerifyInput = () => { + const [otp, setOtp] = useState(""); + const space = "\xa0"; + const router = useRouter(); + const userData = useData((state) => state.data); + const [VerifyRole, setVerifyRole] = useState(""); + const saveToken = useToken((state) => state.saveToken); + return ( -
VerifyInput
+ <> +

+ کد تایید ارسالی به تلفن خود را وارد نمایید. +

+ ) } diff --git a/components/ui/input.tsx b/components/ui/input.tsx index 5b1aeeb..60b97d9 100644 --- a/components/ui/input.tsx +++ b/components/ui/input.tsx @@ -12,10 +12,11 @@ const Input = React.forwardRef( type={type} className={cn( `flex w-full rounded-md border border-input px-3 py-2 ring-offset-background file:border-0 file:bg-transparent file:text-sm file:font-medium placeholder:text-muted-foreground disabled:cursor-not-allowed disabled:opacity-50 - text-black text-opacity-50 text-xs font-normal bg-slate-200 mb-3 + text-black text-opacity-50 text-xs font-normal mb-3 3xl:h-9 h-10 transition-all - hover:bg-slate-300 hover:cursor-pointer focus:cursor-auto - focus:outline-4 focus:outline-slate-300 focus:bg-slate-200 + hover:cursor-pointer focus:cursor-auto + focus:outline-4 focus:outline-slate-300 + bg-white focus:bg-white hover:bg-white text-center `, className diff --git a/components/ui/sonner.tsx b/components/ui/sonner.tsx index 593c458..452f4d9 100644 --- a/components/ui/sonner.tsx +++ b/components/ui/sonner.tsx @@ -11,7 +11,7 @@ const Toaster = ({ ...props }: ToasterProps) => { return ( =16.8.6 || ^17.0.0 || ^18.0.0", + "react-dom": ">=16.8.6 || ^17.0.0 || ^18.0.0" + } + }, "node_modules/read-cache": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", diff --git a/package.json b/package.json index 40a1b8e..814bfb4 100644 --- a/package.json +++ b/package.json @@ -26,6 +26,7 @@ "react-dom": "^18", "react-hook-form": "^7.51.2", "react-loader-spinner": "^6.1.6", + "react-otp-input": "^3.1.1", "sonner": "^1.4.41", "tailwind-merge": "^2.2.2", "tailwindcss-animate": "^1.0.7",