261008_01_ENH: 알림톡 템플릿 관련내용 구현 및 발송 구현
This commit is contained in:
@@ -77,6 +77,8 @@ export const qk = {
|
||||
templateAttachments: (tmplatIdx: number) => ["message-template", "attachment", tmplatIdx] as const,
|
||||
templateAttachment: (tmplatIdx: number, fileName: string) =>
|
||||
["message-template", "attachment", tmplatIdx, fileName] as const,
|
||||
kkoTemplateList: (keyword: string) => ["message-template", "kko", "list", keyword] as const,
|
||||
kkoTemplateDetail: (templateCode: string) => ["message-template", "kko", "detail", templateCode] as const,
|
||||
|
||||
bulkSendList: (sendTy: number, reqstSvc: string, prjctCd: string) =>
|
||||
["message-report", "bulk-list", sendTy, reqstSvc, prjctCd] as const,
|
||||
|
||||
@@ -5,18 +5,20 @@ import { nextApi } from "@/lib/http-client";
|
||||
import { qk } from "@/query/key/keys";
|
||||
import type {
|
||||
BulkSendInfo,
|
||||
BulkSendResult,
|
||||
ChannelType,
|
||||
KkoTemplateDetail,
|
||||
KkoTemplateListResponse,
|
||||
SendResultInfo,
|
||||
SendResultSummaryRequest,
|
||||
SendResultSummaryResponse,
|
||||
} 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,
|
||||
SendSingleResponse,
|
||||
} from "@/types/message";
|
||||
import type { TemplateAttachmentImage, TemplateSummaryWithPurpose, TemplateWithPurpose } from "@/types/message";
|
||||
@@ -164,6 +166,42 @@ export function useUploadTemplateBodyImageMutation(itrntPrjctCd: string) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 외부 알림톡 템플릿 목록 (POST /message-template/kko/list)
|
||||
* keyword가 빈 값이면 기본 목록(ACT 상태 첫 페이지 최대 10개)을 조회한다.
|
||||
*/
|
||||
export function useKkoTemplateListQuery(keyword: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.kkoTemplateList(keyword),
|
||||
queryFn: async () => {
|
||||
const res = await nextApi.post<KkoTemplateListResponse>(`/message-template/kko/list`, keyword ? { keyword } : {});
|
||||
// 외부 응답이므로 list가 배열이 아닌 경우를 빈 목록으로 다룬다.
|
||||
return Array.isArray(res?.list) ? res.list : [];
|
||||
},
|
||||
enabled,
|
||||
staleTime: 0,
|
||||
retry: false,
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 외부 알림톡 템플릿 상세 (POST /message-template/kko/detail)
|
||||
*/
|
||||
export const fetchKkoTemplateDetail = (templateCode: string) =>
|
||||
nextApi.post<KkoTemplateDetail>(`/message-template/kko/detail`, { templateCode });
|
||||
|
||||
export function useKkoTemplateDetailQuery(templateCode: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.kkoTemplateDetail(templateCode),
|
||||
queryFn: () => fetchKkoTemplateDetail(templateCode),
|
||||
enabled: enabled && !!templateCode,
|
||||
staleTime: 0,
|
||||
retry: false,
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 대량발송 리스트 조회 (GET /message-report/bulk-list/{sendTy}/{reqstSvc}/{prjctCd})
|
||||
*/
|
||||
@@ -236,7 +274,7 @@ export function useSendSingleMessageMutation(channel: MessageSendChannel, prjctI
|
||||
export function useSendBulkMessageMutation(channel: MessageSendChannel, prjctIdx: number) {
|
||||
return useMutation({
|
||||
mutationFn: (req: MessageSendBulkRequest) =>
|
||||
nextApi.post<MessageBulkSendResponse>(`/message-send/${channel}/bulk/${prjctIdx}`, req),
|
||||
nextApi.post<BulkSendResult>(`/message-send/${channel}/bulk/${prjctIdx}`, req),
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user