mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-29 21:08:12 +00:00
70 lines
1.8 KiB
TypeScript
70 lines
1.8 KiB
TypeScript
import axiosInstance from "@/shared/services/axiosInstance";
|
|
import { withHeaders } from "@/record-management/services/api/withHeaders";
|
|
import { AxiosResponse } from "axios";
|
|
import { SiteDto, SitePayloadDto, SiteQueryParams } from "@/super-admin/dto/SitesDto";
|
|
|
|
// Fetch all sites (supports pagination/filter params)
|
|
export const getSites = async (
|
|
params?: SiteQueryParams
|
|
): Promise<AxiosResponse<any>> => {
|
|
return axiosInstance.get("/sites", {
|
|
headers: withHeaders(),
|
|
params,
|
|
});
|
|
};
|
|
|
|
// Fetch site by ID
|
|
export const getSiteById = async (
|
|
id: string
|
|
): Promise<AxiosResponse<SiteDto>> => {
|
|
return axiosInstance.get(`/sites/${id}`, {
|
|
headers: withHeaders(),
|
|
});
|
|
};
|
|
|
|
// Create a new site
|
|
export const createSite = async (
|
|
data: SitePayloadDto
|
|
): Promise<AxiosResponse<SiteDto>> => {
|
|
return axiosInstance.post("/sites", data, {
|
|
headers: withHeaders(),
|
|
});
|
|
};
|
|
|
|
// Update an existing site
|
|
export const updateSite = async (
|
|
id: string,
|
|
data: SitePayloadDto
|
|
): Promise<AxiosResponse<SiteDto>> => {
|
|
return axiosInstance.put(`/sites/${id}`, data, {
|
|
headers: withHeaders(),
|
|
});
|
|
};
|
|
|
|
// Soft delete (archive) a site
|
|
export const softDeleteSite = async (
|
|
id: string
|
|
): Promise<AxiosResponse<void>> => {
|
|
return axiosInstance.delete(`/sites/${id}/soft`, {
|
|
headers: withHeaders(),
|
|
});
|
|
};
|
|
|
|
// Permanently delete a site
|
|
export const deleteSite = async (
|
|
id: string
|
|
): Promise<AxiosResponse<void>> => {
|
|
return axiosInstance.delete(`/sites/${id}`, {
|
|
headers: withHeaders(),
|
|
});
|
|
};
|
|
|
|
// Restore an archived site
|
|
export const restoreSite = async (
|
|
id: string
|
|
): Promise<AxiosResponse<SiteDto>> => {
|
|
return axiosInstance.patch(`/sites/${id}/restore`, null, {
|
|
headers: withHeaders(),
|
|
});
|
|
};
|