260714_01_ENH: 테스트 서버에서 기동 후 중간 테스트를 위한 커밋
This commit is contained in:
25
src/query/assign.ts
Normal file
25
src/query/assign.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
"use client";
|
||||
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { nextApi } from "@/lib/http-client";
|
||||
import type { ListAssignRequest, ListAssignResetRequest } from "@/types/list";
|
||||
|
||||
export function useUpsertListAssignMutation(prjctIdx: number) {
|
||||
const qc = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: ({ assignId, request }: { assignId: string; request: ListAssignRequest }) =>
|
||||
nextApi.put<number>(`/assign/list/${prjctIdx}/${encodeURIComponent(assignId)}`, request),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ["list", "search-filter"] }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useResetListAssignMutation(prjctIdx: number) {
|
||||
const qc = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (request: ListAssignResetRequest) =>
|
||||
nextApi.del<number>(`/assign/list/reset/${prjctIdx}`, { json: request }),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ["list", "search-filter"] }),
|
||||
});
|
||||
}
|
||||
@@ -4,17 +4,13 @@ import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { nextApi } from "@/lib/http-client";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { useSelectedProject } from "@/hooks/useSelectedProject";
|
||||
import { useStorage } from "@/hooks/useStorage";
|
||||
import { StorageKeys } from "@/store/storage/storage-keys";
|
||||
import type { LoginUser } from "@/types/auth";
|
||||
import type { LoginUser } from "@kri/common";
|
||||
|
||||
export const useLoginMutation = () => {
|
||||
const { setFromLoginResponse } = useAuth();
|
||||
const { set: setSeat } = useStorage(StorageKeys.SeatNumber);
|
||||
const { set: setLoginType } = useStorage(StorageKeys.LoginType);
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async (v: { userId: string; userPw: string; seatNum: string; loginType: string }) => {
|
||||
mutationFn: async (v: { userId: string; userPw: string }) => {
|
||||
return nextApi.post<LoginUser>(
|
||||
"/login",
|
||||
{ userId: v.userId, userPw: v.userPw },
|
||||
@@ -25,12 +21,8 @@ export const useLoginMutation = () => {
|
||||
},
|
||||
);
|
||||
},
|
||||
onSuccess: (data, v) => {
|
||||
try {
|
||||
setSeat(v.seatNum);
|
||||
setLoginType(v.loginType);
|
||||
} catch {}
|
||||
setFromLoginResponse(data, v.seatNum);
|
||||
onSuccess: (data) => {
|
||||
setFromLoginResponse(data);
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -39,7 +31,6 @@ export const useLogoutMutation = () => {
|
||||
const qc = useQueryClient();
|
||||
const { auth, logout } = useAuth();
|
||||
const { clearSelectedProject } = useSelectedProject();
|
||||
const { get: getLoginType } = useStorage(StorageKeys.LoginType);
|
||||
|
||||
return useMutation({
|
||||
mutationFn: async () => {
|
||||
@@ -55,7 +46,6 @@ export const useLogoutMutation = () => {
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
return { loginType: getLoginType() };
|
||||
},
|
||||
onSettled: () => {
|
||||
clearSelectedProject();
|
||||
|
||||
51
src/query/cmpn.ts
Normal file
51
src/query/cmpn.ts
Normal file
@@ -0,0 +1,51 @@
|
||||
"use client";
|
||||
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { nextApi } from "@/lib/http-client";
|
||||
import { qk } from "@/query/key/keys";
|
||||
import type { CmpnInfo, CmpnInfoSaveRequest } from "@/types/cmpn";
|
||||
import type { DataVerification } from "@kri/common";
|
||||
|
||||
export function useCmpnListQuery() {
|
||||
return useQuery({
|
||||
queryKey: qk.cmpnList(),
|
||||
queryFn: () => nextApi.get<CmpnInfo[]>("/cmpn"),
|
||||
staleTime: 10 * 60_000,
|
||||
});
|
||||
}
|
||||
|
||||
export function useCmpnDetailQuery(cmpnId: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.cmpn(cmpnId),
|
||||
queryFn: () => nextApi.get<CmpnInfo>(`/cmpn/${encodeURIComponent(cmpnId)}`),
|
||||
enabled,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
});
|
||||
}
|
||||
|
||||
export function useCheckCmpnIdDuplicateMutation() {
|
||||
return useMutation({
|
||||
mutationFn: (cmpnId: string) =>
|
||||
nextApi.get<DataVerification>("/cmpn/check-cmpn-id", { query: { cmpnId } }),
|
||||
});
|
||||
}
|
||||
|
||||
export function useUpsertCmpnMutation() {
|
||||
const qc = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (v: { mode: "create" | "edit"; data: CmpnInfoSaveRequest }) => {
|
||||
return v.mode === "create"
|
||||
? nextApi.put<void>("/cmpn", v.data)
|
||||
: nextApi.patch<void>("/cmpn", v.data);
|
||||
},
|
||||
onSuccess: (_res, v) => {
|
||||
qc.invalidateQueries({ queryKey: qk.cmpnList() });
|
||||
|
||||
if (v.data.cmpnId) {
|
||||
qc.invalidateQueries({ queryKey: qk.cmpn(v.data.cmpnId) });
|
||||
}
|
||||
},
|
||||
});
|
||||
}
|
||||
@@ -1,14 +1,15 @@
|
||||
import type { ChannelType } from "@/types/messageTemplate";
|
||||
import type { ChannelType } from "@kri/common/noti-hub";
|
||||
|
||||
export const qk = {
|
||||
/********** 사용자 관리 관련 **********/
|
||||
roleList: () => ["role", "list"] as const,
|
||||
userCompanies: () => ["user", "companies"] as const,
|
||||
users: () => ["user", "list"] as const,
|
||||
user: (userId: string) => ["user", "detail", userId] as const,
|
||||
|
||||
fieldworkUsers: () => ["user", "fieldwork"] as const,
|
||||
outsourceUsers: () => ["user", "outsource"] as const,
|
||||
|
||||
cmpnList: () => ["cmpn", "list"] as const,
|
||||
cmpn: (cmpnId: string) => ["cmpn", "detail", cmpnId] as const,
|
||||
/********** 사용자 관리 관련 **********/
|
||||
|
||||
/********** 프로젝트 관련 **********/
|
||||
@@ -28,12 +29,14 @@ export const qk = {
|
||||
|
||||
/********** 배정 관련 **********/
|
||||
projectAssignFieldwork: (prjctIdx: number) => ["assign", "prjct-fieldwork", prjctIdx] as const,
|
||||
projectAssignOutsource: (prjctIdx: number) => ["assign", "prjct-outsource", prjctIdx] as const,
|
||||
projectAssignCmpn: (prjctIdx: number) => ["assign", "prjct-cmpn", prjctIdx] as const,
|
||||
/********** 배정 관련 **********/
|
||||
|
||||
/********** KON, KIWI 프로젝트 관련 KART에서 받아옴 **********/
|
||||
kartProjectList: (itrntPrjctCd: string, userTeam: string, isKiwi: number, keyword: string) =>
|
||||
["kart", "project-list", itrntPrjctCd, userTeam, isKiwi, keyword] as const,
|
||||
surveyRedirectUrl: (isKiwi: number, pkey: string) =>
|
||||
["kart", "survey-redirect-url", isKiwi, pkey] as const,
|
||||
/********** KON, KIWI 프로젝트 관련 KART에서 받아옴 **********/
|
||||
|
||||
/********** 찐 인트라넷 관련 **********/
|
||||
@@ -49,6 +52,11 @@ 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,
|
||||
listDetail: (prjctIdx: number, sid: string) => ["list", "search-sid", prjctIdx, sid] as const,
|
||||
listEventHistory: (prjctIdx: number, sid: string) => ["list", "event-history", prjctIdx, sid] as const,
|
||||
listUpdateHistory: (prjctIdx: number, sid: string) => ["list", "update-history", prjctIdx, sid] as const,
|
||||
listReserveBySid: (prjctIdx: number, sid: string) => ["list", "reserve", "sid", prjctIdx, sid] as const,
|
||||
listReserveByUser: (prjctIdx: number, userId: string) => ["list", "reserve", "user", prjctIdx, userId] as const,
|
||||
/********** 리스트 관련 **********/
|
||||
|
||||
/********** 템플릿 및 발송 관련 **********/
|
||||
@@ -57,5 +65,23 @@ export const qk = {
|
||||
templateList: (chnnlTy: ChannelType, itrntPrjctCd: string) =>
|
||||
["message-template", "list", chnnlTy, itrntPrjctCd] as const,
|
||||
template: (tmplatIdx: number) => ["message-template", "detail", tmplatIdx] as const,
|
||||
|
||||
bulkSendList: (sendTy: number, reqstSvc: string, prjctCd: string) =>
|
||||
["message-report", "bulk-list", sendTy, reqstSvc, prjctCd] as const,
|
||||
bulkSendDetail: (bulkSendKey: string, pageRequest: unknown) =>
|
||||
["message-report", "bulk-detail", bulkSendKey, pageRequest] as const,
|
||||
sendResultSummary: (request: unknown) =>
|
||||
["message-report", "send-result-summary", request] as const,
|
||||
sendResultBySid: (sid: string, prjctCd: string, reqstSvc: string, channelTy?: ChannelType) =>
|
||||
["message-report", "send-result", sid, prjctCd, reqstSvc, channelTy] as const,
|
||||
/********** 템플릿 및 발송 관련 **********/
|
||||
|
||||
/********** 컨택/면접 진행 현황 관련 **********/
|
||||
userProgress: (prjctIdx: number, eventTy: number, request: unknown) =>
|
||||
["progress", "user", prjctIdx, eventTy, request] as const,
|
||||
dateProgress: (prjctIdx: number, eventTy: number, request: unknown) =>
|
||||
["progress", "date", prjctIdx, eventTy, request] as const,
|
||||
lastDateProgress: (prjctIdx: number, eventTy: number, request: unknown) =>
|
||||
["progress", "last-date", prjctIdx, eventTy, request] as const,
|
||||
/********** 컨택/면접 진행 현황 관련 **********/
|
||||
} as const;
|
||||
|
||||
@@ -2,19 +2,24 @@ import {keepPreviousData, useMutation, useQuery, useQueryClient} from "@tanstack
|
||||
import {qk} from "@/query/key/keys";
|
||||
import {nextApi} from "@/lib/http-client";
|
||||
import {
|
||||
ExcelUploadResult,
|
||||
listHeader,
|
||||
ListEventHistDownloadRequest,
|
||||
ListEventHistory,
|
||||
ListEventInsertRequest,
|
||||
ListFilter,
|
||||
ListReserve,
|
||||
ListReserveRequest,
|
||||
ListResetRequest,
|
||||
ListSearchRequest,
|
||||
ListSearchWithFullResult,
|
||||
ListUpdateHistory,
|
||||
ListUpdateRequest,
|
||||
ListUploadHistory,
|
||||
ListUploadRequest,
|
||||
} from "@/types/list";
|
||||
import type { PageResponse } from "@kri/common";
|
||||
import type { ExcelUploadResult, PageResponse } from "@kri/common";
|
||||
import {ListHeaderAssignConst} from "@/const/listConst";
|
||||
import {ResultCodeType} from "@/types/project";
|
||||
|
||||
export function useListHeaderQuery(prjctIdx: number, enabled: boolean) {
|
||||
return useQuery({
|
||||
@@ -35,11 +40,18 @@ const serializeListSearchRequest = (request: ListSearchRequest) => ({
|
||||
listFilter: {
|
||||
sidSet: request.listFilter.sidSet ?? [],
|
||||
listUseSet: request.listFilter.listUseSet ?? [],
|
||||
listUseConditions: request.listFilter.listUseConditions ?? [],
|
||||
assignUserMap: request.listFilter.assignUserMap ?? {
|
||||
[ListHeaderAssignConst.OUTSOURCE]: [],
|
||||
[ListHeaderAssignConst.CONTACT_INTERVIEWER]: [],
|
||||
[ListHeaderAssignConst.FIELD_INTERVIEWER]: [],
|
||||
},
|
||||
assignConditions: request.listFilter.assignConditions ?? [],
|
||||
resultCodeMap: request.listFilter.resultCodeMap ?? {
|
||||
[ResultCodeType.CONTACT]: [],
|
||||
[ResultCodeType.INTERVIEW]: [],
|
||||
[ResultCodeType.SURVEY]: [],
|
||||
},
|
||||
memoConditions: request.listFilter.memoConditions ?? [],
|
||||
otherItemConditions: request.listFilter.otherItemConditions ?? [],
|
||||
},
|
||||
@@ -64,6 +76,90 @@ export function useListSearchQuery(prjctIdx: number, request: ListSearchRequest,
|
||||
});
|
||||
}
|
||||
|
||||
export function useListDetailQuery(prjctIdx: number, sid: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.listDetail(prjctIdx, sid),
|
||||
queryFn: () => nextApi.get<ListSearchWithFullResult>(`/list/search-sid/${prjctIdx}/${sid}`),
|
||||
enabled,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
|
||||
export function useListEventHistoryQuery(prjctIdx: number, sid: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.listEventHistory(prjctIdx, sid),
|
||||
queryFn: () => nextApi.get<ListEventHistory[]>(`/list-hist/event/${prjctIdx}/${sid}`),
|
||||
enabled,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
|
||||
export function useListUpdateHistoryQuery(prjctIdx: number, sid: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.listUpdateHistory(prjctIdx, sid),
|
||||
queryFn: () => nextApi.get<ListUpdateHistory[]>(`/list-hist/update/${prjctIdx}/${sid}`),
|
||||
enabled,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
|
||||
export function useListReserveBySidQuery(prjctIdx: number, sid: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.listReserveBySid(prjctIdx, sid),
|
||||
queryFn: () => nextApi.get<ListReserve[]>(`/reserve/sid/${prjctIdx}/${sid}`),
|
||||
enabled,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
|
||||
export function useListReserveByUserQuery(prjctIdx: number, userId: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.listReserveByUser(prjctIdx, userId),
|
||||
queryFn: () => nextApi.get<ListReserve[]>(`/reserve/user/${prjctIdx}/${userId}`),
|
||||
enabled,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
|
||||
export function useReserveMutation(prjctIdx: number, sid: string) {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (request: ListReserveRequest) => nextApi.put<ListReserve>(`/reserve`, request),
|
||||
onSuccess: async (_result, request) => {
|
||||
await Promise.all([
|
||||
queryClient.invalidateQueries({ queryKey: qk.listReserveBySid(prjctIdx, sid) }),
|
||||
queryClient.invalidateQueries({ queryKey: qk.listReserveByUser(prjctIdx, request.userId) }),
|
||||
]);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useUploadListItemFileMutation(prjctIdx: number, sid: string) {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: ({ listHderId, file }: { listHderId: number; file: File }) => {
|
||||
const formData = new FormData();
|
||||
formData.append(String(listHderId), file);
|
||||
return nextApi.postForm<void>(`/list/item-file-upload/${prjctIdx}/${sid}`, formData);
|
||||
},
|
||||
onSuccess: async () => {
|
||||
await queryClient.invalidateQueries({ queryKey: qk.listDetail(prjctIdx, sid) });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useDownloadListExcelTemplateMutation() {
|
||||
return useMutation({
|
||||
mutationFn: (prjctIdx: number) =>
|
||||
@@ -131,7 +227,24 @@ export function useUpdateListMutation(prjctIdx: number) {
|
||||
return useMutation({
|
||||
mutationFn: (request: ListUpdateRequest) => nextApi.patch<number>(`/list/update/${prjctIdx}`, request),
|
||||
onSuccess: async () => {
|
||||
await queryClient.invalidateQueries({ queryKey: ["list", "search-filter"] });
|
||||
await Promise.all([
|
||||
queryClient.invalidateQueries({ queryKey: ["list", "search-filter"] }),
|
||||
queryClient.invalidateQueries({ queryKey: ["list", "update-history"] }),
|
||||
]);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useAddListEventMutation(prjctIdx: number, sid: string) {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (request: ListEventInsertRequest) => nextApi.put<void>(`/list-hist/event`, request),
|
||||
onSuccess: async () => {
|
||||
await Promise.all([
|
||||
queryClient.invalidateQueries({ queryKey: qk.listDetail(prjctIdx, sid) }),
|
||||
queryClient.invalidateQueries({ queryKey: qk.listEventHistory(prjctIdx, sid) }),
|
||||
]);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,10 +1,28 @@
|
||||
"use client";
|
||||
|
||||
import { useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { keepPreviousData, useMutation, useQuery, useQueryClient } from "@tanstack/react-query";
|
||||
import { nextApi } from "@/lib/http-client";
|
||||
import { qk } from "@/query/key/keys";
|
||||
import type { ChannelType, Template, TemplateSummary } from "@/types/messageTemplate";
|
||||
import type {
|
||||
BulkSendCreateRequest,
|
||||
BulkSendInfo,
|
||||
BulkSendResponse,
|
||||
ChannelType,
|
||||
SendRequestBulk,
|
||||
SendResultSummaryRequest,
|
||||
SendResultSummaryResponse,
|
||||
Template,
|
||||
TemplateSummary,
|
||||
} from "@kri/common/noti-hub";
|
||||
import type { FileResponse, PageRequest, PageResponse } from "@kri/common";
|
||||
import type { ProjectMainTemplateUpdateRequest } from "@/types/project";
|
||||
import type {
|
||||
MessageBulkSendResponse,
|
||||
MessageSendBulkRequest,
|
||||
MessageSendChannel,
|
||||
MessageSendSingleRequest,
|
||||
SendResultInfo,
|
||||
} from "@/types/message";
|
||||
|
||||
export function useTemplateListQuery(chnnlTy: ChannelType, itrntPrjctCd: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
@@ -87,4 +105,123 @@ export function useUploadTemplateBodyImageMutation(itrntPrjctCd: string) {
|
||||
return nextApi.putForm<string>(`/message-template/body-image/${itrntPrjctCd}`, formData);
|
||||
},
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 발송키 생성 (PUT /send-{sms,email}/create/bulk)
|
||||
*/
|
||||
export function useCreateBulkSendKeyMutation(channel: MessageSendChannel) {
|
||||
return useMutation({
|
||||
mutationFn: (req: BulkSendCreateRequest) =>
|
||||
nextApi.put<string>(`/message-send/create-bulk/${channel}`, req),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* bulkSendKey 기반 벌크 발송 (POST /send-{sms,email}/bulk)
|
||||
*/
|
||||
export function useSendBulkMutation(channel: MessageSendChannel) {
|
||||
return useMutation({
|
||||
mutationFn: (req: SendRequestBulk) =>
|
||||
nextApi.post<BulkSendResponse>(`/message-send/bulk/${channel}`, req),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 대량발송 리스트 조회 (GET /report/bulk-list/{sendTy}/{reqstSvc}/{prjctCd})
|
||||
*/
|
||||
export function useBulkSendListQuery(sendTy: number, reqstSvc: string, prjctCd: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.bulkSendList(sendTy, reqstSvc, prjctCd),
|
||||
queryFn: () => nextApi.get<BulkSendInfo[]>(`/message-report/bulk-list/${sendTy}/${reqstSvc}/${prjctCd}`),
|
||||
enabled: enabled && !!reqstSvc && !!prjctCd,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 대량발송 상세 결과 조회 (POST /report/bulk-detail/{bulkSendKey})
|
||||
*/
|
||||
export function useBulkSendDetailQuery(bulkSendKey: string, pageRequest: PageRequest, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.bulkSendDetail(bulkSendKey, pageRequest),
|
||||
queryFn: () => nextApi.post<PageResponse<SendResultInfo>>(`/message-report/bulk-detail/${bulkSendKey}`, pageRequest),
|
||||
enabled: enabled && !!bulkSendKey,
|
||||
staleTime: 0,
|
||||
placeholderData: keepPreviousData,
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 대량발송 결과 엑셀 다운로드 (POST /report/bulk-detail/excel/{bulkSendKey})
|
||||
*/
|
||||
export function useBulkSendDetailExcelMutation() {
|
||||
return useMutation({
|
||||
mutationFn: (bulkSendKey: string) =>
|
||||
nextApi.post<FileResponse>(`/message-report/bulk-detail-excel/${bulkSendKey}`, undefined),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 발송 결과 축약 조회 (POST /report/send-result-summary)
|
||||
*/
|
||||
export function useSendResultSummaryQuery(request: SendResultSummaryRequest, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.sendResultSummary(request),
|
||||
queryFn: () => nextApi.post<SendResultSummaryResponse[]>(`/message-report/send-result-summary`, request),
|
||||
enabled,
|
||||
staleTime: 0,
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 단건 발송 (POST /message/{channel}/single/{prjctIdx}, contactServer 경유)
|
||||
*/
|
||||
export function useSendSingleMessageMutation(channel: MessageSendChannel, prjctIdx: number) {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (req: MessageSendSingleRequest) =>
|
||||
nextApi.post<void>(`/message/${channel}/single/${prjctIdx}`, req),
|
||||
onSuccess: (_data, req) => {
|
||||
queryClient.invalidateQueries({ queryKey: ["message-report", "send-result", String(req.sid)] });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 대량 발송 (POST /message/{channel}/bulk/{prjctIdx}, contactServer 경유)
|
||||
*/
|
||||
export function useSendBulkMessageMutation(channel: MessageSendChannel, prjctIdx: number) {
|
||||
return useMutation({
|
||||
mutationFn: (req: MessageSendBulkRequest) =>
|
||||
nextApi.post<MessageBulkSendResponse>(`/message/${channel}/bulk/${prjctIdx}`, req),
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* SID 단위 발송 결과 목록 조회 (GET /report/send-result/{sid}/{prjctCd}/{reqstSvc})
|
||||
*/
|
||||
export function useSendResultBySidQuery(
|
||||
sid: string,
|
||||
prjctCd: string,
|
||||
reqstSvc: string,
|
||||
channelTy: ChannelType | undefined,
|
||||
enabled: boolean,
|
||||
) {
|
||||
return useQuery({
|
||||
queryKey: qk.sendResultBySid(sid, prjctCd, reqstSvc, channelTy),
|
||||
queryFn: () => {
|
||||
const query = channelTy !== undefined ? `?channelTy=${channelTy}` : "";
|
||||
return nextApi.get<SendResultInfo[]>(`/message-report/send-result/${sid}/${prjctCd}/${reqstSvc}${query}`);
|
||||
},
|
||||
enabled: enabled && !!sid && !!prjctCd && !!reqstSvc,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
|
||||
45
src/query/progress.ts
Normal file
45
src/query/progress.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
"use client";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { nextApi } from "@/lib/http-client";
|
||||
import { qk } from "@/query/key/keys";
|
||||
import type { ProgressDateResponse, ProgressSearchRequest, ProgressUserResponse } from "@/types/progress";
|
||||
|
||||
/**
|
||||
* 사용자별 컨택/면접 진행 현황
|
||||
*/
|
||||
export function useUserProgressQuery(prjctIdx: number, eventTy: number, request: ProgressSearchRequest, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.userProgress(prjctIdx, eventTy, request),
|
||||
queryFn: () => nextApi.post<ProgressUserResponse[]>(`/progress/user/${prjctIdx}/${eventTy}`, request),
|
||||
enabled: enabled && prjctIdx > 0,
|
||||
staleTime: 0,
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 날짜별 전체 컨택/면접 진행 현황
|
||||
*/
|
||||
export function useDateProgressQuery(prjctIdx: number, eventTy: number, request: ProgressSearchRequest, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.dateProgress(prjctIdx, eventTy, request),
|
||||
queryFn: () => nextApi.post<ProgressDateResponse[]>(`/progress/date/${prjctIdx}/${eventTy}`, request),
|
||||
enabled: enabled && prjctIdx > 0,
|
||||
staleTime: 0,
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 날짜별 마지막 컨택/면접 진행 현황
|
||||
*/
|
||||
export function useLastDateProgressQuery(prjctIdx: number, eventTy: number, request: ProgressSearchRequest, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.lastDateProgress(prjctIdx, eventTy, request),
|
||||
queryFn: () => nextApi.post<ProgressDateResponse[]>(`/progress/last-date/${prjctIdx}/${eventTy}`, request),
|
||||
enabled: enabled && prjctIdx > 0,
|
||||
staleTime: 0,
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
@@ -131,12 +131,25 @@ export function useKartProjectListQuery(args: {
|
||||
}
|
||||
|
||||
/**
|
||||
* 프로젝트에 배정된 외주 userId 목록
|
||||
* KON/KIWI 설문 현황(리포트) 바로가기 URL
|
||||
*/
|
||||
export function useAssignedOutsourceIdsQuery(prjctIdx: number, enabled: boolean) {
|
||||
export function useSurveyRedirectUrlQuery(isKiwi: number, pkey: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.projectAssignOutsource(prjctIdx),
|
||||
queryFn: () => nextApi.get<string[]>(`/assign/prjct-outsource/${prjctIdx}`),
|
||||
queryKey: qk.surveyRedirectUrl(isKiwi, pkey),
|
||||
queryFn: () => nextApi.get<string>(`/kart/survey-redirect-url/${isKiwi}/${encodeURIComponent(pkey)}`),
|
||||
enabled: enabled && !!pkey,
|
||||
staleTime: 0,
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 프로젝트에 배정된 회사 ID 목록
|
||||
*/
|
||||
export function useAssignedCmpnIdsQuery(prjctIdx: number, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.projectAssignCmpn(prjctIdx),
|
||||
queryFn: () => nextApi.get<string[]>(`/assign/prjct-cmpn/${prjctIdx}`),
|
||||
enabled,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
@@ -194,6 +207,19 @@ export function useSaveAssignedFieldworkMutation(prjctIdx: number) {
|
||||
});
|
||||
}
|
||||
|
||||
export function useSaveAssignedCmpnMutation(prjctIdx: number) {
|
||||
const qc = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (cmpnIds: string[]) =>
|
||||
nextApi.put<void>(`/assign/prjct-cmpn/${prjctIdx}`, cmpnIds),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: qk.projectAssignCmpn(prjctIdx) });
|
||||
qc.invalidateQueries({ queryKey: qk.projectInfo(prjctIdx) });
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 프로젝트 삭제
|
||||
*/
|
||||
|
||||
@@ -7,11 +7,10 @@ import { qk } from "@/query/key/keys";
|
||||
// 프로젝트에 존재하는 타입 기준(경로/이름 다르면 import만 수정)
|
||||
import type { RoleInfo } from "@/types/role";
|
||||
import type {
|
||||
ExcelUploadResult,
|
||||
UserInfo,
|
||||
UserInfoSaveRequest,
|
||||
} from "@/types/user";
|
||||
import type { DataVerification } from "@/types/common";
|
||||
import type { DataVerification, ExcelUploadResult } from "@kri/common";
|
||||
|
||||
export function useRoleListQuery() {
|
||||
return useQuery({
|
||||
@@ -21,14 +20,6 @@ export function useRoleListQuery() {
|
||||
});
|
||||
}
|
||||
|
||||
export function useUserCompaniesQuery() {
|
||||
return useQuery({
|
||||
queryKey: qk.userCompanies(),
|
||||
queryFn: () => nextApi.get<string[]>("/user/cmpn"),
|
||||
staleTime: 10 * 60_000,
|
||||
});
|
||||
}
|
||||
|
||||
export function useUsersQuery() {
|
||||
return useQuery({
|
||||
queryKey: qk.users(),
|
||||
@@ -52,18 +43,6 @@ export function useUserDetailQuery(userId: string, enabled: boolean) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 외주 사용자 목록
|
||||
*/
|
||||
export function useOutsourceUsersQuery(enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.outsourceUsers(),
|
||||
queryFn: () => nextApi.get<UserInfo[]>("/user/outsource"),
|
||||
enabled,
|
||||
staleTime: 5 * 60_000,
|
||||
});
|
||||
}
|
||||
|
||||
export function useFieldworkUsersQuery(enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.fieldworkUsers(),
|
||||
|
||||
Reference in New Issue
Block a user