diff --git a/app/component/element/AutoCompleteSelect.js b/app/component/element/AutoCompleteSelect.js index 20134ab..202e9fe 100644 --- a/app/component/element/AutoCompleteSelect.js +++ b/app/component/element/AutoCompleteSelect.js @@ -7,7 +7,6 @@ function AutoCompleteSelect({ value, isError, updateData, - name, label, disabled = false, listboxProps, @@ -20,14 +19,17 @@ function AutoCompleteSelect({ disabled={disabled} ListboxProps={listboxProps} value={value || null} + getOptionLabel={(option) => { + if (typeof option === "string") return option; + return option?.name || option?.label || ""; + }} className="!w-full !rounded-lg auto-complete-selector" onChange={(e, newValue) => { updateData && updateData( newValue && sendAll ? newValue - : (newValue && !sendAll && newValue.label) || "", - name, + : (newValue && !sendAll && newValue.label) || "" ); }} sx={{ @@ -73,7 +75,7 @@ function AutoCompleteSelect({ key={option.id || props.id} className="!flex !justify-start !p-[8px] !text-start !text-[#A1A1A1] hover:dark:!bg-[#35343D] !bg-[#FFF] dark:!bg-[#1F1D2B]" > - {option.label} + {option.name || option.label} )} renderInput={(params) => ( diff --git a/app/globals.css b/app/globals.css index 57b70da..d8d1928 100644 --- a/app/globals.css +++ b/app/globals.css @@ -295,7 +295,7 @@ html { } .MuiModal-root div:nth-child(3) { - border-radius: 0 !important; + /* border-radius: 0 !important; */ } } @@ -850,3 +850,11 @@ html { .text-item-head-white:hover .item-head { color: #d7d8ed; } + +.bg-poster { + background-image: url(/public/assets/images/poster.png); + width: 100%; + height: 100%; + background-repeat: no-repeat; + background-size: cover; +} diff --git a/components/doctor/Poster.js b/components/doctor/Poster.js new file mode 100644 index 0000000..0df8de7 --- /dev/null +++ b/components/doctor/Poster.js @@ -0,0 +1,15 @@ +import Image from "next/image"; +import Logo from "@/public/assets/images/logo.png"; + +function Poster() { + return ( +
+
+ logo +

nobat724.com

+
+
+ ); +} + +export default Poster; diff --git a/components/doctor/detailDoctor/Share.js b/components/doctor/detailDoctor/Share.js index 8e60582..b961fa7 100644 --- a/components/doctor/detailDoctor/Share.js +++ b/components/doctor/detailDoctor/Share.js @@ -41,7 +41,7 @@ function Share() { sx={styleDefault} className="!pt-[12px] md:!pt-[14px] lg:!py-[16px] !px-[12px] sm:!px-[16px] md:!px-[20px] lg:!px-[24px] - !pb-[12px] sm:!pb-[16px] lg:!pb-[20px]" + !pb-[12px] sm:!pb-[16px] lg:!pb-[20px] !rounded-[8px] overflow-hidden" >

diff --git a/components/doctor/index.js b/components/doctor/index.js index 5c5ba3a..750329d 100644 --- a/components/doctor/index.js +++ b/components/doctor/index.js @@ -5,6 +5,7 @@ import AppointmentList from "./appointmentList"; import DetailDoctor from "./detailDoctor"; import Share from "./detailDoctor/Share"; import CustomLoading from "@/app/component/loading/Custom"; +import Poster from "./Poster"; function DoctorPage({ doctor }) { const [loading, setLoading] = useState(true); @@ -30,6 +31,7 @@ function DoctorPage({ doctor }) {

+
diff --git a/components/doctors/index.js b/components/doctors/index.js index 92bb153..82ac3b8 100644 --- a/components/doctors/index.js +++ b/components/doctors/index.js @@ -18,19 +18,18 @@ function DoctorsPage({ params, matchedCity, matchedState }) { province: matchedState?.name || params?.province, city: matchedCity?.name || params?.city, }); - const findItem = (name, value) => - specialties.find((item) => item[name] === value); - const itemCategory = findItem("id", params.category); - const itemSpecialties = findItem("id", params.specialties); + const findSpecial = (id) => specialties.find((item) => item.id === id); const [data, setData] = useState({ - category: itemCategory || "", - specialties: itemSpecialties - ? { ...itemSpecialties, label: itemSpecialties.name } + category: findSpecial(params.specialties)?.parent + ? findSpecial(findSpecial(params.specialties)?.parent) + : findSpecial(params.specialties) || "", + specialties: findSpecial(params.specialties)?.parent + ? findSpecial(params.specialties) : "", turn: params && params.hasOwnProperty("turn") ? JSON.parse(params.turn) : 1, gender: params.gender || "هر دو", - degree: params.degree || "متخصص", + degree: params.degree || "همه موارد", }); useEffect(() => { diff --git a/components/doctors/modal/Content.js b/components/doctors/modal/Content.js index ecbdfcf..aa6692c 100644 --- a/components/doctors/modal/Content.js +++ b/components/doctors/modal/Content.js @@ -3,25 +3,22 @@ import RadioContent from "./RadioContent"; import { FormControlLabel, Switch } from "@mui/material"; import { useRouter } from "next/navigation"; import { filterList } from "@/helper"; -const group1 = ["خانم", "آقا", "هر دو"]; -const group2 = ["فوق تخصص", "دکترای تخصصی", "متخصص", "دکتری"]; +const gender = ["زن", "مرد", "هر دو"]; +const degree = ["پزشک عمومی", "پزشک متخصص", "پزشک فوق تخصص", "همه موارد"]; function Content({ data, setData }) { const router = useRouter(); const { parentList, childrenList } = filterList(data); - const changeUrl = (value, name, removeSpecialties) => { + const changeUrl = (value) => { const current = new URLSearchParams(window.location.search); - current.set(name, value.id || value); - if (removeSpecialties) { - current.delete("specialties"); - } + current.set("specialties", value.id || value); const queryString = current.toString(); router.push(`/doctors?${queryString}`); }; const changeData = (value, name, removeSpecialties) => { - changeUrl(value, name, removeSpecialties); + changeUrl(value); const newData = data; newData[name] = value; if (removeSpecialties) { @@ -34,20 +31,18 @@ function Content({ data, setData }) {
changeData(value, name, true)} + updateData={(value) => changeData(value, "category", true)} sendAll={true} - value={data.category.name} + value={data.category?.name} label="دسته بندی" - name="category" /> {!!childrenList.length && (
changeData(value, "specialties")} sendAll={true} - value={data.specialties} - name="specialties" + value={data.specialties?.name} label="تخصص" />
@@ -57,7 +52,7 @@ function Content({ data, setData }) { changeData={changeData} value={data.gender} text="جنسیت پزشک" - group={group1} + group={gender} name="gender" /> @@ -65,7 +60,7 @@ function Content({ data, setData }) { changeData={changeData} value={data.degree} text="درجه علمی" - group={group2} + group={degree} name="degree" /> diff --git a/components/home/FrequentSearches.js b/components/home/FrequentSearches.js index 5dc975c..324d94b 100644 --- a/components/home/FrequentSearches.js +++ b/components/home/FrequentSearches.js @@ -1,12 +1,9 @@ -import { frequentSearches } from "@/constans"; -import { filterList } from "@/helper"; import { Button } from "@mui/material"; import specialties from "@/data/specialties.json"; import Link from "next/link"; function FrequentSearches() { const childrenList = specialties.filter((item) => item.parent); - console.log(childrenList); return (
@@ -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", + }, + } + ), };