260722_01_ENH: 버그 수정 및 개선 사항 수정
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
import {keepPreviousData, useQuery} from "@tanstack/react-query";
|
||||
import {qk} from "@/query/key/keys";
|
||||
import {nextApi} from "@/lib/http-client";
|
||||
import {ItrntUserInfo} from "@/types/user";
|
||||
import {CallerTelNumInfo, IntranetProjectSearchResponse, KonKiwiProjectInfo} from "@/types/project";
|
||||
import {GroupCodeInfo, ItrntUserInfo} from "@/types/user";
|
||||
import {CallerTelNumInfo, IntranetProjectSearchResponse} from "@/types/project";
|
||||
|
||||
export function useIntranetProjectListQuery(keyword: string, enabled: boolean) {
|
||||
const kw = keyword.trim();
|
||||
@@ -43,4 +43,13 @@ export function useCallerTelNumListQuery(enabled: boolean) {
|
||||
enabled,
|
||||
staleTime: 60_000,
|
||||
});
|
||||
}
|
||||
|
||||
export function useGroupCodeListQuery(enabled: boolean = true) {
|
||||
return useQuery({
|
||||
queryKey: qk.groupCodeList(),
|
||||
queryFn: () => nextApi.get<GroupCodeInfo[]>("/intranet/group-code-list"),
|
||||
enabled,
|
||||
staleTime: 10 * 60_000,
|
||||
});
|
||||
}
|
||||
@@ -47,6 +47,7 @@ export const qk = {
|
||||
intranetProjectList: (keyword: string) => ["intranet", "project-list", keyword] as const,
|
||||
intranetUsers: () => ["intranet", "user-list"] as const,
|
||||
callerTelNumList: () => ["intranet", "caller-tel-num"] as const,
|
||||
groupCodeList: () => ["intranet", "group-code-list"] as const,
|
||||
/********** 인트라넷 관련 **********/
|
||||
|
||||
/********** 리스트 관련 **********/
|
||||
|
||||
@@ -32,7 +32,7 @@ export function useListHeaderQuery(prjctIdx: number, enabled: boolean) {
|
||||
staleTime: 0, // 항상 오래된 데이터 취급
|
||||
refetchOnMount: "always", // 컴포넌트 다시 붙을 때마다
|
||||
placeholderData: keepPreviousData,
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
meta: { ignoreGlobalLoading: false },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -50,8 +50,8 @@ const serializeListSearchRequest = (request: ListSearchRequest) => ({
|
||||
resultCodeMap: request.listFilter.resultCodeMap ?? {
|
||||
[ResultCodeType.CONTACT]: [],
|
||||
[ResultCodeType.INTERVIEW]: [],
|
||||
[ResultCodeType.SURVEY]: [],
|
||||
},
|
||||
surveyResultConditions: request.listFilter.surveyResultConditions ?? [],
|
||||
memoConditions: request.listFilter.memoConditions ?? [],
|
||||
otherItemConditions: request.listFilter.otherItemConditions ?? [],
|
||||
},
|
||||
@@ -72,7 +72,7 @@ export function useListSearchQuery(prjctIdx: number, request: ListSearchRequest,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
placeholderData: keepPreviousData,
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
meta: { ignoreGlobalLoading: false },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ export function useListDetailQuery(prjctIdx: number, sid: string, enabled: boole
|
||||
refetchOnMount: "always",
|
||||
// 조사 시작으로 새 창이 뜬 뒤 응답을 마치고 이 탭으로 돌아왔을 때 최신 상태(설문 응답 등)를 바로 보여주기 위함.
|
||||
refetchOnWindowFocus: true,
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
meta: { ignoreGlobalLoading: false },
|
||||
});
|
||||
}
|
||||
|
||||
@@ -162,6 +162,15 @@ export function useUploadListItemFileMutation(prjctIdx: number, sid: string) {
|
||||
});
|
||||
}
|
||||
|
||||
export function useDownloadListItemFileByHeaderMutation(prjctIdx: number, sid: string) {
|
||||
return useMutation({
|
||||
mutationFn: (listHderId: number) =>
|
||||
nextApi.get<ArrayBuffer>(`/list/item-file-download/${prjctIdx}/${sid}/${listHderId}`, {
|
||||
expectBinary: true,
|
||||
}),
|
||||
});
|
||||
}
|
||||
|
||||
export function useDownloadListExcelTemplateMutation() {
|
||||
return useMutation({
|
||||
mutationFn: (prjctIdx: number) =>
|
||||
|
||||
@@ -238,8 +238,6 @@ export function useDeleteProjectMutation(prjctIdx: number) {
|
||||
* 시나리오 이미지 업로드 (엔드포인트 spelling은 너 서버 기준으로)
|
||||
*/
|
||||
export function useUploadScenarioImageMutation(prjctIdx: number, prjctCd: string) {
|
||||
const qc = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (file: File): Promise<string> => {
|
||||
const formData = new FormData();
|
||||
@@ -248,9 +246,7 @@ export function useUploadScenarioImageMutation(prjctIdx: number, prjctCd: string
|
||||
// 서버가 업로드된 이미지 URL을 문자열로 반환한다는 전제
|
||||
return await nextApi.postForm<string>(`/project/senario-image/${prjctCd}`, formData);
|
||||
},
|
||||
onSuccess: () => {
|
||||
// 업로드 결과가 projectInfo에 반영된다면 해당 프로젝트만 갱신
|
||||
qc.invalidateQueries({ queryKey: qk.projectInfo(prjctIdx) });
|
||||
},
|
||||
// 업로드는 URL만 돌려받는 동작이라 projectInfo를 실제로 바꾸지 않는다.
|
||||
// 여기서 invalidate하면 편집 중(저장 전) projectInfo refetch가 발생해 미저장 폼 값을 덮어쓴다.
|
||||
});
|
||||
}
|
||||
|
||||
@@ -70,6 +70,7 @@ export function useUpsertUserMutation() {
|
||||
},
|
||||
onSuccess: (_res, v) => {
|
||||
qc.invalidateQueries({ queryKey: qk.users() });
|
||||
qc.invalidateQueries({ queryKey: qk.fieldworkUsers() });
|
||||
|
||||
const userId = (v.data as any)?.userId;
|
||||
if (userId) {
|
||||
@@ -83,7 +84,10 @@ export function useDeleteUserMutation() {
|
||||
const qc = useQueryClient();
|
||||
return useMutation({
|
||||
mutationFn: (userId: string) => nextApi.del<void>(`/user/${encodeURIComponent(userId)}`),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: qk.users() }),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: qk.users() });
|
||||
qc.invalidateQueries({ queryKey: qk.fieldworkUsers() });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -99,6 +103,7 @@ export function useUploadUsersExcelMutation() {
|
||||
onSuccess: (res) => {
|
||||
if (!res.hasErrorFile) {
|
||||
qc.invalidateQueries({ queryKey: qk.users() });
|
||||
qc.invalidateQueries({ queryKey: qk.fieldworkUsers() });
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user