260727_01_ENH: 전화 걸기 ws 틀어막기, 선택 항목만인경우 선택된 것이 없으면 오류

This commit is contained in:
2026-07-27 16:37:26 +09:00
parent 58e9d0702e
commit 157ba6155d
9 changed files with 393 additions and 158 deletions

View File

@@ -2,7 +2,7 @@ import {NextRequest, NextResponse} from "next/server";
import {RouteContext} from "@/types/common";
import {createContactApi} from "@/lib/http-server";
import {errorToResponse} from "@kri/common/http";
import type {ListCallHistSession} from "@/types/list";
import type {ListCallHist, ListCallHistSession} from "@/types/list";
export const GET = async (_req: NextRequest, context: RouteContext) => {
try {
@@ -25,8 +25,8 @@ export const GET = async (_req: NextRequest, context: RouteContext) => {
export const PUT = async (req: NextRequest, context: RouteContext) => {
try {
const { slug = [] } = await context.params;
const [prjctIdx, sid] = slug;
if (!prjctIdx || !sid) {
const [prjctIdx, sid, action] = slug;
if (!prjctIdx || !sid || (action !== "call-start" && action !== "call-close")) {
return NextResponse.json({ message: "Not found" }, { status: 404 });
}
@@ -36,7 +36,28 @@ export const PUT = async (req: NextRequest, context: RouteContext) => {
}
const contactApi = await createContactApi();
const result = await contactApi.put(`/list-call-hist/${prjctIdx}/${sid}`, body);
const result = await contactApi.put<ListCallHist>(
`/list-call-hist/${prjctIdx}/${sid}/${action}`,
body,
);
return NextResponse.json(result, { status: 200 });
} catch (error: unknown) {
return errorToResponse(error);
}
};
export const PATCH = async (_req: NextRequest, context: RouteContext) => {
try {
const { slug = [] } = await context.params;
const [action, agentSessionId] = slug;
if (action !== "hangup" || !agentSessionId) {
return NextResponse.json({ message: "Not found" }, { status: 404 });
}
const contactApi = await createContactApi();
const result = await contactApi.patch<boolean>(
`/list-call-hist/hangup/${encodeURIComponent(agentSessionId)}`,
);
return NextResponse.json(result, { status: 200 });
} catch (error: unknown) {
return errorToResponse(error);