[st] refactor: 알림톡발송 코드 분리
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
import { client } from "@/shared/api/client";
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
import type { PageableList } from "@/shared/model";
|
||||
|
||||
import type {
|
||||
NtftalkTemplate,
|
||||
TemplateVariablesResponse,
|
||||
} from "../../model/notice-talk/notice-talk-sending-interface";
|
||||
|
||||
export const NTFTALK_TEMPLATE_LIST_PARAMS = {
|
||||
sort: "createdAt,desc",
|
||||
senderKey: "",
|
||||
inspectionStatus: "APR",
|
||||
templateMessageType: "BA",
|
||||
page: 0,
|
||||
size: 10,
|
||||
};
|
||||
|
||||
/**
|
||||
* 알림톡 발송 화면용 Ntftalk API
|
||||
*/
|
||||
export class NoticeTalkSendingApiService {
|
||||
async getTemplatePage(
|
||||
params: typeof NTFTALK_TEMPLATE_LIST_PARAMS = NTFTALK_TEMPLATE_LIST_PARAMS,
|
||||
): Promise<PageableList<NtftalkTemplate>> {
|
||||
const response = await client.get<PageableList<NtftalkTemplate>>(
|
||||
ENDPOINT.NTFTALK_SERVICE.TEMP,
|
||||
{ params },
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
|
||||
async getTemplateVariables(
|
||||
templateCode: string,
|
||||
): Promise<TemplateVariablesResponse> {
|
||||
const response = await client.get<TemplateVariablesResponse>(
|
||||
`${ENDPOINT.NTFTALK_SERVICE.ATA_SEND}/template-variables/${templateCode}`,
|
||||
);
|
||||
return response.data;
|
||||
}
|
||||
}
|
||||
|
||||
export const noticeTalkSendingApi = new NoticeTalkSendingApiService();
|
||||
@@ -0,0 +1,33 @@
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
|
||||
import { ENDPOINT } from "@/shared/config";
|
||||
|
||||
import {
|
||||
noticeTalkSendingApi,
|
||||
NTFTALK_TEMPLATE_LIST_PARAMS,
|
||||
} from "./notice-talk-sending-service";
|
||||
|
||||
export function useNtftalkTemplateList() {
|
||||
return useQuery({
|
||||
queryKey: [
|
||||
ENDPOINT.NTFTALK_SERVICE.TEMP,
|
||||
"ntitlk-sndng",
|
||||
NTFTALK_TEMPLATE_LIST_PARAMS,
|
||||
],
|
||||
queryFn: () =>
|
||||
noticeTalkSendingApi.getTemplatePage(NTFTALK_TEMPLATE_LIST_PARAMS),
|
||||
});
|
||||
}
|
||||
|
||||
export function useNtftalkTemplateVariables(templateCode: string) {
|
||||
return useQuery({
|
||||
queryKey: [
|
||||
ENDPOINT.NTFTALK_SERVICE.ATA_SEND,
|
||||
"template-variables",
|
||||
templateCode,
|
||||
],
|
||||
queryFn: () =>
|
||||
noticeTalkSendingApi.getTemplateVariables(templateCode),
|
||||
enabled: Boolean(templateCode),
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user