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> {
|
async function getCommCode(request: NextRequest): Promise<NextResponse> {
|
||||||
try {
|
try {
|
||||||
const searchParams = request.nextUrl.searchParams
|
const searchParams = request.nextUrl.searchParams
|
||||||
const headCode = searchParams.get('headCode')
|
const headId = searchParams.get('headId')
|
||||||
if (headCode === 'QNA_CD') {
|
if (headId === 'QNA_CD') {
|
||||||
return getQnaCd()
|
return getQnaCd()
|
||||||
}
|
}
|
||||||
|
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const headCd = await prisma.BC_COMM_H.findFirst({
|
const commHeadData = await prisma.BC_COMM_H.findFirst({
|
||||||
where: {
|
where: {
|
||||||
HEAD_ID: headCode,
|
HEAD_ID: headId,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
HEAD_CD: true,
|
HEAD_CD: true,
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
if (!headCd) {
|
if (!commHeadData) {
|
||||||
return NextResponse.json({ error: `${headCode}를 찾을 수 없습니다` }, { status: 404 })
|
return NextResponse.json({ error: `${headId}를 찾을 수 없습니다` }, { status: 404 })
|
||||||
}
|
}
|
||||||
|
|
||||||
if (headCode === 'SALES_OFFICE_CD') {
|
if (headId === 'SALES_OFFICE_CD') {
|
||||||
return getSaleOffice(headCd.HEAD_CD)
|
return getSaleOffice(commHeadData.HEAD_CD)
|
||||||
}
|
}
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
const roofMaterials: CommCode[] = await prisma.BC_COMM_L.findMany({
|
const roofMaterials: CommCode[] = await prisma.BC_COMM_L.findMany({
|
||||||
where: {
|
where: {
|
||||||
HEAD_CD: headCd.HEAD_CD,
|
HEAD_CD: commHeadData.HEAD_CD,
|
||||||
},
|
},
|
||||||
select: {
|
select: {
|
||||||
HEAD_CD: true,
|
HEAD_CD: true,
|
||||||
|
|||||||
@ -3,12 +3,12 @@ import type { CommCode } from '@/types/CommCode'
|
|||||||
|
|
||||||
export function useCommCode() {
|
export function useCommCode() {
|
||||||
const { axiosInstance } = useAxios()
|
const { axiosInstance } = useAxios()
|
||||||
const getCommCode = async (headCode: string): Promise<CommCode[]> => {
|
const getCommCode = async (headId: string): Promise<CommCode[]> => {
|
||||||
try {
|
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
|
return response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`common code (${headCode}) load failed:`, error)
|
console.error(`common code (${headId}) load failed:`, error)
|
||||||
throw error
|
throw error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user