diff --git a/src/app/api/comm-code/route.ts b/src/app/api/comm-code/route.ts index 26340b6..71acdd1 100644 --- a/src/app/api/comm-code/route.ts +++ b/src/app/api/comm-code/route.ts @@ -6,32 +6,32 @@ import { CommonCode } from '@/types/Inquiry' async function getCommCode(request: NextRequest): Promise { try { const searchParams = request.nextUrl.searchParams - const headCode = searchParams.get('headCode') - if (headCode === 'QNA_CD') { + const headId = searchParams.get('headId') + if (headId === 'QNA_CD') { return getQnaCd() } // @ts-ignore - const headCd = await prisma.BC_COMM_H.findFirst({ + const commHeadData = await prisma.BC_COMM_H.findFirst({ where: { - HEAD_ID: headCode, + HEAD_ID: headId, }, select: { HEAD_CD: true, }, }) - if (!headCd) { - return NextResponse.json({ error: `${headCode}를 찾을 수 없습니다` }, { status: 404 }) + if (!commHeadData) { + return NextResponse.json({ error: `${headId}를 찾을 수 없습니다` }, { status: 404 }) } - if (headCode === 'SALES_OFFICE_CD') { - return getSaleOffice(headCd.HEAD_CD) + if (headId === 'SALES_OFFICE_CD') { + return getSaleOffice(commHeadData.HEAD_CD) } // @ts-ignore const roofMaterials: CommCode[] = await prisma.BC_COMM_L.findMany({ where: { - HEAD_CD: headCd.HEAD_CD, + HEAD_CD: commHeadData.HEAD_CD, }, select: { HEAD_CD: true, diff --git a/src/hooks/useCommCode.ts b/src/hooks/useCommCode.ts index 73f3918..ddf551a 100644 --- a/src/hooks/useCommCode.ts +++ b/src/hooks/useCommCode.ts @@ -3,12 +3,12 @@ import type { CommCode } from '@/types/CommCode' export function useCommCode() { const { axiosInstance } = useAxios() - const getCommCode = async (headCode: string): Promise => { + const getCommCode = async (headId: string): Promise => { try { - const response = await axiosInstance(null).get('/api/comm-code', { params: { headCode: headCode } }) + const response = await axiosInstance(null).get('/api/comm-code', { params: { headId: headId } }) return response.data } catch (error) { - console.error(`common code (${headCode}) load failed:`, error) + console.error(`common code (${headId}) load failed:`, error) throw error } }