- types.ts: DeviceSummary/MOCK_DEVICES/SERVICE_FILTER_OPTIONS 삭제, swagger 기준 snake_case 타입 추가 (DeviceListItem, DeviceListRequest 등) - device.api.ts: 신규 생성 (fetchDevices, deleteDevice, exportDevices) - DeviceListPage.tsx: Mock → loadData/useCallback 서버 필터링, fetchServices로 서비스 목록 로드, 엑셀 내보내기 구현 - DeviceSlidePanel.tsx: DeviceListItem 타입 적용, deleteDevice API 호출 연동 Closes #37
44 lines
1.0 KiB
TypeScript
44 lines
1.0 KiB
TypeScript
import { apiClient } from "./client";
|
|
import type { ApiResponse } from "@/types/api";
|
|
import type {
|
|
DeviceListRequest,
|
|
DeviceListResponse,
|
|
DeviceDeleteRequest,
|
|
DeviceExportRequest,
|
|
} from "@/features/device/types";
|
|
|
|
/** 기기 목록 조회 (X-Service-Code 선택) */
|
|
export function fetchDevices(
|
|
data: DeviceListRequest,
|
|
serviceCode?: string,
|
|
) {
|
|
return apiClient.post<ApiResponse<DeviceListResponse>>(
|
|
"/v1/in/device/list",
|
|
data,
|
|
serviceCode ? { headers: { "X-Service-Code": serviceCode } } : undefined,
|
|
);
|
|
}
|
|
|
|
/** 기기 삭제 (비활성화) */
|
|
export function deleteDevice(
|
|
data: DeviceDeleteRequest,
|
|
serviceCode: string,
|
|
) {
|
|
return apiClient.post<ApiResponse<null>>(
|
|
"/v1/in/device/admin/delete",
|
|
data,
|
|
{ headers: { "X-Service-Code": serviceCode } },
|
|
);
|
|
}
|
|
|
|
/** 기기 내보내기 (xlsx blob) */
|
|
export function exportDevices(
|
|
data: DeviceExportRequest,
|
|
serviceCode: string,
|
|
) {
|
|
return apiClient.post("/v1/in/device/export", data, {
|
|
headers: { "X-Service-Code": serviceCode },
|
|
responseType: "blob",
|
|
});
|
|
}
|