Files
nobat724_front/app/doctors/page.js
T

39 lines
1.0 KiB
JavaScript

import DoctorsPage from "@/components/doctors";
import Layout from "@/components/layout/StLayout";
import { buildDoctorParams } from "@/helper";
import { getStateInfo } from "@/lib/getStateInfo";
import axios from "axios";
async function Doctors({ searchParams }) {
const { matchedCity, matchedState } = getStateInfo();
const API_URL = process.env.NEXT_PUBLIC_API_URL;
let doctors = null;
try {
let newSearchParams = searchParams;
if (matchedCity) newSearchParams.city = matchedCity.name;
if (matchedState) newSearchParams.state = matchedState.name;
const params = buildDoctorParams(searchParams);
const response = await axios.get(`${API_URL}/api/v1/doctors`, {
params,
});
doctors = response.data.data;
} catch (error) {
console.error("Error fetching doctors:", error);
}
return (
<Layout>
<DoctorsPage
list={doctors}
params={searchParams}
matchedCity={matchedCity}
matchedState={matchedState}
/>
</Layout>
);
}
export default Doctors;