[as] WIP: 기본계획조회 다이얼로그 구현
This commit is contained in:
@@ -2,9 +2,11 @@ import { client } from "@/shared/api";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
|
||||
import type {
|
||||
ClsfSystmRequestDto,
|
||||
ClsfSystmParamsDto,
|
||||
ClsfSystmResponseDto,
|
||||
DcService,
|
||||
FileDownloadParamsDto,
|
||||
FileParamsDto,
|
||||
LvNowDmgMtncGnsvyResponseDto,
|
||||
LvNowDmgMtncGnsvySearchDto,
|
||||
NowDmgMtncGnsvyResponseDto,
|
||||
@@ -31,15 +33,39 @@ async function getLvNowDmgMtncGnsvy(
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async function getClsfSystm(params: ClsfSystmRequestDto): Promise<ClsfSystmResponseDto[]> {
|
||||
async function getClsfSystm(params: ClsfSystmParamsDto): Promise<ClsfSystmResponseDto[]> {
|
||||
const response = await client.get<ClsfSystmResponseDto[]>(`${ENDPOINT.DC_SERVICE}/clsfSystm`, {
|
||||
params,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async function getFile(params: FileParamsDto): Promise<unknown> {
|
||||
const response = await client.get<unknown>(`${ENDPOINT.DC_SERVICE}/file`, {
|
||||
params,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async function getFilePrcs(fileSn: string): Promise<unknown> {
|
||||
const response = await client.get<unknown>(`${ENDPOINT.DC_SERVICE}/fileprcs`, {
|
||||
params: { fileSn },
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async function fileDownload(params: FileDownloadParamsDto): Promise<unknown> {
|
||||
const response = await client.get<unknown>(`${ENDPOINT.DC_SERVICE}/fileDownload`, {
|
||||
params,
|
||||
});
|
||||
return response.data;
|
||||
}
|
||||
|
||||
export const dcService = {
|
||||
getNowDmgMtncGnsvy,
|
||||
getLvNowDmgMtncGnsvy,
|
||||
getClsfSystm,
|
||||
getFile,
|
||||
getFilePrcs,
|
||||
fileDownload,
|
||||
} satisfies DcService;
|
||||
|
||||
@@ -3,7 +3,8 @@ import { useQuery } from "@tanstack/react-query";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
|
||||
import type {
|
||||
ClsfSystmRequestDto,
|
||||
ClsfSystmParamsDto,
|
||||
FileParamsDto,
|
||||
LvNowDmgMtncGnsvySearchDto,
|
||||
NowDmgMtncGnsvySearchDto,
|
||||
} from "../model/dc-interface";
|
||||
@@ -20,17 +21,45 @@ export function useNowDmgMtncGnsvy(params: NowDmgMtncGnsvySearchDto) {
|
||||
});
|
||||
}
|
||||
|
||||
function isLvNowDmgMtncGnsvyEnabled(params: LvNowDmgMtncGnsvySearchDto): boolean {
|
||||
if (!params.level || !params.ctpvNm) return false;
|
||||
if (params.level === "1") return true;
|
||||
if (params.level === "2") return Boolean(params.sggNm);
|
||||
if (params.level === "3") return Boolean(params.sggNm && params.gnsvyYr);
|
||||
return false;
|
||||
}
|
||||
|
||||
export function useLvNowDmgMtncGnsvy(params: LvNowDmgMtncGnsvySearchDto) {
|
||||
return useQuery({
|
||||
queryKey: [...baseKey, "lvNowDmgMtncGnsvy", params],
|
||||
queryFn: () => dcService.getLvNowDmgMtncGnsvy(params),
|
||||
enabled: Boolean(params.level && params.ctpvNm && params.sggNm && params.gnsvyYr),
|
||||
enabled: isLvNowDmgMtncGnsvyEnabled(params),
|
||||
});
|
||||
}
|
||||
|
||||
export function useClsfSystm(params: ClsfSystmRequestDto) {
|
||||
export function useClsfSystm(params: ClsfSystmParamsDto) {
|
||||
return useQuery({
|
||||
queryKey: [...baseKey, "clsfSystm", params],
|
||||
queryFn: () => dcService.getClsfSystm(params),
|
||||
// TODO: T4 — upClsfSystmSn 점진 로드 여부 확정 후 enabled/파라미터 조정
|
||||
enabled: Boolean(params.clsfSystmNm),
|
||||
});
|
||||
}
|
||||
|
||||
export function useFile(params: FileParamsDto) {
|
||||
return useQuery({
|
||||
queryKey: [...baseKey, "file", params],
|
||||
queryFn: () => dcService.getFile(params),
|
||||
// TODO: T2 — getFile Response DTO 확정 후 타입 교체
|
||||
enabled: Boolean(params.clsfSystmSn),
|
||||
});
|
||||
}
|
||||
|
||||
export function useFilePrcs(fileSn: string) {
|
||||
return useQuery({
|
||||
queryKey: [...baseKey, "filePrcs", fileSn],
|
||||
queryFn: () => dcService.getFilePrcs(fileSn),
|
||||
// TODO: T2 — getFilePrcs Response DTO 확정 후 타입 교체
|
||||
enabled: Boolean(fileSn),
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user