From 4a57468e2664154584082ed7a8e426cd48181d83 Mon Sep 17 00:00:00 2001 From: Ehsan Date: Sun, 18 May 2025 01:07:22 +0330 Subject: [PATCH] handle pagination in clinics page & change design login & fix bug filter state & change list most searched in home page & handle error page doctor item & change key url doctors and home page and get data from url & send data with url search to doctors page & show pagination only when list is long --- app/component/Pagination.js | 4 +++- app/component/modalSearchCity/Content.js | 2 +- components/clinics/list/index.js | 2 +- .../detailDoctor/cards/comments/chart/index.js | 9 ++++----- .../detailDoctor/cards/locations/index.js | 4 ++-- components/doctors/index.js | 4 ++-- components/doctors/listDoctors/index.js | 2 +- components/doctors/modal/Content.js | 18 +++++++++--------- components/doctors/modal/FilterModal.js | 4 ++-- components/doctors/modal/listSelector.js | 17 ----------------- components/home/FrequentSearches.js | 17 ++++++++++++----- components/home/search/Fields.js | 14 ++++++++------ components/register/LayoutRegister.js | 6 +++--- components/register/LogInPage.js | 6 +++--- helper/index.js | 5 ++++- 15 files changed, 55 insertions(+), 59 deletions(-) delete mode 100644 components/doctors/modal/listSelector.js diff --git a/app/component/Pagination.js b/app/component/Pagination.js index 8b2177e..cf19340 100644 --- a/app/component/Pagination.js +++ b/app/component/Pagination.js @@ -2,13 +2,15 @@ import { Pagination as PaginationMUI } from "@mui/material"; function Pagination({ page, setPage, list, itemsPerPage }) { const handleChange = (_, value) => setPage(value); + const count = list && itemsPerPage ? Math.ceil(list.length / itemsPerPage) : 20; return ( { - handleSearch('') + handleSearch && handleSearch(''); handleClose(); } diff --git a/components/clinics/list/index.js b/components/clinics/list/index.js index 4732f3c..ac30067 100644 --- a/components/clinics/list/index.js +++ b/components/clinics/list/index.js @@ -23,7 +23,7 @@ function List({ loading, selected, clinics }) { )}
- +
); diff --git a/components/doctor/detailDoctor/cards/comments/chart/index.js b/components/doctor/detailDoctor/cards/comments/chart/index.js index f2ee988..b31a7c3 100644 --- a/components/doctor/detailDoctor/cards/comments/chart/index.js +++ b/components/doctor/detailDoctor/cards/comments/chart/index.js @@ -54,13 +54,12 @@ function Chart({ doctor, loading }) {
    {doctor.progress_detail.map((item, idx) => ( - - + + ))}
diff --git a/components/doctor/detailDoctor/cards/locations/index.js b/components/doctor/detailDoctor/cards/locations/index.js index 125b57a..dc55f4f 100644 --- a/components/doctor/detailDoctor/cards/locations/index.js +++ b/components/doctor/detailDoctor/cards/locations/index.js @@ -9,9 +9,9 @@ function Locations({ doctor, loading }) {

    {doctor.locations.map((item, idx) => ( - +
  • - + {doctor.locations.length > idx + 1 && ( )} diff --git a/components/doctors/index.js b/components/doctors/index.js index 4c5c903..b9b278e 100644 --- a/components/doctors/index.js +++ b/components/doctors/index.js @@ -20,11 +20,11 @@ function DoctorsPage({ params, matchedCity, matchedState }) { }); const findItem = (name, value) => specialties.find(item => item[name] === value) const itemCategory = findItem('id', params.category); - const itemExpertise = findItem('id', params.expertise); + const itemSpecialties = findItem('id', params.specialties); const [data, setData] = useState({ category: itemCategory || "", - expertise: itemExpertise ? { ...itemExpertise, label: itemExpertise.name } : "", + specialties: itemSpecialties ? { ...itemSpecialties, label: itemSpecialties.name } : "", turn: params && params.hasOwnProperty('turn') ? JSON.parse(params.turn) : 1, gender: params.gender || "هر دو", degree: params.degree || "متخصص", diff --git a/components/doctors/listDoctors/index.js b/components/doctors/listDoctors/index.js index 144fd66..6e016b6 100644 --- a/components/doctors/listDoctors/index.js +++ b/components/doctors/listDoctors/index.js @@ -11,7 +11,7 @@ function ListDoctors({ loading }) { ))}
- +
); diff --git a/components/doctors/modal/Content.js b/components/doctors/modal/Content.js index 905851d..3884c84 100644 --- a/components/doctors/modal/Content.js +++ b/components/doctors/modal/Content.js @@ -11,22 +11,22 @@ function Content({ data, setData }) { const router = useRouter(); const { parentList, childrenList } = filterList(data); - const changeUrl = (value, name, removeExpertise) => { + const changeUrl = (value, name, removeSpecialties) => { const current = new URLSearchParams(window.location.search); current.set(name, value.id || value); - if (removeExpertise) { - current.delete('expertise') + if (removeSpecialties) { + current.delete('specialties') }; const queryString = current.toString(); router.push(`/doctors?${queryString}`) } - const changeData = (value, name, removeExpertise) => { - changeUrl(value, name, removeExpertise); + const changeData = (value, name, removeSpecialties) => { + changeUrl(value, name, removeSpecialties); const newData = data; newData[name] = value; - if (removeExpertise) { - newData.expertise = '' + if (removeSpecialties) { + newData.specialties = '' }; setData(newData); } @@ -47,8 +47,8 @@ function Content({ data, setData }) { list={childrenList} updateData={changeData} sendAll={true} - value={data.expertise} - name="expertise" + value={data.specialties} + name="specialties" label="تخصص" />
diff --git a/components/doctors/modal/FilterModal.js b/components/doctors/modal/FilterModal.js index 2ca74f4..5341eb4 100644 --- a/components/doctors/modal/FilterModal.js +++ b/components/doctors/modal/FilterModal.js @@ -16,10 +16,10 @@ function FilterModal({ data, setData, children }) { const handleClose = () => setOpen(false); const deleteData = () => { - clearFilterParams(router, ['turn', 'expertise', 'degree', 'category', 'gender']) + clearFilterParams(router, ['turn', 'specialties', 'degree', 'category', 'gender']) setData({ category: "", - expertise: "", + specialties: "", turn: true, gender: "هر دو", degree: "متخصص", diff --git a/components/doctors/modal/listSelector.js b/components/doctors/modal/listSelector.js deleted file mode 100644 index d576ea4..0000000 --- a/components/doctors/modal/listSelector.js +++ /dev/null @@ -1,17 +0,0 @@ -const category = [ - { label: "چشم پزشکی 1", id: 10 }, - { label: "چشم پزشکی 2", id: 20 }, - { label: "چشم پزشکی 3", id: 30 }, - { label: "چشم پزشکی 4", id: 40 }, - { label: "چشم پزشکی 5", id: 40 }, -]; - -const expertise = [ - { label: "تخصص 1", id: 10 }, - { label: "تخصص 2", id: 20 }, - { label: "تخصص 3", id: 30 }, - { label: "تخصص 4", id: 40 }, - { label: "تخصص 5", id: 40 }, -]; - -export { category, expertise }; diff --git a/components/home/FrequentSearches.js b/components/home/FrequentSearches.js index dcb0e7d..ef5087e 100644 --- a/components/home/FrequentSearches.js +++ b/components/home/FrequentSearches.js @@ -1,20 +1,27 @@ 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 ( -
+

جستجوهای پر تکرار:

-
+
    - {frequentSearches.map((item, idx) => ( + {childrenList.map((item, idx) => (
  • @@ -24,7 +31,7 @@ function FrequentSearches() { className="!py-[6px] md:!py-[7px] lg:!py-[8px] !px-[12px] sm:!px-[14px] md:!px-[15px] lg:!px-[16px] !text-[12px] lg:!text-[14px] !rounded-[4px] !shadow-none !font-normal !border !border-solid !border-[#D7D7D7] hover:!bg-[#EFEFEF]" > - {item} + {item.name}
  • diff --git a/components/home/search/Fields.js b/components/home/search/Fields.js index f7cd5b5..0ff24ac 100644 --- a/components/home/search/Fields.js +++ b/components/home/search/Fields.js @@ -11,7 +11,7 @@ import SearchD from "@/components/icons/SearchD"; function Fields({ city, state }) { const [open, setOpen] = useState(false); - const [selected, setSelected] = useState({ + const [data, setData] = useState({ province: state?.name || '', city: city?.name || '', }); @@ -21,15 +21,16 @@ function Fields({ city, state }) { - + setData({ ...data, search: e.target.value })} InputProps={{ disableUnderline: true, }} @@ -62,8 +63,9 @@ function Fields({ city, state }) { href={{ pathname: "/doctors", query: { - province: selected.province, - city: selected.city, + province: data.province, + city: data.city, + search: data.search }, }} > diff --git a/components/register/LayoutRegister.js b/components/register/LayoutRegister.js index 8e24525..96bd584 100644 --- a/components/register/LayoutRegister.js +++ b/components/register/LayoutRegister.js @@ -8,7 +8,7 @@ function LayoutRegister({ children, matchedCity }) {
    @@ -22,9 +22,9 @@ function LayoutRegister({ children, matchedCity }) {
    {children} -
    +
    -
    +
    {about.map((item, idx) => (

    ورود یا ثبت نام در {matchedCity?.site_name || "نوبت 724"} @@ -73,7 +73,7 @@ function LogInPage({ setIsSendMsg, setStep, matchedCity }) { > ورود -

    +

    قوانین استفاده {" "} diff --git a/helper/index.js b/helper/index.js index 48ac182..0fea6fe 100644 --- a/helper/index.js +++ b/helper/index.js @@ -168,7 +168,10 @@ export const filterList = (data) => { const changedParentList = addKeyToList(parentList, 'label', 'name') || []; const changedChildrenList = addKeyToList(childrenList, 'label', 'name') || []; - const filteredChildrenList = changedChildrenList.filter(item => item.parent === data.category.id); + const filteredChildrenList = + data && data.category ? + changedChildrenList.filter(item => item.parent === data.category.id) : + []; return { parentList: changedParentList,