last update
This commit is contained in:
@@ -6,6 +6,7 @@ import {
|
|||||||
} from "@/helper";
|
} from "@/helper";
|
||||||
import { request } from "@/services/response";
|
import { request } from "@/services/response";
|
||||||
import { InputAdornment, Button } from "@mui/material";
|
import { InputAdornment, Button } from "@mui/material";
|
||||||
|
import axios from "axios";
|
||||||
import Link from "next/link";
|
import Link from "next/link";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
|
|
||||||
@@ -23,20 +24,39 @@ function LogInPage({ setIsSendMsg, num, setNum, matchedCity }) {
|
|||||||
// handleReq();
|
// handleReq();
|
||||||
// }
|
// }
|
||||||
};
|
};
|
||||||
const handleReq = () => {
|
const handleReq = async () => {
|
||||||
setLoading(true);
|
try {
|
||||||
request
|
const res = await axios.post(
|
||||||
.sendCode(changeNumToDefault(num))
|
"https://back-dev.clinic-pro.ir/api/v1/user/auth?_format=json",
|
||||||
.then((response) => {
|
{ mobile_number: changeNumToDefault(num) },
|
||||||
setLoading(false);
|
{
|
||||||
if (response) {
|
withCredentials: true,
|
||||||
// setNum("");
|
headers: {
|
||||||
setIsSendMsg(true);
|
"Content-Type": "application/json",
|
||||||
|
},
|
||||||
}
|
}
|
||||||
})
|
);
|
||||||
.catch(() => {
|
console.log(res);
|
||||||
setLoading(false);
|
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 (
|
return (
|
||||||
|
|||||||
@@ -7,6 +7,7 @@ import RetryLogin from "../icons/RetryLogin";
|
|||||||
import ArrowRightS from "../icons/ArrowRightS";
|
import ArrowRightS from "../icons/ArrowRightS";
|
||||||
import { request } from "@/services/response";
|
import { request } from "@/services/response";
|
||||||
import { changeNumToDefault } from "@/helper";
|
import { changeNumToDefault } from "@/helper";
|
||||||
|
import axios from "axios";
|
||||||
|
|
||||||
const time_resend_code = 120;
|
const time_resend_code = 120;
|
||||||
|
|
||||||
@@ -61,24 +62,44 @@ function SetCodePage({ setIsSendMsg, link, num, setStep }) {
|
|||||||
}, 1000);
|
}, 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 = () => {
|
try {
|
||||||
setLoading(true);
|
const res = await axios.post(
|
||||||
request
|
"https://back-dev.clinic-pro.ir/oauth/token",
|
||||||
.getToken(
|
formData,
|
||||||
"mobile",
|
{
|
||||||
process.env.NEXT_PUBLIC_CLIENT_ID,
|
withCredentials: true,
|
||||||
process.env.NEXT_PUBLIC_CLIENT_SECRET,
|
headers: {
|
||||||
changeNumToDefault(num),
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
code.join("")
|
},
|
||||||
)
|
}
|
||||||
.then((response) => {
|
);
|
||||||
setLoading(false);
|
console.log(res);
|
||||||
})
|
} catch (err) {
|
||||||
.catch((err) => {
|
console.error("Request failed:", err);
|
||||||
setLoading(false);
|
}
|
||||||
});
|
// 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 (
|
return (
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import LayoutRegister from "./LayoutRegister";
|
|||||||
function RegisterPage({ matchedCity }) {
|
function RegisterPage({ matchedCity }) {
|
||||||
const [isSendMsg, setIsSendMsg] = useState(false);
|
const [isSendMsg, setIsSendMsg] = useState(false);
|
||||||
const [num, setNum] = useState("");
|
const [num, setNum] = useState("");
|
||||||
console.log(num);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<LayoutRegister matchedCity={matchedCity}>
|
<LayoutRegister matchedCity={matchedCity}>
|
||||||
|
|||||||
Reference in New Issue
Block a user