2026-01-18 19:57:16 +00:00
|
|
|
import {
|
|
|
|
|
httpDeleteInterceptor,
|
|
|
|
|
httpGetInterceptor,
|
|
|
|
|
httpPutInterceptor,
|
|
|
|
|
httpPostInterceptor,
|
|
|
|
|
} from "./http-config/http-interceptor-service";
|
2025-10-05 05:04:09 +00:00
|
|
|
|
|
|
|
|
export async function deleteUserLevel(id: number) {
|
|
|
|
|
const url = `user-levels/${id}`;
|
|
|
|
|
return await httpDeleteInterceptor(url);
|
2025-10-06 14:17:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function updateUserLevel(id: number, data: any) {
|
|
|
|
|
const url = `user-levels/${id}`;
|
|
|
|
|
return httpPutInterceptor(url, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function getUserLevelDetail(id: number) {
|
|
|
|
|
const url = `user-levels/${id}`;
|
|
|
|
|
return httpGetInterceptor(url);
|
|
|
|
|
}
|
2026-01-18 19:57:16 +00:00
|
|
|
|
|
|
|
|
// Tenant/Client Types
|
|
|
|
|
export interface Tenant {
|
|
|
|
|
id: string;
|
|
|
|
|
name: string;
|
|
|
|
|
slug: string;
|
|
|
|
|
description?: string;
|
|
|
|
|
clientType: "parent_client" | "sub_client" | "standalone";
|
|
|
|
|
parentClientId?: string;
|
|
|
|
|
logoUrl?: string;
|
|
|
|
|
logoImagePath?: string;
|
|
|
|
|
address?: string;
|
|
|
|
|
phoneNumber?: string;
|
|
|
|
|
website?: string;
|
|
|
|
|
maxUsers?: number;
|
|
|
|
|
maxStorage?: number;
|
|
|
|
|
currentUsers?: number;
|
|
|
|
|
currentStorage?: number;
|
|
|
|
|
settings?: string;
|
|
|
|
|
isActive?: boolean;
|
|
|
|
|
createdAt?: string;
|
|
|
|
|
updatedAt?: string;
|
|
|
|
|
parentClient?: {
|
|
|
|
|
id: string;
|
|
|
|
|
name: string;
|
|
|
|
|
};
|
|
|
|
|
subClients?: Array<{
|
|
|
|
|
id: string;
|
|
|
|
|
name: string;
|
|
|
|
|
}>;
|
|
|
|
|
subClientCount?: number;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface TenantCreateRequest {
|
|
|
|
|
name: string;
|
|
|
|
|
description?: string;
|
|
|
|
|
clientType: "parent_client" | "sub_client" | "standalone";
|
|
|
|
|
parentClientId?: string;
|
|
|
|
|
maxUsers?: number;
|
|
|
|
|
maxStorage?: number;
|
|
|
|
|
settings?: string;
|
|
|
|
|
address?: string;
|
|
|
|
|
phoneNumber?: string;
|
|
|
|
|
website?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export interface TenantUpdateRequest {
|
|
|
|
|
name?: string;
|
|
|
|
|
description?: string;
|
|
|
|
|
clientType?: "parent_client" | "sub_client" | "standalone";
|
|
|
|
|
parentClientId?: string;
|
|
|
|
|
maxUsers?: number;
|
|
|
|
|
maxStorage?: number;
|
|
|
|
|
settings?: string;
|
|
|
|
|
isActive?: boolean;
|
|
|
|
|
logoUrl?: string;
|
|
|
|
|
logoImagePath?: string;
|
|
|
|
|
address?: string;
|
|
|
|
|
phoneNumber?: string;
|
|
|
|
|
website?: string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Tenant API Functions
|
|
|
|
|
export async function getTenantList(params?: {
|
|
|
|
|
name?: string;
|
|
|
|
|
clientType?: string;
|
|
|
|
|
parentClientId?: string;
|
|
|
|
|
isActive?: boolean;
|
|
|
|
|
page?: number;
|
|
|
|
|
limit?: number;
|
|
|
|
|
}) {
|
|
|
|
|
const queryParams = new URLSearchParams();
|
|
|
|
|
if (params?.name) queryParams.append("name", params.name);
|
|
|
|
|
if (params?.clientType) queryParams.append("clientType", params.clientType);
|
|
|
|
|
if (params?.parentClientId) queryParams.append("parentClientId", params.parentClientId);
|
|
|
|
|
if (params?.isActive !== undefined) queryParams.append("isActive", params.isActive.toString());
|
|
|
|
|
if (params?.page) queryParams.append("page", params.page.toString());
|
|
|
|
|
if (params?.limit) queryParams.append("limit", params.limit.toString());
|
|
|
|
|
|
|
|
|
|
const url = `clients${queryParams.toString() ? `?${queryParams.toString()}` : ""}`;
|
2025-10-10 16:30:17 +00:00
|
|
|
return httpGetInterceptor(url);
|
|
|
|
|
}
|
2025-10-06 14:17:48 +00:00
|
|
|
|
2026-01-18 19:57:16 +00:00
|
|
|
export async function getTenantById(id: string) {
|
|
|
|
|
const url = `clients/${id}`;
|
|
|
|
|
return httpGetInterceptor(url);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function createTenant(data: TenantCreateRequest) {
|
|
|
|
|
const url = "clients";
|
|
|
|
|
return httpPostInterceptor(url, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function updateTenant(id: string, data: TenantUpdateRequest) {
|
|
|
|
|
const url = `clients/${id}`;
|
|
|
|
|
return httpPutInterceptor(url, data);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export async function deleteTenant(id: string) {
|
|
|
|
|
const url = `clients/${id}`;
|
|
|
|
|
return httpDeleteInterceptor(url);
|
|
|
|
|
}
|
2025-10-06 14:17:48 +00:00
|
|
|
|