import ClinicPage from "@/components/clinic";
import Layout from "@/components/layout/StLayout";
import { fetchReq } from "@/lib/req";

async function Clinic({ params: { slug },searchParams }) {
  const API_URL = process.env.NEXT_PUBLIC_API_URL;
  const page = Number(searchParams?.page) || 1;
  const reqClinics = await fetchReq(
    `${API_URL}/api/v1/clinic/${slug}`
  );
const limit=50 

  const reqDoctors = await fetchReq(
    `${API_URL}/api/v1/clinic/doctor-list/${slug}?page=${page}&limit=${limit}`
  );


  const clinic = reqClinics;
  const doctors = reqDoctors?.data || [];
  const pagedoctors=reqDoctors?.page

  return (
    <Layout>
      <ClinicPage data={clinic} doctors={doctors} slug={slug} pages={pagedoctors} />
    </Layout>
  );
}

export default Clinic;
