@@ -20,7 +17,6 @@ function FrequentSearches() {
href={{
pathname: "/doctors",
query: {
- category: item.parent,
specialties: item.id,
},
}}
diff --git a/components/register/LogInPage.js b/components/register/LogInPage.js
index caee821..466e315 100644
--- a/components/register/LogInPage.js
+++ b/components/register/LogInPage.js
@@ -1,5 +1,6 @@
import Field from "@/app/component/element/Field";
import { formatPhoneNumber, validatePhoneNumber } from "@/helper";
+import { request } from "@/services/response";
import { Button, InputAdornment } from "@mui/material";
import Link from "next/link";
import { useState } from "react";
@@ -15,6 +16,18 @@ function LogInPage({ setIsSendMsg, setStep, matchedCity }) {
setNum(formatted);
};
+ const handleReq = () => {
+ request
+ .auth("/")
+ .then(() => {
+ setIsSendMsg && setIsSendMsg(true);
+ setStep && setStep((prev) => prev + 1);
+ })
+ .catch(() => {
+ setLoading(false);
+ });
+ };
+
return (
diff --git a/helper/index.js b/helper/index.js
index 07e8fbb..9e056c9 100644
--- a/helper/index.js
+++ b/helper/index.js
@@ -105,11 +105,11 @@ export const addLabelToList = (list) =>
});
export const formatPhoneNumber = (input) => {
- if (typeof input !== 'string') input = String(input);
+ if (typeof input !== "string") input = String(input);
const normalized = input
- .replace(/[\u06F0-\u06F9]/g, d => String(d.charCodeAt(0) - 0x06F0))
- .replace(/[\u0660-\u0669]/g, d => String(d.charCodeAt(0) - 0x0660));
+ .replace(/[\u06F0-\u06F9]/g, (d) => String(d.charCodeAt(0) - 0x06f0))
+ .replace(/[\u0660-\u0669]/g, (d) => String(d.charCodeAt(0) - 0x0660));
const digits = normalized.replace(/\D/g, "");
@@ -146,17 +146,6 @@ export const searchOnList = (list, value, name) => {
return newList;
};
-export const addKeyToList = (list, nameKey, nameValue) => {
- const newList = list.map((item) => {
- return {
- ...item,
- [nameKey]: item[nameValue],
- };
- });
-
- return newList;
-};
-
export function clearFilterParams(router, listRemove) {
const currentParams = new URLSearchParams(window.location.search);
const keysToRemove = listRemove;
@@ -171,30 +160,27 @@ export const filterList = (data) => {
const parentList = specialties.filter((item) => !item.parent);
const childrenList = specialties.filter((item) => item.parent);
- const changedParentList = addKeyToList(parentList, "label", "name") || [];
- const changedChildrenList = addKeyToList(childrenList, "label", "name") || [];
-
const filteredChildrenList =
data && data.category
- ? changedChildrenList.filter((item) => item.parent === data.category.id)
+ ? childrenList.filter((item) => item.parent === data.category.id)
: [];
return {
- parentList: changedParentList,
+ parentList: parentList,
childrenList: filteredChildrenList,
};
};
export function getCleanNumberValue(value, defaultValue = 0) {
- if (typeof value !== 'string') value = String(value);
+ if (typeof value !== "string") value = String(value);
// Convert Persian and Arabic digits to English digits
const persianArabicToEnglish = value
- .replace(/[\u06F0-\u06F9]/g, d => String(d.charCodeAt(0) - 0x06F0))
- .replace(/[\u0660-\u0669]/g, d => String(d.charCodeAt(0) - 0x0660));
+ .replace(/[\u06F0-\u06F9]/g, (d) => String(d.charCodeAt(0) - 0x06f0))
+ .replace(/[\u0660-\u0669]/g, (d) => String(d.charCodeAt(0) - 0x0660));
// Remove non-numeric characters except dots (for decimal support)
- const cleaned = persianArabicToEnglish.replace(/[^0-9.]/g, '');
+ const cleaned = persianArabicToEnglish.replace(/[^0-9.]/g, "");
// Return number or default if invalid
const number = parseFloat(cleaned);
diff --git a/public/assets/images/poster.png b/public/assets/images/poster.png
new file mode 100644
index 0000000..304d36c
Binary files /dev/null and b/public/assets/images/poster.png differ
diff --git a/services/api.js b/services/api.js
index 46d6b0f..4f479c4 100644
--- a/services/api.js
+++ b/services/api.js
@@ -1,46 +1,24 @@
import axios from "axios";
import Cookies from "universal-cookie";
+import "react-toastify/dist/ReactToastify.css";
const cookies = new Cookies();
-const BASE_URL = "https://nobat724.com/";
+const BASE_URL = process.env.NEXT_PUBLIC_API_URL;
const api = axios.create({
baseURL: BASE_URL,
headers: {
"Content-Type": "application/json",
+ Authorization: `Bearer ${cookies.get("access")}`,
},
});
-api.interceptors.request.use(
- (request) => {
- const token = cookies.get("token");
- const isLoginPage = window.location.pathname === "/login";
-
- if (!token) {
- if (!isLoginPage) {
- window.location.pathname = "/login";
- }
- } else {
- if (isLoginPage) {
- window.location.pathname = "/";
- }
- request.headers.authorization = `Bearer ${token}`;
- }
- return request;
- },
- (err) => Promise.reject(err)
-);
-
api.interceptors.response.use(
(response) => {
return response.data;
},
(error) => {
- if (error.data.status === 400) {
- cookies.remove("token", { path: "/" });
- window.location.pathname = "/login";
- } else {
- }
+ return error;
}
);
diff --git a/services/response.js b/services/response.js
index e93d9d4..7dc40ed 100644
--- a/services/response.js
+++ b/services/response.js
@@ -1,5 +1,22 @@
import api from "./api";
+import Cookies from "universal-cookie";
export const request = {
- auth: (phone) => api.post("sign-up/", { phone }),
+ auth: (grant_type, client_id, client_secret, username, password) =>
+ api.post(
+ "oauth/token",
+ {
+ grant_type,
+ client_id,
+ client_secret,
+ username,
+ password,
+ },
+ {
+ headers: {
+ Authorization: "",
+ "Content-Type": "application/x-www-form-urlencoded",
+ },
+ }
+ ),
};