handle register and poster and fix bugs
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user