261029_01_ENH: 이메일·문자·알림톡 템플릿 삭제 기능 추가 및 삭제
This commit is contained in:
@@ -18,6 +18,7 @@ import type { FileResponse, PageRequest, PageResponse } from "@kri/common";
|
||||
import { apiError, HttpError } from "@kri/common/http";
|
||||
import type { ProjectMainTemplateUpdateRequest } from "@/types/project";
|
||||
import type {
|
||||
KkoSenderProfile,
|
||||
MessageSendChannel,
|
||||
MessageSendSingleRequest,
|
||||
SendCancelRequest,
|
||||
@@ -204,16 +205,31 @@ export function useUploadTemplateBodyImageMutation(itrntPrjctCd: string) {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 외부 알림톡 템플릿 목록 (POST /message-template/kko/list)
|
||||
* keyword가 빈 값이면 기본 목록(ACT 상태 첫 페이지 최대 10개)을 조회한다.
|
||||
*/
|
||||
export function useKkoTemplateListQuery(keyword: string, enabled: boolean) {
|
||||
/** 외부 알림톡 발신 프로필 조회 */
|
||||
export function useKkoSenderProfilesQuery(enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.kkoTemplateList(keyword),
|
||||
queryKey: qk.kkoSenderProfiles,
|
||||
queryFn: async () => {
|
||||
const profiles: unknown = await nextApi.get("/message-template/kko/profiles");
|
||||
if (!Array.isArray(profiles) || !profiles.every((profile) =>
|
||||
profile && typeof profile.senderKey === "string" && profile.senderKey.trim() &&
|
||||
typeof profile.name === "string" && typeof profile.uuid === "string" && profile.uuid.trim(),
|
||||
)) throw new Error("발신 프로필 응답 형식이 올바르지 않습니다.");
|
||||
return profiles as KkoSenderProfile[];
|
||||
},
|
||||
enabled,
|
||||
retry: false,
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
|
||||
/** keyword가 빈 값이면 선택한 프로필의 기본 목록을 조회한다. */
|
||||
export function useKkoTemplateListQuery(senderKey: string, keyword: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.kkoTemplateList(senderKey, keyword),
|
||||
queryFn: async () => {
|
||||
const res = await nextApi
|
||||
.post<KkoTemplateListResponse>(`/message-template/kko/list`, keyword ? { keyword } : {}, {
|
||||
.post<KkoTemplateListResponse>(`/message-template/kko/list`, { senderKey, ...(keyword ? { keyword } : {}) }, {
|
||||
skipResponseErrorHandler: true,
|
||||
})
|
||||
.catch((error: unknown) => {
|
||||
@@ -223,7 +239,7 @@ export function useKkoTemplateListQuery(keyword: string, enabled: boolean) {
|
||||
// 외부 응답이므로 list가 배열이 아닌 경우를 빈 목록으로 다룬다.
|
||||
return Array.isArray(res?.list) ? res.list : [];
|
||||
},
|
||||
enabled,
|
||||
enabled: enabled && !!senderKey,
|
||||
staleTime: 0,
|
||||
retry: false,
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
@@ -233,14 +249,14 @@ export function useKkoTemplateListQuery(keyword: string, enabled: boolean) {
|
||||
/**
|
||||
* 외부 알림톡 템플릿 상세 (POST /message-template/kko/detail)
|
||||
*/
|
||||
export const fetchKkoTemplateDetail = (templateCode: string) =>
|
||||
nextApi.post<KkoTemplateDetail>(`/message-template/kko/detail`, { templateCode });
|
||||
export const fetchKkoTemplateDetail = (senderKey: string, templateCode: string) =>
|
||||
nextApi.post<KkoTemplateDetail>(`/message-template/kko/detail`, { senderKey, templateCode });
|
||||
|
||||
export function useKkoTemplateDetailQuery(templateCode: string, enabled: boolean) {
|
||||
export function useKkoTemplateDetailQuery(senderKey: string, templateCode: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.kkoTemplateDetail(templateCode),
|
||||
queryFn: () => fetchKkoTemplateDetail(templateCode),
|
||||
enabled: enabled && !!templateCode,
|
||||
queryKey: qk.kkoTemplateDetail(senderKey, templateCode),
|
||||
queryFn: () => fetchKkoTemplateDetail(senderKey, templateCode),
|
||||
enabled: enabled && !!senderKey && !!templateCode,
|
||||
staleTime: 0,
|
||||
retry: false,
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
|
||||
Reference in New Issue
Block a user