Some Changes

Danovin Api Removed
Sign Up OTP Completed (Has Interface Bugs)
Exams Started
main
Pedram Keshavarzi 3 years ago
parent 8f28c64106
commit aa2756a828
  1. 46
      src/components/Product/index.js
  2. 84
      src/components/Timer/index.js
  3. 8
      src/components/Timer/index.scss
  4. 4
      src/components/input/index.js
  5. 195
      src/components/input/signUpInput.js
  6. 6
      src/constants/defaultValues.js
  7. 35
      src/view/LoginSignUp/SignUpForm/index.js
  8. 267
      src/view/LoginSignUp/index.js
  9. 1
      src/view/login/Login.js
  10. 35
      src/view/services/index.js

@ -175,7 +175,51 @@ const ProductDesign = ({
</div>
)
}else{
}
if(catId == 3){
return(
<div className={`flex flex-col pt-4 text-right rounded-xl justify-start w-full m-4 border border-red82OP`}
style={{ width: '375px', direction: 'rtl' }}
>
<div className="border-b border-red82OP pb-2 px-4">
<h1 className="text-red52 text-lg font-bold">{productName}</h1>
<p className="text-red26 text-sm my-2">
در این قسمت یک توضیحات کوتاه در مورد دوره خواهد آمد که بصورت دو خط در این قسمت قرار میگیرد
</p>
</div>
<div className="flex border-b border-red82OP px-4 py-2">
<div>
<h1 className="font-bold text-red26">
استاد : {teacher}
</h1>
</div>
</div>
<div className="flex border-b border-red82OP px-4 py-2 text-red26">
<h1>نوع گروه : A</h1>
</div>
<div className="flex p-4 justify-between items-center">
<h1 className="font-black text-xl text-red52">{productPrice} تومان</h1>
<div
className={`bg-pinkF5 text-red26 w-32 border-2 border-red52 px-1 py-2 text-xs flex justify-center hover:bg-red52 hover:text-white
`}
>
<button onClick={btnOnClick}>افزودن به سبد خرید</button>
</div>
</div>
</div>
)
}
else{
return <div></div>
}
};

@ -0,0 +1,84 @@
import { Component } from "react";
const maxDesktopSize = 1250;
const maxMobileSize = 550;
const fontSize = {
desktop: {
div: window.innerWidth > maxDesktopSize ? 12 : window.innerWidth / 95,
},
mobile: {
div: window.innerWidth > maxMobileSize ? 12 : window.innerWidth / 30,
},
};
export default class Timer extends Component {
constructor(props) {
super(props);
this.state = {
time: {
h: 0,
m: 0,
s: 0,
},
seconds : props.seconds,
flag: true,
};
this.timer = 0;
this.startTimer = this.startTimer.bind(this);
this.countDown = this.countDown.bind(this);
}
secondsToTime(secs) {
let hours = Math.floor(secs / (60 * 60));
let divisor_for_minutes = secs % (60 * 60);
let minutes = Math.floor(divisor_for_minutes / 60);
let divisor_for_seconds = divisor_for_minutes % 60;
let seconds = Math.ceil(divisor_for_seconds);
let obj = {
h: hours,
m: minutes,
s: seconds,
};
return obj;
}
componentDidMount() {
this.startTimer();
let timeLeftVar = this.secondsToTime(this.state.seconds);
this.setState({ time: timeLeftVar });
}
startTimer() {
if (this.timer === 0 && this.state.seconds > 0) {
this.timer = setInterval(this.countDown, 1000);
}
}
countDown = async () => {
// Remove one second, set state so a re-render happens.
let seconds = this.state.seconds - 1;
this.setState({
time: this.secondsToTime(seconds),
seconds: seconds,
});
if (seconds === 0) {
this.props.refresh(true);
}
};
componentWillUnmount() {
clearInterval(this.timer);
}
render() {
return (
<>
<div className="timer text-greenBA text-sm inline">
{this.state.time ? this.state.time.m : ''}:{this.state.time ? this.state.time.s : ''}
</div>
</>
);
}
}

@ -0,0 +1,8 @@
.timer {
flex-direction: row;
direction: rtl !important;
margin-right: 10px;
margin-left: 10px;
color: $green2;
font-family: numeralLight;
}

@ -43,8 +43,8 @@ const Input = ({
};
return (
<div style={style} className={`${className} Login-box-form-item w-full ml-4 h-12 ${borderType ? borderType : 'rounded-lg'} border border-color7 mt-6 relative flex items-center flex-row-reverse`}>
<div className={`Login-box-form-item-line w-${gapSize ? gapSize : '20'} h-px absolute top-[-1px] right-7 bg-color7`}></div>
<div className="Login-box-form-item-label text-sm text-color19 absolute right-6 transition-all duration-300 pointer-events-none">
<div className={`Login-box-form-item-line w-${gapSize ? gapSize : '20'} h-px absolute top-[-1px] right-7 bg-white`}></div>
<div className="Login-box-form-item-label text-sm text-color19 bg-white absolute right-6 transition-all duration-300 pointer-events-none">
{title ? title : 'نام کاربری'}
</div>
<input

@ -0,0 +1,195 @@
import React, { useState } from "react";
import _ from "lodash";
const langDetector = (lang, option1, option2) => {
return lang === "fa" ? option1 : option2;
};
const inputStatusHandler = (value, focus, status, primary, success, danger) => {
if (!focus) {
return "";
} else {
if (!value) {
return primary;
} else {
if (status) {
return success;
} else {
return danger;
}
}
}
};
export default function Input(props) {
const [value, setValue] = useState("");
const [focusToggle, setFocusToggle] = useState(false);
const {
backgroundColor,
lang,
theme,
inputMode,
label,
status,
maxLength,
message,
onChange,
align,
name,
regex,
direction,
width,
title,
borderType,
gapSize,
id,
type,
className,
style,
bg
} = props;
const focusHandler = (id) => {
let inputs = document.querySelectorAll(".Login-box-form-item");
let label = document.querySelectorAll(".Login-box-form-item-label");
let line = document.querySelectorAll(".Login-box-form-item-line");
inputs[id].style.borderColor = "#df1452";
inputs[id].style.backgroundColor = "#fff";
label[id].style.transform = `translate(-10px,-27px)`;
label[id].style.color = "#df1452";
line[id].style.backgroundColor = "#fff";
};
const blurHandler = (id) => {
let inputsBox = document.querySelectorAll(".Login-box-form-item");
let inputs = document.querySelectorAll(".Login-box-form-item-input");
let label = document.querySelectorAll(".Login-box-form-item-label");
let line = document.querySelectorAll(".Login-box-form-item-line");
if (inputs[id].value === "") {
inputsBox[id].style.borderColor = "#EBEBEB";
label[id].style.transform = "translate(0px,0px)";
label[id].style.color = "#959595";
line[id].style.backgroundColor = "#EBEBEB";
}
};
return (
<div style={style} className={`${className} Login-box-form-item w-full ml-4 h-12 ${borderType ? borderType : 'rounded-lg'} border border-color7 mt-6 relative flex items-center flex-row-reverse`}>
<div className={`Login-box-form-item-line w-${gapSize ? gapSize : '20'} h-px absolute top-[-1px] right-7 bg-color7`}></div>
<div className="Login-box-form-item-label text-sm text-color19 bg-white absolute right-6 transition-all duration-300 pointer-events-none">
{title ? title : 'نام کاربری'}
</div>
{/* <label
className={_.join(
[
"absolute top-1/2 transform -translate-y-1/2 text-gray-500 dark:text-white px-2 text-xs transition-all duration-300",
langDetector(lang, "right-2", "left-2"),
inputStatusHandler(
value,
focusToggle,
status,
"input__labelFocus",
"input__labelSuccess",
"input__labelDanger"
),
],
" "
)}
onClick={() => setFocusToggle(true)}
>
{label}
</label> */}
<input
type="text"
inputMode={inputMode}
className={_.join(
[
`flex-1 border border-gray-300 dark:bg-opacity-10 bg-transparent rounded-md outline-none py-3 px-4 text-tiny ${backgroundColor} ${align}`,
inputStatusHandler(
value,
focusToggle,
status,
"input__inputActive",
"input__inputSuccess",
"input__inputDanger"
),
"transition",
],
" "
)}
style={{ direction: direction }}
onChange={(e) =>
onChange(name, (e.target.value = regex(e.target.value)))
}
// onFocus={() => setFocusToggle(true)}
// onBlur={() => (!value ? setFocusToggle(false) : setFocusToggle(true))}
onFocus={() => focusHandler(id ? id : 0)}
onBlur={() => blurHandler(id ? id : 0)}
maxLength={maxLength}
/>
{value && !status && (
<span
className={_.join(
[
"input__message text-xs absolute -bottom-5",
langDetector(lang, "right-2", "left-2"),
inputStatusHandler(
value,
focusToggle,
status,
"",
"input__messageSuccess",
"input__messageDanger"
),
"transition",
],
" "
)}
>
{message}
</span>
)}
{value && (
<span
className={_.join(
[
"input__length absolute -bottom-5 text-xs",
langDetector(lang, "left-2", "right-2"),
inputStatusHandler(
value,
focusToggle,
status,
"",
"input__lengthSuccess",
"input__lengthDanger"
),
"transition",
],
" "
)}
>
{value.length + "/" + maxLength}
</span>
)}
</div>
);
}
Input.defaultProps = {
lang: "fa",
inputMode: "numeric",
label: "label",
status: "",
maxLength: "",
message: "",
direction: "rtl",
};

@ -1,7 +1,7 @@
export const ApiConfig = {
apiKey: 'AIzaSyBBksq-Asxq2M4Ot-75X19IyrEYJqNBPcg',
authDomain: 'dnvn.ir',
baseUrl: 'https://dnvn.ir/api/v1',
// apiKey: 'AIzaSyBBksq-Asxq2M4Ot-75X19IyrEYJqNBPcg',
// authDomain: 'dnvn.ir',
// baseUrl: 'https://dnvn.ir/api/v1',
//baseUrl: 'http://localhost:3030/api/v1',
loginURL: 'user/login',
otploginURL: 'user/otp/login',

@ -1,6 +1,6 @@
import React, { useState, useRef, useEffect } from "react";
import { useNavigate } from "react-router-dom";
import Input from "../../../components/Input";
import Input from "../../../components/input/signUpInput";
import Button from "../../../components/Button";
import Timer from "../../../components/Timer";
import onInput from "../../../utils/onInput";
@ -10,9 +10,9 @@ import { connect } from "react-redux";
import { user, publicApi } from "../../../redux/actions";
import _ from "lodash";
//assets
import logoIcon from "./assets/logo.svg";
import logoIcon from "../../../assets/img/logo.png";
function SignUp({
function Auth({
sendOtp,
sendPhoneNumber,
loginFlag,
@ -97,6 +97,7 @@ function SignUp({
applicationToken: "22",
});
setError(undefined);
} else {
setError("کد وارد شده را چک کنید.");
}
@ -136,19 +137,16 @@ function SignUp({
const light = theme === "light";
return (
<div
className="w-screen overflow-x-hidden flex flex-row transform -translate-y-10 relative"
style={{ height: "calc(100vh - 160px)" }}
className="w-full overflow-x-hidden flex flex-row relative"
style={{ height: "160px" }}
>
<div
className={`flex flex-col items-center justify-center h-full w-full p-4 transition transform duration-300 absolute top-0 left-0 ${
className={`flex flex-col items-center justify-center h-full w-full p-0 transition transform duration-300 absolute top-0 left-0 ${
level === "phonenumber" ? "translate-x-0" : "-translate-x-full"
}`}
>
<img src={logoIcon} alt="" className="" />
<strong className="w-full leading-6 dark:text-white mt-10">
سلام <br /> خوش برگشتی!
</strong>
<div className="w-full flex flex-col mt-10">
<div className="w-full flex flex-col mt-4">
<Input
label={"شماره موبایل"}
name="cellphone"
@ -160,7 +158,7 @@ function SignUp({
direction="ltr"
/>
<span className="text-red-500 text-xs">{error}</span>
<br />
<Button
title="ادامه"
backgroundColor="bg-blueC0"
@ -177,17 +175,6 @@ function SignUp({
}`}
>
<img src={logoIcon} alt="" className="" />
{!resend && (
<div className="w-full leading-6 dark:text-white mt-10 text-xs text-gray1">
یک کد چهار رقمی تا &nbsp;{" "}
<Timer seconds={120} refresh={setResend} /> &nbsp; دیگر برای شماره
&nbsp;{" "}
<span className="text-greenBA text-sm">
{signUpFields?.cellphone}
</span>{" "}
&nbsp; ارسال خواهد شد.
</div>
)}
<div className="w-full flex flex-col mt-5">
<div className="w-full flex flex-row-reverse justify-center">
@ -289,4 +276,4 @@ const mapDispatchToProps = {
export default connect(
mapStateToProps,
mapDispatchToProps
)(SignUp);
)(Auth);

@ -7,10 +7,21 @@ import thirdPic from '../../assets/img/undraw_certificate_re_yadi.svg';
import { Slide } from 'react-slideshow-image';
import './index.css';
import VerificationInput from "../../components/verificationInput";
import { useNavigate } from "react-router-dom";
import Input from "../../components/input/signUpInput";
import onInput from "../../utils/onInput";
import Timer from "../../components/Timer";
const LoginSignUp = ({ activeLogin,
sendOtp,
sendPhoneNumber,
loginFlag,
theme,
headerOptions,
setHeaderOptions,
const LoginSignUp = ({ activeLogin }) => {
const [steps, setSteps] = useState(0);
}) => {
const [steps, setSteps] = useState(2);
const [index, setIndex] = useState(1);
const [register, setRegister] = useState(false);
const timeoutRef = useRef(null);
@ -47,7 +58,8 @@ const LoginSignUp = ({ activeLogin }) => {
useEffect(() => {
resetTimeout();
timeoutRef.current = setTimeout(
() =>{setIndex((prevIndex) =>prevIndex + 1
() => {
setIndex((prevIndex) => prevIndex + 1
// prevIndex === slideContents.length - 1 ? 0 : prevIndex + 1
)
if (index === slideContents.length)
@ -123,6 +135,124 @@ const LoginSignUp = ({ activeLogin }) => {
},
];
const delay = 2500;
const [level, setLevel] = useState("phonenumber");
const [signUpFields, setSignUpFiels] = useState({});
const [error, setError] = useState("");
const [resend, setResend] = useState(false);
const navigate = useNavigate();
const otp1 = useRef();
const otp2 = useRef();
const otp3 = useRef();
const otp4 = useRef();
const onChange = (name, value) => {
setSignUpFiels({ ...signUpFields, [name]: value });
switch (name) {
case "otp1":
if (value) {
otp2.current.focus();
}
break;
case "otp2":
if (value) {
otp3.current.focus();
} else {
otp1.current.focus();
}
break;
case "otp3":
if (value) {
otp4.current.focus();
} else {
otp2.current.focus();
}
break;
case "otp4":
if (value) {
checkOtp();
} else {
otp3.current.focus();
}
break;
default:
break;
}
};
const checkPhoneNumber = (e) => {
if (
signUpFields?.cellphone?.slice(0, 2) === "09" &&
signUpFields?.cellphone.length === 11
) {
setSteps(2)
setResend(false);
sendPhoneNumber({ cellphone: signUpFields?.cellphone });
setError(undefined);
} else {
setError("شماره موبایل خود را چک کنید.");
}
};
const checkOtp = () => {
if (
signUpFields?.otp1 &&
signUpFields?.otp2 &&
signUpFields?.otp3 &&
signUpFields?.otp4
) {
sendOtp({
cellphone: signUpFields?.cellphone,
otp:
signUpFields?.otp1 +
signUpFields?.otp2 +
signUpFields?.otp3 +
signUpFields?.otp4,
userToken: "2",
applicationToken: "22",
});
setError(undefined);
} else {
setError("کد وارد شده را چک کنید.");
}
};
const numberInput = useRef();
// useEffect(() => {
// // numberInput.current.focus();
// setHeaderOptions(headerOptions);
// }, []);
useEffect(() => {
if (signUpFields?.otp?.length === 4) {
sendOtp({
cellphone: signUpFields?.cellphone,
otp: signUpFields?.otp,
userToken: "2",
applicationToken: "22",
});
}
}, [signUpFields]);
useEffect(() => {
if (level === "phonenumber") {
// numberInput.current.focus();
} else {
// otpInput.current.focus();
}
}, [level]);
useEffect(() => {
if (loginFlag) {
navigate("/");
}
}, [loginFlag]);
const light = theme === "light";
return (
<div className="w-full flex items-center justify-center" style={{ height: '100vh', direction: 'rtl' }}>
<div className="w-3/4 border border-solid border-gray-200 flex rounded-xl">
@ -138,12 +268,31 @@ const LoginSignUp = ({ activeLogin }) => {
</div>
<img src={logo} className="w-1/3 m-6" />
<div className="flex flex-col items-start justify-start leading-normal">
{
steps == 2 ? <h1 className="text-red26 text-lg font-bold">تاییدیه ثبت نام</h1> : <>
<h1 className="text-red26 text-lg font-bold">ورود یا ثبت نام</h1>
<h1 className="text-red26 text-lg font-bold">سامانه ثبت نام مدارس موسسه علمی اندیشمند</h1>
</>
}
<p className="text-gray-500 text-sm mt-2">
{
steps == 2 ? <div>
یک کد چهار رقمی تا &nbsp;{" "}
<Timer seconds={120} refresh={setResend} /> &nbsp; دیگر برای شماره
&nbsp;{" "}
<span className="text-greenBA text-sm">
{signUpFields?.cellphone}
</span>{" "}
&nbsp; ارسال خواهد شد.
</div> : <div>
کاربر گرامی لطفا یکی از دو گزینه زیر را انتخاب نمایید.
<br />
در صورتی که عضو نیستید روی دکمه ثبت نام بزنید
</div>
}
</p>
{
@ -176,47 +325,105 @@ const LoginSignUp = ({ activeLogin }) => {
steps == 1 &&
<>
<div className="Login-box-form-item w-full h-12 rounded-lg border border-color7 mt-6 relative flex items-center flex-row-reverse">
<div className="Login-box-form-item-line w-20 h-px absolute top-[-1px] right-7 bg-color7"></div>
<div className="Login-box-form-item-label text-sm text-color19 absolute right-6 transition-all duration-300 pointer-events-none">
شماره تلفن
</div>
<input
type="number"
name="Login-box-form-item-input-name"
id="Login-box-form-item-input-name"
className="Login-box-form-item-input w-full h-full bg-transparent px-4 outline-0 rounded text-red52"
style={{ direction: "ltr" }}
onFocus={() => focusHandler(0)}
onBlur={() => blurHandler(0)}
<Input
title={"شماره موبایل"}
name="cellphone"
regex={onInput.numberOnly}
onChange={(name, value) => onChange(name, value)}
value={signUpFields?.cellphone}
maxLength="11"
direction="ltr"
/>
</div>
<span className="text-red-500 text-xs">{error}</span>
<Link
to=""
className="Login-box-form-btn w-full h-12 rounded-lg bg-red52 text-white flex items-center justify-center mt-4"
onClick={() => {
setSteps(2);
onClick={(e) => {
// setSteps(2);
checkPhoneNumber(e)
}}
>
ارسال کد تاییدیه
</Link>
</>
}
{
steps == 2 &&
<>
<div style={{ direction: 'ltr' }} className="w-full mt-6">
<VerificationInput />
<div className="w-full flex flex-col mt-5">
<div className="w-full flex flex-row-reverse justify-center">
<input
inputMode="numeric"
style={{ direction: "ltr" }}
name="otp1"
className="bg-red82OP rounded-md p-4 w-16 text-md text-center text-blueC0 mx-1"
onChange={(e) =>
onChange(
e.target.name,
(e.target.value = onInput.numberOnly(e.target.value))
)
}
maxlength="1"
ref={otp1}
/>
<input
inputMode="numeric"
style={{ direction: "ltr" }}
name="otp2"
className="bg-red82OP rounded-md p-4 w-16 text-md text-center text-blueC0 mx-1"
onChange={(e) =>
onChange(
e.target.name,
(e.target.value = onInput.numberOnly(e.target.value))
)
}
maxlength="1"
ref={otp2}
/>
<input
inputMode="numeric"
style={{ direction: "ltr" }}
name="otp3"
className="bg-red82OP rounded-md p-4 w-16 text-md text-center text-blueC0 mx-1"
onChange={(e) =>
onChange(
e.target.name,
(e.target.value = onInput.numberOnly(e.target.value))
)
}
maxlength="1"
ref={otp3}
/>
<input
inputMode="numeric"
style={{ direction: "ltr" }}
name="otp4"
className="bg-red82OP rounded-md p-4 w-16 text-md text-center text-blueC0 mx-1"
onChange={(e) =>
onChange(
e.target.name,
(e.target.value = onInput.englishAndNumberWithoutSpace(e.target.value))
)
}
maxlength="1"
ref={otp4}
/>
</div>
<Link
to={register == true ? '/register' : `/dashboard`}
className="Login-box-form-btn w-full h-12 rounded-lg bg-red52 text-white flex items-center justify-center mt-4"
onClick={() => {
onClick={(e) => {
activeLogin()
checkOtp(e)
@ -224,6 +431,18 @@ const LoginSignUp = ({ activeLogin }) => {
>
تایید
</Link>
<div className="mt-2 flex flex-row text-center w-full justify-center">
<div className="text-xs text-gray1">
شماره خود را اشتباه وارد کردید؟{" "}
<button
className="bg-transparent border-none text-greenBA font-medium"
onClick={() => setLevel("phonenumber")}
>
اصلاح شماره تلفن
</button>
</div>
</div>
</div>
</>
}

@ -101,6 +101,7 @@ const Login = ({ activeLogin }) => {
</div>
</div>
</div>
);
};

@ -17,7 +17,7 @@ import Packages from "../dashboard2/Packages";
const Services = ({
isMobile,
books,
// books,
getList,
grades,
gradeFilter,
@ -99,7 +99,38 @@ const Services = ({
role: "",
},
];
const books = [
{
name : 'علوم',
product: [{price: 1000}],
vodTeacher: 'علی استادی'
},
{
name : 'علوم',
product: [{price: 1000}],
vodTeacher: 'علی استادی'
},
{
name : 'علوم',
product: [{price: 1000}],
vodTeacher: 'علی استادی'
},
{
name : 'علوم',
product: [{price: 1000}],
vodTeacher: 'علی استادی'
},
{
name : 'علوم',
product: [{price: 1000}],
vodTeacher: 'علی استادی'
},
{
name : 'علوم',
product: [{price: 1000}],
vodTeacher: 'علی استادی'
},
]
const [selectedGames, setSelectedGames] = useState([]);
const [gameId, setGameId] = useState(1);
const chooseGame = (id) => {

Loading…
Cancel
Save