refactor: 공통코드 조회 기능 내 변수명 수정 #120

Merged
seul merged 1 commits from feature/common-code into dev 2025-08-05 13:14:08 +09:00
2 changed files with 12 additions and 12 deletions

View File

@ -6,32 +6,32 @@ import { CommonCode } from '@/types/Inquiry'
async function getCommCode(request: NextRequest): Promise<NextResponse> {
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,

View File

@ -3,12 +3,12 @@ import type { CommCode } from '@/types/CommCode'
export function useCommCode() {
const { axiosInstance } = useAxios()
const getCommCode = async (headCode: string): Promise<CommCode[]> => {
const getCommCode = async (headId: string): Promise<CommCode[]> => {
try {
const response = await axiosInstance(null).get<CommCode[]>('/api/comm-code', { params: { headCode: headCode } })
const response = await axiosInstance(null).get<CommCode[]>('/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
}
}