handle register and poster and fix bugs

This commit is contained in:
Ehsan
2025-05-21 23:35:55 +03:30
parent 81f8042f6c
commit c469f2ee3c
23 changed files with 512 additions and 147 deletions
+10 -9
View File
@@ -1,13 +1,13 @@
import Field from "@/app/component/element/Field";
import { formatPhoneNumber, validatePhoneNumber } from "@/helper";
import { changeNumToDefault, formatPhoneNumber, validatePhoneNumber } from "@/helper";
import { request } from "@/services/response";
import { Button, InputAdornment } from "@mui/material";
import { InputAdornment, Button } from "@mui/material";
import Link from "next/link";
import { useState } from "react";
function LogInPage({ setIsSendMsg, setStep, matchedCity }) {
const [num, setNum] = useState("");
function LogInPage({ setIsSendMsg, num, setNum, matchedCity }) {
const [error, setError] = useState({ valid: true, text: "" });
const [loading, setLoading] = useState(false);
const handleChange = (val) => {
const formatted = formatPhoneNumber(val);
@@ -15,13 +15,13 @@ function LogInPage({ setIsSendMsg, setStep, matchedCity }) {
setError(checkedNum);
setNum(formatted);
};
const handleReq = () => {
setLoading(true);
request
.auth("/")
.then(() => {
setIsSendMsg && setIsSendMsg(true);
setStep && setStep((prev) => prev + 1);
.sendCode(changeNumToDefault(num))
.then((response) => {
setLoading(false);
if (response) setIsSendMsg(true);
})
.catch(() => {
setLoading(false);
@@ -80,6 +80,7 @@ function LogInPage({ setIsSendMsg, setStep, matchedCity }) {
<Button
fullWidth
variant="contained"
loading={loading}
onClick={() => {
const checkedNum = validatePhoneNumber(num);
if (!checkedNum.valid) {