133 lines
3.6 KiB
JavaScript
133 lines
3.6 KiB
JavaScript
import { axiosInstance } from "../config/api";
|
|
import { CLINIC_TYPE } from "../constants";
|
|
import { clinicsData, registeredClinicsData } from "../mock/clinics";
|
|
|
|
// export const getClinics = (params) => {
|
|
// switch (params.type) {
|
|
// case CLINIC_TYPE.UNREGISTERED:
|
|
// return { data: clinicsData };
|
|
// case CLINIC_TYPE.REGISTERED:
|
|
// return { data: registeredClinicsData };
|
|
// case CLINIC_TYPE.SUBSCRIBED:
|
|
// return { data: registeredClinicsData };
|
|
// default:
|
|
// return { data: clinicsData };
|
|
// }
|
|
// };
|
|
|
|
export const getClinics = (params) => {
|
|
console.log(params);
|
|
|
|
let searchParams = new URLSearchParams();
|
|
searchParams.append("size", params?.pagination?.pageSize ?? 10);
|
|
searchParams.append("page", params?.pagination.pageIndex ?? 0);
|
|
searchParams.append("filter_type", params?.type ?? CLINIC_TYPE.REGISTERED);
|
|
searchParams.append("search", params?.globalFilter ?? "");
|
|
|
|
let url = `/clinics/?${searchParams.toString()}`;
|
|
|
|
return new Promise((resolve, reject) => {
|
|
axiosInstance
|
|
.get(url)
|
|
.then((response) => resolve(response))
|
|
.catch((err) => reject(err));
|
|
});
|
|
|
|
};
|
|
|
|
export const getLatestClinicId = () => {
|
|
const url = `/auth/clinic/latest-id`;
|
|
return new Promise((resolve, reject) => {
|
|
axiosInstance
|
|
.get(url)
|
|
.then((response) => resolve(response))
|
|
.catch((err) => reject(err));
|
|
});
|
|
};
|
|
|
|
export const getClinicsById = (id) => {
|
|
const url = `/clinics/${id}`;
|
|
return new Promise((resolve, reject) => {
|
|
axiosInstance
|
|
.get(url)
|
|
.then((response) => resolve(response))
|
|
.catch((err) => reject(err));
|
|
});
|
|
};
|
|
|
|
export const updateClinicStatus = (data) => {
|
|
const url = `/admin/clinic/status`;
|
|
return new Promise((resolve, reject) => {
|
|
axiosInstance
|
|
.put(url, data)
|
|
.then((response) => resolve(response))
|
|
.catch((err) => reject(err));
|
|
});
|
|
};
|
|
|
|
export const updateClinicDocs = (id, data) => {
|
|
const url = `/clinics/${id}`;
|
|
return new Promise((resolve, reject) => {
|
|
axiosInstance
|
|
.put(url, data)
|
|
.then((response) => resolve(response))
|
|
.catch((err) => reject(err));
|
|
});
|
|
};
|
|
|
|
export const getClinicsDashboardStatsById = () => {
|
|
const url = `/companies/dashboard-stats`;
|
|
return new Promise((resolve, reject) => {
|
|
axiosInstance
|
|
.get(url)
|
|
.then((response) => resolve(response))
|
|
.catch((err) => reject(err));
|
|
});
|
|
};
|
|
|
|
export const createClinicOffer = (data) => {
|
|
const url = `/admin/clinic/offer`;
|
|
return new Promise((resolve, reject) => {
|
|
axiosInstance
|
|
.post(url, data)
|
|
.then((response) => resolve(response))
|
|
.catch((err) => reject(err));
|
|
});
|
|
};
|
|
|
|
export const getClinicOffer = (params) => {
|
|
|
|
let searchParams = new URLSearchParams();
|
|
searchParams.append("size", params?.pagination?.pageSize ?? 10);
|
|
searchParams.append("page", params?.pagination.pageIndex ?? 0);
|
|
searchParams.append("search", params?.globalFilter ?? "");
|
|
|
|
const url = `/admin/clinic/offers?${searchParams.toString()}`;
|
|
return new Promise((resolve, reject) => {
|
|
axiosInstance
|
|
.get(url)
|
|
.then((response) => resolve(response))
|
|
.catch((err) => reject(err));
|
|
});
|
|
};
|
|
|
|
export const updateClinicOffer = (data) => {
|
|
const url = `/admin/clinic/offer`;
|
|
return new Promise((resolve, reject) => {
|
|
axiosInstance
|
|
.put(url, data)
|
|
.then((response) => resolve(response))
|
|
.catch((err) => reject(err));
|
|
});
|
|
};
|
|
|
|
export const deleteClinicOffer = (id) => {
|
|
const url = `/admin/clinic/offer/${id}`;
|
|
return new Promise((resolve, reject) => {
|
|
axiosInstance
|
|
.delete(url)
|
|
.then((response) => resolve(response))
|
|
.catch((err) => reject(err));
|
|
});
|
|
};
|