last update

This commit is contained in:
Ehsan
2025-05-23 19:45:14 +03:30
parent dc118bc48b
commit 7dfad1847a
3 changed files with 71 additions and 31 deletions
+33 -13
View File
@@ -6,6 +6,7 @@ import {
} from "@/helper";
import { request } from "@/services/response";
import { InputAdornment, Button } from "@mui/material";
import axios from "axios";
import Link from "next/link";
import { useState } from "react";
@@ -23,20 +24,39 @@ function LogInPage({ setIsSendMsg, num, setNum, matchedCity }) {
// handleReq();
// }
};
const handleReq = () => {
setLoading(true);
request
.sendCode(changeNumToDefault(num))
.then((response) => {
setLoading(false);
if (response) {
// setNum("");
setIsSendMsg(true);
const handleReq = async () => {
try {
const res = await axios.post(
"https://back-dev.clinic-pro.ir/api/v1/user/auth?_format=json",
{ mobile_number: changeNumToDefault(num) },
{
withCredentials: true,
headers: {
"Content-Type": "application/json",
},
}
})
.catch(() => {
setLoading(false);
});
);
console.log(res);
if (res.data) {
setIsSendMsg(true);
}
} catch (err) {
console.error("Request failed:", err);
}
// setLoading(true);
// request
// .sendCode(changeNumToDefault(num))
// .then((response) => {
// setLoading(false);
// if (response) {
// // setNum("");
// setIsSendMsg(true);
// }
// })
// .catch(() => {
// setLoading(false);
// });
};
return (
+38 -17
View File
@@ -7,6 +7,7 @@ import RetryLogin from "../icons/RetryLogin";
import ArrowRightS from "../icons/ArrowRightS";
import { request } from "@/services/response";
import { changeNumToDefault } from "@/helper";
import axios from "axios";
const time_resend_code = 120;
@@ -61,24 +62,44 @@ function SetCodePage({ setIsSendMsg, link, num, setStep }) {
}, 1000);
};
console.log(num);
const handleReq = async () => {
const formData = new URLSearchParams();
formData.append("grant_type", "mobile");
formData.append("client_id", process.env.NEXT_PUBLIC_CLIENT_ID);
formData.append("client_secret", process.env.NEXT_PUBLIC_CLIENT_SECRET);
formData.append("mobile_number", changeNumToDefault(num));
formData.append("code", code.join(""));
const handleReq = () => {
setLoading(true);
request
.getToken(
"mobile",
process.env.NEXT_PUBLIC_CLIENT_ID,
process.env.NEXT_PUBLIC_CLIENT_SECRET,
changeNumToDefault(num),
code.join("")
)
.then((response) => {
setLoading(false);
})
.catch((err) => {
setLoading(false);
});
try {
const res = await axios.post(
"https://back-dev.clinic-pro.ir/oauth/token",
formData,
{
withCredentials: true,
headers: {
"Content-Type": "application/x-www-form-urlencoded",
},
}
);
console.log(res);
} catch (err) {
console.error("Request failed:", err);
}
// setLoading(true);
// request
// .getToken(
// "mobile",
// process.env.NEXT_PUBLIC_CLIENT_ID,
// process.env.NEXT_PUBLIC_CLIENT_SECRET,
// changeNumToDefault(num),
// code.join("")
// )
// .then((response) => {
// setLoading(false);
// })
// .catch((err) => {
// setLoading(false);
// });
};
return (
-1
View File
@@ -8,7 +8,6 @@ import LayoutRegister from "./LayoutRegister";
function RegisterPage({ matchedCity }) {
const [isSendMsg, setIsSendMsg] = useState(false);
const [num, setNum] = useState("");
console.log(num);
return (
<LayoutRegister matchedCity={matchedCity}>