17 lines
790 B
TypeScript
17 lines
790 B
TypeScript
import { apiDelete, apiGet, apiPatch, apiPost } from "./axios";
|
|
import type { ApiListResponse, Site } from "../types/api";
|
|
|
|
export const fetchSites = (studyId: string, params?: Record<string, any>) =>
|
|
apiGet<ApiListResponse<Site> | Site[]>(`/api/v1/studies/${studyId}/sites/`, {
|
|
params: { include_inactive: true, ...(params || {}) },
|
|
});
|
|
|
|
export const createSite = (studyId: string, payload: Partial<Site> & { name: string }) =>
|
|
apiPost<Site>(`/api/v1/studies/${studyId}/sites/`, payload);
|
|
|
|
export const updateSite = (studyId: string, siteId: string, payload: Partial<Site>) =>
|
|
apiPatch<Site>(`/api/v1/studies/${studyId}/sites/${siteId}`, payload);
|
|
|
|
export const deleteSite = (studyId: string, siteId: string) =>
|
|
apiDelete<void>(`/api/v1/studies/${studyId}/sites/${siteId}`);
|