handle request in modal filters, selector sort, search city with one function and field-search & handle change all data in doctors filter with one function & change modal search location in home page & set data with diffrent key in url of page doctors

This commit is contained in:
Ehsan
2025-09-12 20:51:50 +03:30
parent dbef29b9d9
commit 6414293d1c
19 changed files with 385 additions and 409 deletions
+16 -2
View File
@@ -3,6 +3,10 @@ import Layout from "@/components/layout/StLayout";
import { getStateInfo } from "@/lib/getStateInfo";
import axios from "axios";
// Data
import states from "@/data/state.json";
import cities from "@/data/city.json";
async function Doctors({ searchParams }) {
const { matchedCity, matchedState } = getStateInfo();
const API_URL = process.env.NEXT_PUBLIC_API_URL;
@@ -10,9 +14,19 @@ async function Doctors({ searchParams }) {
let doctors = null;
try {
const params = {};
const state = searchParams.state;
const city = searchParams.city;
console.log(state);
console.log(city);
if (matchedCity) params.city = matchedCity?.id || null;
if (matchedState) params.state = matchedState?.id || null;
if (matchedCity)
params.city = city
? cities.find((item) => item.name === city)?.id
: matchedCity?.id || null;
if (matchedState)
params.state = state
? states.find((item) => item.name === state)?.id
: matchedState?.id || null;
if (searchParams.search) params.name = searchParams.search;
const response = await axios.get(`${API_URL}/api/v1/doctors`, {