feat : add code verifaction for authorization
This commit is contained in:
@@ -4,27 +4,44 @@ import { useState } from "react";
|
|||||||
import LoginNumberOrEmail from "./components/LoginNumberOrEmail";
|
import LoginNumberOrEmail from "./components/LoginNumberOrEmail";
|
||||||
import { motion } from "framer-motion";
|
import { motion } from "framer-motion";
|
||||||
import Rabbit from "./components/Rabbit";
|
import Rabbit from "./components/Rabbit";
|
||||||
|
import OTPInput from "react-otp-input";
|
||||||
|
|
||||||
const Login = () => {
|
const Login = () => {
|
||||||
const [loginWithEmail, setLoginWithEmail] = useState<boolean>(false);
|
const [loginWithEmail, setLoginWithEmail] = useState<boolean>(false);
|
||||||
const [inputText, setInputText] = useState<boolean>(false);
|
const [inputText, setInputText] = useState<boolean>(false);
|
||||||
const [inputPassword, setInputPassword] = useState<boolean>(false);
|
const [inputPassword, setInputPassword] = useState<boolean>(false);
|
||||||
|
|
||||||
|
const [authCode, setAuthCode] = useState<boolean>(false);
|
||||||
|
const [errorCode, setErrorCode] = useState<boolean>(false);
|
||||||
|
|
||||||
|
const [otp, setOtp] = useState<string>("");
|
||||||
|
|
||||||
|
const handleChange = (otp: string) => {
|
||||||
|
setOtp(otp);
|
||||||
|
if (otp === "1111" && otp.length === 4)
|
||||||
|
setAuthCode(true), setErrorCode(false);
|
||||||
|
else if (otp.length === 4) setErrorCode(true), setAuthCode(false);
|
||||||
|
else setAuthCode(false), setErrorCode(false);
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<div className="w-4/5 rounded-lg shadow md:mt-0 sm:max-w-md xl:p-0 glass">
|
<div className="w-4/5 rounded-lg shadow md:mt-0 sm:max-w-md xl:p-0 glass">
|
||||||
<Rabbit focusInputText={inputText} focusInputPassword={inputPassword} />
|
{/* <Rabbit focusInputText={inputText} focusInputPassword={inputPassword} /> */}
|
||||||
<div className="p-6 space-y-4 md:space-y-6 sm:p-8">
|
<div className="p-6 space-y-4 md:space-y-6 sm:p-8">
|
||||||
<h1 className="text-2xl font-bold text-center leading-tight tracking-tight md:text-3xl text-white">
|
<h1 className="text-2xl font-bold text-center leading-tight tracking-tight md:text-3xl text-white">
|
||||||
ورود
|
ورود
|
||||||
</h1>
|
</h1>
|
||||||
<LoginNumberOrEmail
|
<h1 className="text-base text-center leading-tight tracking-tight md:text-lg text-white">
|
||||||
|
کد ارسال شده رو وارد نمایید:
|
||||||
|
</h1>
|
||||||
|
{/* <LoginNumberOrEmail
|
||||||
loginWithEmail={loginWithEmail}
|
loginWithEmail={loginWithEmail}
|
||||||
setLoginWithEmail={setLoginWithEmail}
|
setLoginWithEmail={setLoginWithEmail}
|
||||||
/>
|
/> */}
|
||||||
<form className="flex flex-col gap-10">
|
<form className="flex flex-col gap-10">
|
||||||
<div className="w-full h-full flex flex-col gap-2">
|
<div className="w-full h-full flex flex-col gap-2">
|
||||||
{!loginWithEmail && (
|
{/* {!loginWithEmail && (
|
||||||
<motion.div
|
<motion.div
|
||||||
initial={{ x: "100vw", opacity: 0 }}
|
initial={{ x: "100vw", opacity: 0 }}
|
||||||
animate={{ x: 0, opacity: 1 }}
|
animate={{ x: 0, opacity: 1 }}
|
||||||
@@ -53,11 +70,52 @@ const Login = () => {
|
|||||||
onBlur={() => setInputText(false)}
|
onBlur={() => setInputText(false)}
|
||||||
/>
|
/>
|
||||||
</motion.div>
|
</motion.div>
|
||||||
)}
|
)} */}
|
||||||
|
<OTPInput
|
||||||
|
value={otp}
|
||||||
|
onChange={handleChange}
|
||||||
|
numInputs={4}
|
||||||
|
inputStyle={{
|
||||||
|
width: "3rem",
|
||||||
|
height: "3rem",
|
||||||
|
margin: "0 0.5rem",
|
||||||
|
fontSize: "2rem",
|
||||||
|
borderRadius: "4px",
|
||||||
|
border: "none",
|
||||||
|
outline: "none",
|
||||||
|
textAlign: "center",
|
||||||
|
direction: "ltr",
|
||||||
|
}}
|
||||||
|
shouldAutoFocus={true}
|
||||||
|
containerStyle={{
|
||||||
|
display: "flex",
|
||||||
|
flexDirection: "row-reverse",
|
||||||
|
justifyContent: "center",
|
||||||
|
}}
|
||||||
|
renderInput={(props) => (
|
||||||
|
<motion.input
|
||||||
|
{...props}
|
||||||
|
type="number"
|
||||||
|
initial={{
|
||||||
|
y: 20,
|
||||||
|
opacity: 0,
|
||||||
|
border: "2px solid transparent",
|
||||||
|
}}
|
||||||
|
animate={{
|
||||||
|
y: 0,
|
||||||
|
opacity: 1,
|
||||||
|
border: `2px solid ${
|
||||||
|
authCode ? "green" : errorCode ? "red" : "transparent"
|
||||||
|
}`,
|
||||||
|
}}
|
||||||
|
className={`bg-gray-800 focus:outline-none focus:ring-1 focus:ring-gray-600 shadow-md max-sm:!w-[2.5rem] max-sm:!h-[2.5rem] shadow-gray-900 ${props.className}`}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div className="w-full h-full grid grid-cols-1">
|
<div className="w-full h-full grid grid-cols-1">
|
||||||
<Button extra="py-2">ورود</Button>
|
<Button extra="py-2">تایید</Button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ const BestQuality = () => {
|
|||||||
<div className="w-full h-full flex flex-col gap-2 md:gap-4 justify-center items-center">
|
<div className="w-full h-full flex flex-col gap-2 md:gap-4 justify-center items-center">
|
||||||
<h1 className="max-md:text-xl md:text-4xl font-bold">
|
<h1 className="max-md:text-xl md:text-4xl font-bold">
|
||||||
به عنوان{" "}
|
به عنوان{" "}
|
||||||
<span className="max-md:text-xl md:text-5xl text-yellow-600 font-bold">
|
<span className="max-md:text-xl md:text-5xl text-secondTheme font-bold">
|
||||||
اولین و بهترین
|
اولین و بهترین
|
||||||
</span>{" "}
|
</span>{" "}
|
||||||
ارائه دهنده{" "}
|
ارائه دهنده{" "}
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ const Intro = () => {
|
|||||||
<div className="w-full h-full flex flex-col gap-8 justify-center mx-auto items-center">
|
<div className="w-full h-full flex flex-col gap-8 justify-center mx-auto items-center">
|
||||||
<h1 className="text-start flex flex-col gap-3 md:gap-4 text-3xl md:text-4xl lg:text-5xl">
|
<h1 className="text-start flex flex-col gap-3 md:gap-4 text-3xl md:text-4xl lg:text-5xl">
|
||||||
<span className="inline-block">بزرگترین فروشگاه</span>
|
<span className="inline-block">بزرگترین فروشگاه</span>
|
||||||
<span className="text-yellow-600 font-bold max-md:text-center">
|
<span className="text-secondTheme font-bold max-md:text-center">
|
||||||
کاهش پینگ
|
کاهش پینگ
|
||||||
</span>{" "}
|
</span>{" "}
|
||||||
<span className="inline-block max-md:text-center">در ایران</span>
|
<span className="inline-block max-md:text-center">در ایران</span>
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ const ListAllProduct = ({ activeId }: { activeId: number }) => {
|
|||||||
}, [activeId]);
|
}, [activeId]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="w-full h-full border-4 gap-5 border-spacing-1 border-solid border-yellow-600 rounded-lg p-3 grid max-sm:grid-cols-1 max-md:grid-cols-2 max-lg:grid-cols-3 lg:grid-cols-4">
|
<div className="w-full h-full border-4 gap-5 border-spacing-1 border-solid border-secondTheme rounded-lg p-3 grid max-sm:grid-cols-1 max-md:grid-cols-2 max-lg:grid-cols-3 lg:grid-cols-4">
|
||||||
{dataProduct?.map((item) => {
|
{dataProduct?.map((item) => {
|
||||||
return (
|
return (
|
||||||
<Fragment key={item.id}>
|
<Fragment key={item.id}>
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ const ListTutorials = ({
|
|||||||
return (
|
return (
|
||||||
<li
|
<li
|
||||||
className={`text-center text-sm md:text-lg ${
|
className={`text-center text-sm md:text-lg ${
|
||||||
i.id === activeTutorial ? "bg-yellow-600" : "bg-gray-800"
|
i.id === activeTutorial ? "bg-secondTheme" : "bg-gray-800"
|
||||||
} rounded-md p-2 cursor-pointer`}
|
} rounded-md p-2 cursor-pointer`}
|
||||||
onClick={() => setActiveTutorial(i.id)}
|
onClick={() => setActiveTutorial(i.id)}
|
||||||
key={i.id}
|
key={i.id}
|
||||||
|
|||||||
13
src/types/props.d.ts
vendored
13
src/types/props.d.ts
vendored
@@ -66,18 +66,18 @@ export type LearnProps = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// begin TypeWriter.tsx
|
// begin TypeWriter.tsx
|
||||||
interface TypewriterProps {
|
export interface TypewriterProps {
|
||||||
text: string;
|
text: string;
|
||||||
speed?: number; // سرعت تایپ در میلیثانیه
|
speed?: number; // سرعت تایپ در میلیثانیه
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ButtonListProps {
|
export interface ButtonListProps {
|
||||||
ProductsList: { id: number; title: string }[];
|
ProductsList: { id: number; title: string }[];
|
||||||
activeId: number;
|
activeId: number;
|
||||||
setActiveId: SetStateAction;
|
setActiveId: SetStateAction;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface ProductBoxProps {
|
export interface ProductBoxProps {
|
||||||
title: string;
|
title: string;
|
||||||
space: number;
|
space: number;
|
||||||
users: number;
|
users: number;
|
||||||
@@ -86,7 +86,7 @@ interface ProductBoxProps {
|
|||||||
variant: number;
|
variant: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
export interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
||||||
label: string;
|
label: string;
|
||||||
id?: string;
|
id?: string;
|
||||||
type: string;
|
type: string;
|
||||||
@@ -94,3 +94,8 @@ interface InputProps extends InputHTMLAttributes<HTMLInputElement> {
|
|||||||
placeholder?: string;
|
placeholder?: string;
|
||||||
extra?: string;
|
extra?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export interface MuiModalProps {
|
||||||
|
isOpenModal: boolean;
|
||||||
|
setIsOpenModal:SetStateAction
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user