Merge pull request 'refactor: 공통코드 조회 기능 내 변수명 수정' (#120) from feature/common-code into dev
Reviewed-on: #120
This commit is contained in:
commit
549bd92e2a
@ -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,
|
||||
|
||||
@ -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
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user