added Modified

master
YasamanKahdooei 2024-04-09 13:53:03 +03:30
parent 0bd15b48ad
commit b69df8c707
8 changed files with 84 additions and 34 deletions

View File

@ -1,9 +1,8 @@
import type { Metadata } from "next"; import type { Metadata } from "next";
import { Inter } from "next/font/google"; import { Inter } from "next/font/google";
import "./globals.css"; import "./globals.css";
import { Toaster } from "@/components/ui/toaster"; import { Toaster } from '@/components/ui/sonner'
import Provider from "../utils/ReactQuery/Provider"; import Provider from "../utils/ReactQuery/Provider";
import { Toaster as SonnerToaster } from "@/components/ui/sonner";
const inter = Inter({ subsets: ["latin"] }); const inter = Inter({ subsets: ["latin"] });
@ -22,8 +21,7 @@ export default function RootLayout({
<body className={inter.className}> <body className={inter.className}>
<Provider> <Provider>
{children} {children}
<Toaster /> <Toaster richColors/>
<SonnerToaster />
</Provider> </Provider>
</body> </body>
</html> </html>

View File

@ -53,26 +53,23 @@ function LoginForm() {
const loginMutation = useMutation({ const loginMutation = useMutation({
mutationFn: logisterCitizen, mutationFn: logisterCitizen,
onSuccess: (res: any | string) => { onSuccess: (res: any | string) => {
router.push("/Verify");
localStorage.setItem("VerifyRole", "citizen"); localStorage.setItem("VerifyRole", "citizen");
localStorage.setItem("verificationToken", res); localStorage.setItem("verificationToken", res);
}, },
onError: (err: any | string) => { onError: (err: any | string) => {
if (err.response.status == 428) { refetch();
router.push("/Verify"); toast.error(err.response.data.detail);
}
}, form.reset({
phoneNumber:"",
captcha: "",
});
// onSuccess: (res: any | string) => { console.log(err);
// router.push("/Verify"); console.log(err.message);
// localStorage.setItem("VerifyRole", "citizen"); console.log(err.detail);
// localStorage.setItem("verificationToken", res); },
// },
// onError: (err: any | string) => {
// refetch();
// toast(<>{err.response.data.detail}</>, {
// className: "!bg-red-500 !text-white",
// });
// },
}); });
// 1. Define your form. // 1. Define your form.
@ -111,12 +108,12 @@ function LoginForm() {
name="phoneNumber" name="phoneNumber"
render={({ field }) => ( render={({ field }) => (
<FormItem className="space-y-2"> <FormItem className="space-y-2">
<FormLabel className="text-black text-lg">تلفن همراه</FormLabel> <FormLabel className="text-black text-lg absolute -mt-4 bg-white mr-4">تلفن همراه</FormLabel>
<FormControl> <FormControl>
<Input <Input
placeholder="09" placeholder="09"
{...field} {...field}
className="bg-white rounded-3xl focus:bg-white hover:bg-white text-center w-full" className=" w-full"
/> />
</FormControl> </FormControl>
<FormMessage className="bg-red text-white text-sm p-1" /> <FormMessage className="bg-red text-white text-sm p-1" />
@ -135,7 +132,7 @@ function LoginForm() {
<Input <Input
placeholder="عبارت امنیتی" placeholder="عبارت امنیتی"
{...field} {...field}
className="bg-white rounded-tr-3xl rounded-br-3xl focus:bg-white hover:bg-white text-center w-full h-10 m-0" className="w-full h-10 m-0"
/> />
</FormControl> </FormControl>
<FormMessage className="bg-red text-white text-sm p-1 mb-4" /> <FormMessage className="bg-red text-white text-sm p-1 mb-4" />
@ -162,7 +159,7 @@ function LoginForm() {
alt="icon" alt="icon"
src={srcForImage as string} src={srcForImage as string}
// src={img1} // src={img1}
className="h-10 rounded-md shadow-md" className="h-10 rounded-sm shadow-md"
width={150} width={150}
height={20} height={20}
quality={100} quality={100}
@ -178,9 +175,23 @@ function LoginForm() {
<Button <Button
type="submit" type="submit"
className="w-full p-2 text-black transition bg-yellow hover:bg-yellow rounded-3xl" className="w-full p-2 text-black transition bg-yellow hover:bg-yellow rounded-xl"
> >
ورود {loginMutation.isPending ? (
<div className="flex items-center justify-center gap-2">
<Oval
visible={true}
height="20"
width="20"
color="#fff"
ariaLabel="oval-loading"
wrapperStyle={{}}
wrapperClass=""
/>
</div>
) : (
"ورود"
)}
</Button> </Button>
</form> </form>
</Form> </Form>

View File

@ -1,14 +1,22 @@
"use client"
import React from 'react' import React from 'react'
import { YellowSection } from '../SignIn/YellowSection' import { YellowSection } from '../SignIn/YellowSection'
import { VerifyInput } from './VerifyInput'
import { Phone } from 'lucide-react';
import useData from "@/store/useData";
const Verify = () => { const Verify = () => {
const data = useData((state) => state.data);
console.log(data);
return ( return (
<section className="bg-yellow flex h-screen w-full items-stretch justify-center overflow-y-hidden"> <section className="bg-yellow flex h-screen w-full items-stretch justify-center overflow-y-hidden">
{/* Right Section */} {/* Right Section */}
<div className="flex flex-1 items-center justify-center flex-col bg-white rounded-tl-[50px]"> <div className="flex flex-1 items-center justify-center flex-col bg-white rounded-tl-[50px]">
{/* <LoginForm /> */} <VerifyInput />
OTP Section
</div> </div>
{/* Left Section */} {/* Left Section */}

View File

@ -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 = () => { export const VerifyInput = () => {
const [otp, setOtp] = useState("");
const space = "\xa0";
const router = useRouter();
const userData = useData((state) => state.data);
const [VerifyRole, setVerifyRole] = useState<any>("");
const saveToken = useToken((state) => state.saveToken);
return ( return (
<div>VerifyInput</div> <>
<p className="text-2xl color-black text-center font-bold">
کد تایید ارسالی به تلفن خود را وارد نمایید.
</p>
</>
) )
} }

View File

@ -12,10 +12,11 @@ const Input = React.forwardRef<HTMLInputElement, InputProps>(
type={type} type={type}
className={cn( 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 `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 3xl:h-9 h-10 transition-all
hover:bg-slate-300 hover:cursor-pointer focus:cursor-auto hover:cursor-pointer focus:cursor-auto
focus:outline-4 focus:outline-slate-300 focus:bg-slate-200 focus:outline-4 focus:outline-slate-300
bg-white focus:bg-white hover:bg-white text-center
`, `,
className className

View File

@ -11,7 +11,7 @@ const Toaster = ({ ...props }: ToasterProps) => {
return ( return (
<Sonner <Sonner
theme={theme as ToasterProps["theme"]} theme={theme as ToasterProps["theme"]}
className="toaster group !font-[yekan]" className="toaster group"
toastOptions={{ toastOptions={{
classNames: { classNames: {
toast: toast:

10
package-lock.json generated
View File

@ -25,6 +25,7 @@
"react-dom": "^18", "react-dom": "^18",
"react-hook-form": "^7.51.2", "react-hook-form": "^7.51.2",
"react-loader-spinner": "^6.1.6", "react-loader-spinner": "^6.1.6",
"react-otp-input": "^3.1.1",
"sonner": "^1.4.41", "sonner": "^1.4.41",
"tailwind-merge": "^2.2.2", "tailwind-merge": "^2.2.2",
"tailwindcss-animate": "^1.0.7", "tailwindcss-animate": "^1.0.7",
@ -4411,6 +4412,15 @@
"resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz", "resolved": "https://registry.npmjs.org/react-is/-/react-is-18.2.0.tgz",
"integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w==" "integrity": "sha512-xWGDIW6x921xtzPkhiULtthJHoJvBbF3q26fzloPCK0hsvxtPVelvftw3zjbHWSkR2km9Z+4uxbDDK/6Zw9B8w=="
}, },
"node_modules/react-otp-input": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/react-otp-input/-/react-otp-input-3.1.1.tgz",
"integrity": "sha512-bjPavgJ0/Zmf/AYi4onj8FbH93IjeD+e8pWwxIJreDEWsU1ILR5fs8jEJmMGWSBe/yyvPP6X/W6Mk9UkOCkTPw==",
"peerDependencies": {
"react": ">=16.8.6 || ^17.0.0 || ^18.0.0",
"react-dom": ">=16.8.6 || ^17.0.0 || ^18.0.0"
}
},
"node_modules/read-cache": { "node_modules/read-cache": {
"version": "1.0.0", "version": "1.0.0",
"resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz", "resolved": "https://registry.npmjs.org/read-cache/-/read-cache-1.0.0.tgz",

View File

@ -26,6 +26,7 @@
"react-dom": "^18", "react-dom": "^18",
"react-hook-form": "^7.51.2", "react-hook-form": "^7.51.2",
"react-loader-spinner": "^6.1.6", "react-loader-spinner": "^6.1.6",
"react-otp-input": "^3.1.1",
"sonner": "^1.4.41", "sonner": "^1.4.41",
"tailwind-merge": "^2.2.2", "tailwind-merge": "^2.2.2",
"tailwindcss-animate": "^1.0.7", "tailwindcss-animate": "^1.0.7",