diff --git a/src/app/api/list-external/[[...slug]]/route.ts b/src/app/api/list-external/[[...slug]]/route.ts index 3418668..a0a0e72 100644 --- a/src/app/api/list-external/[[...slug]]/route.ts +++ b/src/app/api/list-external/[[...slug]]/route.ts @@ -15,17 +15,17 @@ export const GET = async (req: NextRequest, context: RouteContext) => { } const { slug = [] } = await context.params; - const [action, prjctIdx, sid] = slug; + const [action, prjctCd, sid] = slug; const contactApi = await createContactApiWithApiKey(apiKey); - if (action === "header" && prjctIdx) { - const result = await contactApi.get(`/list-external/header/${prjctIdx}`); + if (action === "header" && prjctCd) { + const result = await contactApi.get(`/list-external/header/${encodeURIComponent(prjctCd)}`); return NextResponse.json(result, { status: 200 }); } - if (action === "search" && prjctIdx && sid) { + if (action === "search" && prjctCd && sid) { const result = await contactApi.get( - `/list-external/search/${prjctIdx}/${encodeURIComponent(sid)}`, + `/list-external/search/${encodeURIComponent(prjctCd)}/${encodeURIComponent(sid)}`, ); return NextResponse.json(result, { status: 200 }); } @@ -45,13 +45,13 @@ export const PATCH = async (req: NextRequest, context: RouteContext) => { } const { slug = [] } = await context.params; - const [action, prjctIdx, sid] = slug; + const [action, prjctCd, sid] = slug; - if (action === "update" && prjctIdx && sid) { + if (action === "update" && prjctCd && sid) { const body = await req.json().catch(() => null); const contactApi = await createContactApiWithApiKey(apiKey); const result = await contactApi.patch( - `/list-external/update/${prjctIdx}/${encodeURIComponent(sid)}`, + `/list-external/update/${encodeURIComponent(prjctCd)}/${encodeURIComponent(sid)}`, body, ); return NextResponse.json(result, { status: 200 }); @@ -74,35 +74,35 @@ export const POST = async (req: NextRequest, context: RouteContext) => { const { slug = [] } = await context.params; const [action] = slug; const { searchParams } = req.nextUrl; - const prjctIdx = searchParams.get("prjctIdx"); + const prjctCd = searchParams.get("prjctCd"); const sid = searchParams.get("sid"); const contactApi = await createContactApiWithApiKey(apiKey); if (action === "header") { - if (!prjctIdx) { - return NextResponse.json({ message: "prjctIdx는 필수입니다." }, { status: 400 }); + if (!prjctCd) { + return NextResponse.json({ message: "prjctCd는 필수입니다." }, { status: 400 }); } - const result = await contactApi.get(`/list-external/header/${prjctIdx}`); + const result = await contactApi.get(`/list-external/header/${encodeURIComponent(prjctCd)}`); return NextResponse.json(result, { status: 200 }); } if (action === "search") { - if (!prjctIdx || !sid) { - return NextResponse.json({ message: "prjctIdx, sid는 필수입니다." }, { status: 400 }); + if (!prjctCd || !sid) { + return NextResponse.json({ message: "prjctCd, sid는 필수입니다." }, { status: 400 }); } const result = await contactApi.get( - `/list-external/search/${prjctIdx}/${encodeURIComponent(sid)}`, + `/list-external/search/${encodeURIComponent(prjctCd)}/${encodeURIComponent(sid)}`, ); return NextResponse.json(result, { status: 200 }); } if (action === "update") { - if (!prjctIdx || !sid) { - return NextResponse.json({ message: "prjctIdx, sid는 필수입니다." }, { status: 400 }); + if (!prjctCd || !sid) { + return NextResponse.json({ message: "prjctCd, sid는 필수입니다." }, { status: 400 }); } const body = await req.json().catch(() => null); const result = await contactApi.patch( - `/list-external/update/${prjctIdx}/${encodeURIComponent(sid)}`, + `/list-external/update/${encodeURIComponent(prjctCd)}/${encodeURIComponent(sid)}`, body, ); return NextResponse.json(result, { status: 200 }); diff --git a/src/types/list.ts b/src/types/list.ts index bd21367..51c1f95 100644 --- a/src/types/list.ts +++ b/src/types/list.ts @@ -369,7 +369,7 @@ export type ListSearchWithFullResult = ListSearchWithResult & { }; export type ListSearchExternal = { - prjctIdx: number; + prjctCd: string; sid: string; itemList: Record; };