컴포넌트 추가방식 변경
This commit is contained in:
@@ -1,120 +0,0 @@
|
||||
import { apiClient } from "./client";
|
||||
|
||||
export interface ComponentStandard {
|
||||
component_code: string;
|
||||
component_name: string;
|
||||
component_name_eng?: string;
|
||||
description?: string;
|
||||
category: string;
|
||||
icon_name?: string;
|
||||
default_size: {
|
||||
width: number;
|
||||
height: number;
|
||||
};
|
||||
component_config: {
|
||||
type: string;
|
||||
webType?: string;
|
||||
config_panel?: string;
|
||||
};
|
||||
preview_image?: string;
|
||||
sort_order: number;
|
||||
is_active: string;
|
||||
is_public?: string;
|
||||
company_code?: string;
|
||||
created_by?: string;
|
||||
updated_by?: string;
|
||||
created_date?: string;
|
||||
updated_date?: string;
|
||||
}
|
||||
|
||||
export interface ComponentQueryParams {
|
||||
category?: string;
|
||||
active?: string;
|
||||
is_public?: string;
|
||||
search?: string;
|
||||
sort?: string;
|
||||
order?: "asc" | "desc";
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
}
|
||||
|
||||
export interface ComponentsResponse {
|
||||
components: ComponentStandard[];
|
||||
total: number;
|
||||
limit?: number;
|
||||
offset?: number;
|
||||
}
|
||||
|
||||
export interface ApiResponse<T> {
|
||||
success: boolean;
|
||||
data: T;
|
||||
message: string;
|
||||
error?: string;
|
||||
}
|
||||
|
||||
// 컴포넌트 목록 조회
|
||||
export const getComponents = async (params?: ComponentQueryParams): Promise<ComponentsResponse> => {
|
||||
const response = await apiClient.get<ApiResponse<ComponentsResponse>>("/admin/component-standards", {
|
||||
params,
|
||||
});
|
||||
return response.data.data;
|
||||
};
|
||||
|
||||
// 컴포넌트 상세 조회
|
||||
export const getComponent = async (componentCode: string): Promise<ComponentStandard> => {
|
||||
const response = await apiClient.get<ApiResponse<ComponentStandard>>(`/admin/component-standards/${componentCode}`);
|
||||
return response.data.data;
|
||||
};
|
||||
|
||||
// 컴포넌트 생성
|
||||
export const createComponent = async (
|
||||
data: Omit<ComponentStandard, "created_date" | "updated_date">,
|
||||
): Promise<ComponentStandard> => {
|
||||
const response = await apiClient.post<ApiResponse<ComponentStandard>>("/admin/component-standards", data);
|
||||
return response.data.data;
|
||||
};
|
||||
|
||||
// 컴포넌트 수정
|
||||
export const updateComponent = async (
|
||||
componentCode: string,
|
||||
data: Partial<ComponentStandard>,
|
||||
): Promise<ComponentStandard> => {
|
||||
const response = await apiClient.put<ApiResponse<ComponentStandard>>(
|
||||
`/admin/component-standards/${componentCode}`,
|
||||
data,
|
||||
);
|
||||
return response.data.data;
|
||||
};
|
||||
|
||||
// 컴포넌트 삭제
|
||||
export const deleteComponent = async (componentCode: string): Promise<void> => {
|
||||
await apiClient.delete(`/admin/component-standards/${componentCode}`);
|
||||
};
|
||||
|
||||
// 컴포넌트 코드 중복 체크
|
||||
export const checkComponentDuplicate = async (
|
||||
componentCode: string,
|
||||
): Promise<{ isDuplicate: boolean; component_code: string }> => {
|
||||
const response = await apiClient.get<ApiResponse<{ isDuplicate: boolean; component_code: string }>>(
|
||||
`/admin/component-standards/check-duplicate/${componentCode}`,
|
||||
);
|
||||
return response.data.data;
|
||||
};
|
||||
|
||||
// 카테고리 목록 조회
|
||||
export const getCategories = async (): Promise<string[]> => {
|
||||
const response = await apiClient.get<ApiResponse<string[]>>("/admin/component-standards/categories");
|
||||
return response.data.data;
|
||||
};
|
||||
|
||||
// 통계 조회
|
||||
export interface ComponentStatistics {
|
||||
total: number;
|
||||
byCategory: Array<{ category: string; count: number }>;
|
||||
byStatus: Array<{ status: string; count: number }>;
|
||||
}
|
||||
|
||||
export const getStatistics = async (): Promise<ComponentStatistics> => {
|
||||
const response = await apiClient.get<ApiResponse<ComponentStatistics>>("/admin/component-standards/statistics");
|
||||
return response.data.data;
|
||||
};
|
||||
Reference in New Issue
Block a user