fix filter gender, req and set new data when delete all filters, show date time with timestamp in doctors list, fix send data in home page list specialty, change data of params for request to doctors in doctors page
This commit is contained in:
+5
-20
@@ -1,39 +1,24 @@
|
||||
import DoctorsPage from "@/components/doctors";
|
||||
import Layout from "@/components/layout/StLayout";
|
||||
import { buildDoctorParams } from "@/helper";
|
||||
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;
|
||||
|
||||
let doctors = null;
|
||||
try {
|
||||
const params = {};
|
||||
const state = searchParams.state;
|
||||
const city = searchParams.city;
|
||||
console.log(state);
|
||||
console.log(city);
|
||||
|
||||
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 params = buildDoctorParams(searchParams);
|
||||
|
||||
const response = await axios.get(`${API_URL}/api/v1/doctors`, {
|
||||
params,
|
||||
});
|
||||
doctors = response.data.data;
|
||||
} catch (error) {}
|
||||
} catch (error) {
|
||||
console.error("Error fetching doctors:", error);
|
||||
}
|
||||
|
||||
return (
|
||||
<Layout>
|
||||
|
||||
Reference in New Issue
Block a user