handel filter clinic and added changenumber function
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
// src/services/clinicApi.js
|
||||
export async function getClinicDoctors(slug, params = {}) {
|
||||
try {
|
||||
const baseUrl = process.env.NEXT_PUBLIC_API_URL;
|
||||
if (!baseUrl) throw new Error("❌ NEXT_PUBLIC_API_URL is not defined");
|
||||
if (!slug) throw new Error("❌ slug is missing");
|
||||
|
||||
const query = new URLSearchParams(params).toString();
|
||||
const finalUrl = `${baseUrl}/api/v1/clinic/doctor-list/${slug}?${query}`;
|
||||
|
||||
console.log("🔗 Final API URL:", finalUrl);
|
||||
|
||||
const response = await fetch(finalUrl, { method: "GET" });
|
||||
|
||||
if (!response.ok) {
|
||||
const text = await response.text();
|
||||
throw new Error(`HTTP ${response.status}: ${text}`);
|
||||
}
|
||||
|
||||
const json = await response.json();
|
||||
console.log("✅ raw API result:", json);
|
||||
|
||||
const doctorsList = json?.data || json || [];
|
||||
return Array.isArray(doctorsList) ? doctorsList : [];
|
||||
} catch (error) {
|
||||
console.error("❌ خطا در دریافت دکترهای کلینیک:", error);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user