diff --git a/src/app/api/qna/route.ts b/src/app/api/qna/route.ts index 767f9ca..0fc1046 100644 --- a/src/app/api/qna/route.ts +++ b/src/app/api/qna/route.ts @@ -38,7 +38,7 @@ async function getCommonCodeListData(): Promise { if (response instanceof ApiError) { return NextResponse.json({ error: response.message }, { status: response.statusCode }) } - const result = service.getInquiryTypeList(response.data.apiCommCdList) + const result = service.getInquiryTypeList(response.data) return NextResponse.json({ data: result }) } diff --git a/src/app/api/qna/service.ts b/src/app/api/qna/service.ts index cbba527..93774a9 100644 --- a/src/app/api/qna/service.ts +++ b/src/app/api/qna/service.ts @@ -57,12 +57,22 @@ export class QnaService { * @param {string[]} responseList 문의 유형 타입 목록 * @returns {CommonCode[]} 문의 유형 타입 목록 */ - getInquiryTypeList(responseList: string[]): CommonCode[] { + getInquiryTypeList(responseList: any): CommonCode[] { const codeList: CommonCode[] = [] - responseList.forEach((item: any) => { - if (item.headCd === '204200' || item.headCd === '204300' || item.headCd === '204400') { + const headCdList: { headCd: string; headId: string }[] = [] + responseList.apiHeadCdList.forEach((item: any) => { + if (item.headId === 'QNA_CLS_LRG_CD' || item.headId === 'QNA_CLS_MID_CD' || item.headId === 'QNA_CLS_SML_CD') { + headCdList.push({ + headCd: item.headCd, + headId: item.headId, + }) + } + }) + responseList.apiCommCdList.forEach((item: any) => { + if (headCdList.some((headCd) => headCd.headCd === item.headCd)) { codeList.push({ headCd: item.headCd, + headId: headCdList.find((headCd) => headCd.headCd === item.headCd)?.headId ?? '', code: item.code, name: item.codeJp, refChar1: item.refChr1, diff --git a/src/components/inquiry/RegistForm.tsx b/src/components/inquiry/RegistForm.tsx index 0011d9e..e6eca3d 100644 --- a/src/components/inquiry/RegistForm.tsx +++ b/src/components/inquiry/RegistForm.tsx @@ -153,7 +153,7 @@ export default function RegistForm() { 選択してください {commonCodeList - .filter((code) => code.headCd === '204200') + .filter((code) => code.headId === 'QNA_CLS_LRG_CD') .map((code) => (