260702_01_ENH: 리스트 작업 도중 공용 ui를 적용하기 위한 중간 커밋
This commit is contained in:
@@ -15,7 +15,15 @@ export const useLoginMutation = () => {
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (v: { userId: string; userPw: string; seatNum: string; loginType: string }) => {
|
||||
return nextApi.post<LoginUser>("/login", { userId: v.userId, userPw: v.userPw }, { autoLogoutOnAuthError: false });
|
||||
return nextApi.post<LoginUser>(
|
||||
"/login",
|
||||
{ userId: v.userId, userPw: v.userPw },
|
||||
{
|
||||
skipUnauthorizedHandler: true,
|
||||
skipForbiddenHandler: true,
|
||||
skipResponseErrorHandler: true,
|
||||
},
|
||||
);
|
||||
},
|
||||
onSuccess: (data, v) => {
|
||||
try {
|
||||
@@ -38,7 +46,11 @@ export const useLogoutMutation = () => {
|
||||
const userId = auth.user?.userId ?? "";
|
||||
try {
|
||||
if (userId){
|
||||
await nextApi.post(`/logout/${userId}`, null, { autoLogoutOnAuthError: false });
|
||||
await nextApi.post(`/logout/${userId}`, null, {
|
||||
skipUnauthorizedHandler: true,
|
||||
skipForbiddenHandler: true,
|
||||
skipResponseErrorHandler: true,
|
||||
});
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
@@ -51,4 +63,4 @@ export const useLogoutMutation = () => {
|
||||
qc.clear(); // 다음 사용자/세션에 서버상태 남지 않게
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
31
src/query/internal.ts
Normal file
31
src/query/internal.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import {keepPreviousData, useQuery} from "@tanstack/react-query";
|
||||
import {qk} from "@/query/key/keys";
|
||||
import {internalApi} from "@/lib/http-client";
|
||||
import {InternalInfo} from "@/types/internal";
|
||||
|
||||
const DEFAULT_INTERNAL_INFO: InternalInfo = {
|
||||
clientId: "",
|
||||
internalNo: "",
|
||||
externalNo: "",
|
||||
clientIp: "",
|
||||
};
|
||||
|
||||
export function useInternalInfoQuery(enabled?: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.internalInfo(),
|
||||
queryFn: async (): Promise<InternalInfo> => {
|
||||
try {
|
||||
return await internalApi.get<InternalInfo>(
|
||||
`/new-contact-get-info.asp`,
|
||||
);
|
||||
} catch (error) {
|
||||
//내부 정보 조회 실패
|
||||
return DEFAULT_INTERNAL_INFO;
|
||||
}
|
||||
},
|
||||
enabled: enabled ?? true,
|
||||
staleTime: 0,
|
||||
placeholderData: keepPreviousData, // 검색 중 빈 배열로 깜빡임 방지
|
||||
meta: { ignoreGlobalLoading: true }, // 원하면 전역 오버레이 제외(네가 이미 메타 방식 쓰고 있었지)
|
||||
});
|
||||
}
|
||||
@@ -36,6 +36,10 @@ export const qk = {
|
||||
["kart", "project-list", itrntPrjctCd, userTeam, isKiwi, keyword] as const,
|
||||
/********** KON, KIWI 프로젝트 관련 KART에서 받아옴 **********/
|
||||
|
||||
/********** 찐 인트라넷 관련 **********/
|
||||
internalInfo: () => ["internal", "info"] as const,
|
||||
/********** 찐 인트라넷 관련 **********/
|
||||
|
||||
/********** 인트라넷 관련 **********/
|
||||
intranetProjectList: (keyword: string) => ["intranet", "project-list", keyword] as const,
|
||||
intranetUsers: () => ["intranet", "user-list"] as const,
|
||||
@@ -43,6 +47,7 @@ export const qk = {
|
||||
|
||||
/********** 리스트 관련 **********/
|
||||
listHeader: (prjctIdx: number) => ["list", "header", prjctIdx] as const,
|
||||
listUploadHistory: (prjctIdx: number) => ["list", "upload-history", prjctIdx] as const,
|
||||
listSearch: (prjctIdx: number, body: unknown) => ["list", "search-filter", prjctIdx, body] as const,
|
||||
/********** 리스트 관련 **********/
|
||||
|
||||
|
||||
@@ -1,12 +1,22 @@
|
||||
import {keepPreviousData, useQuery} from "@tanstack/react-query";
|
||||
import {keepPreviousData, useMutation, useQuery, useQueryClient} from "@tanstack/react-query";
|
||||
import {qk} from "@/query/key/keys";
|
||||
import {nextApi} from "@/lib/http-client";
|
||||
import {listHeader, ListSearchRequest, ListSearchWithFullResult} from "@/types/list";
|
||||
import {PageResponse} from "@/types/common";
|
||||
import {
|
||||
ExcelUploadResult,
|
||||
listHeader,
|
||||
ListEventHistDownloadRequest,
|
||||
ListFilter,
|
||||
ListResetRequest,
|
||||
ListSearchRequest,
|
||||
ListSearchWithFullResult,
|
||||
ListUpdateRequest,
|
||||
ListUploadHistory,
|
||||
ListUploadRequest,
|
||||
} from "@/types/list";
|
||||
import type { PageResponse } from "@kri/common";
|
||||
import {ListHeaderAssignConst} from "@/const/listConst";
|
||||
|
||||
export function useListHeaderQuery(prjctIdx: number, enabled: boolean) {
|
||||
|
||||
return useQuery({
|
||||
queryKey: qk.listHeader(prjctIdx),
|
||||
queryFn: () =>
|
||||
@@ -30,8 +40,8 @@ const serializeListSearchRequest = (request: ListSearchRequest) => ({
|
||||
[ListHeaderAssignConst.CONTACT_INTERVIEWER]: [],
|
||||
[ListHeaderAssignConst.FIELD_INTERVIEWER]: [],
|
||||
},
|
||||
memo: request.listFilter.memo ?? "",
|
||||
otherItems: request.listFilter.otherItems ?? {},
|
||||
memoConditions: request.listFilter.memoConditions ?? [],
|
||||
otherItemConditions: request.listFilter.otherItemConditions ?? [],
|
||||
},
|
||||
pageRequest: request.pageRequest,
|
||||
});
|
||||
@@ -53,3 +63,112 @@ export function useListSearchQuery(prjctIdx: number, request: ListSearchRequest,
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
|
||||
export function useDownloadListExcelTemplateMutation() {
|
||||
return useMutation({
|
||||
mutationFn: (prjctIdx: number) =>
|
||||
nextApi.post<ArrayBuffer>(`/list/excel-template/${prjctIdx}`, undefined, { expectBinary: true }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useListUploadHistoryQuery(prjctIdx: number, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.listUploadHistory(prjctIdx),
|
||||
queryFn: () => nextApi.get<ListUploadHistory[]>(`/list/upload-history/${prjctIdx}`),
|
||||
enabled,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
placeholderData: keepPreviousData,
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
|
||||
export function useUploadListExcelMutation(prjctIdx: number) {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: ({ file, request }: { file: File; request: ListUploadRequest }) => {
|
||||
const formData = new FormData();
|
||||
formData.append("file", file);
|
||||
formData.append("request", new Blob([JSON.stringify(request)], { type: "application/json" }));
|
||||
return nextApi.postForm<ExcelUploadResult>(`/list/excel-upload/${prjctIdx}`, formData);
|
||||
},
|
||||
onSuccess: async () => {
|
||||
await Promise.all([
|
||||
queryClient.invalidateQueries({ queryKey: qk.listHeader(prjctIdx) }),
|
||||
queryClient.invalidateQueries({ queryKey: qk.listUploadHistory(prjctIdx) }),
|
||||
queryClient.invalidateQueries({ queryKey: ["list", "search-filter"] }),
|
||||
]);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateListHeaderMutation(prjctIdx: number) {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (rows: listHeader[]) => nextApi.patch<void>(`/list/header/${prjctIdx}`, rows),
|
||||
onSuccess: async () => {
|
||||
await queryClient.invalidateQueries({ queryKey: qk.listHeader(prjctIdx) });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useResetListMutation(prjctIdx: number) {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (request: ListResetRequest) => nextApi.del<number>(`/list/${prjctIdx}`, { json: request }),
|
||||
onSuccess: async () => {
|
||||
await queryClient.invalidateQueries({ queryKey: ["list"] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpdateListMutation(prjctIdx: number) {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (request: ListUpdateRequest) => nextApi.patch<number>(`/list/update/${prjctIdx}`, request),
|
||||
onSuccess: async () => {
|
||||
await queryClient.invalidateQueries({ queryKey: ["list", "search-filter"] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useDownloadListMutation(prjctIdx: number) {
|
||||
return useMutation({
|
||||
mutationFn: (listFilter: ListFilter) =>
|
||||
nextApi.post<ArrayBuffer>(`/list/excel-download/${prjctIdx}`, listFilter, { expectBinary: true }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useDownloadListUpdateHistoryMutation(prjctIdx: number) {
|
||||
return useMutation({
|
||||
mutationFn: (listFilter: ListFilter) =>
|
||||
nextApi.post<ArrayBuffer>(`/list/excel-download-update/${prjctIdx}`, listFilter, { expectBinary: true }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useDownloadListEventHistoryMutation(prjctIdx: number) {
|
||||
return useMutation({
|
||||
mutationFn: (request: ListEventHistDownloadRequest) =>
|
||||
nextApi.post<ArrayBuffer>(`/list/event-history-download/${prjctIdx}`, request, { expectBinary: true }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useDownloadListItemFileMutation(prjctIdx: number) {
|
||||
return useMutation({
|
||||
mutationFn: (listFilter: ListFilter) =>
|
||||
nextApi.post<ArrayBuffer>(`/list/item-file-download/${prjctIdx}`, listFilter, { expectBinary: true }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useDownloadUploadHistoryFileMutation(prjctIdx: number) {
|
||||
return useMutation({
|
||||
mutationFn: (listUploadLogId: string) =>
|
||||
nextApi.post<ArrayBuffer>(`/list/upload-history-file/${prjctIdx}/${listUploadLogId}`, undefined, {
|
||||
expectBinary: true,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import type {
|
||||
ProjectListRequest,
|
||||
ProjectOwnerResponse, ProjectUpdateRequest, ResultCode
|
||||
} from "@/types/project";
|
||||
import {PageRequest, PageResponse} from "@/types/common";
|
||||
import type { PageRequest, PageResponse } from "@kri/common";
|
||||
|
||||
export function useProjectOwnerListQuery(enabled: boolean = true) {
|
||||
return useQuery({
|
||||
@@ -227,4 +227,4 @@ export function useUploadScenarioImageMutation(prjctIdx: number, prjctCd: string
|
||||
qc.invalidateQueries({ queryKey: qk.projectInfo(prjctIdx) });
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user