refactor: update inquiry type list handling and adjust filtering logic in RegistForm
This commit is contained in:
parent
56536efdf1
commit
fd35348694
@ -38,7 +38,7 @@ async function getCommonCodeListData(): Promise<NextResponse> {
|
|||||||
if (response instanceof ApiError) {
|
if (response instanceof ApiError) {
|
||||||
return NextResponse.json({ error: response.message }, { status: response.statusCode })
|
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 })
|
return NextResponse.json({ data: result })
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -57,12 +57,22 @@ export class QnaService {
|
|||||||
* @param {string[]} responseList 문의 유형 타입 목록
|
* @param {string[]} responseList 문의 유형 타입 목록
|
||||||
* @returns {CommonCode[]} 문의 유형 타입 목록
|
* @returns {CommonCode[]} 문의 유형 타입 목록
|
||||||
*/
|
*/
|
||||||
getInquiryTypeList(responseList: string[]): CommonCode[] {
|
getInquiryTypeList(responseList: any): CommonCode[] {
|
||||||
const codeList: CommonCode[] = []
|
const codeList: CommonCode[] = []
|
||||||
responseList.forEach((item: any) => {
|
const headCdList: { headCd: string; headId: string }[] = []
|
||||||
if (item.headCd === '204200' || item.headCd === '204300' || item.headCd === '204400') {
|
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({
|
codeList.push({
|
||||||
headCd: item.headCd,
|
headCd: item.headCd,
|
||||||
|
headId: headCdList.find((headCd) => headCd.headCd === item.headCd)?.headId ?? '',
|
||||||
code: item.code,
|
code: item.code,
|
||||||
name: item.codeJp,
|
name: item.codeJp,
|
||||||
refChar1: item.refChr1,
|
refChar1: item.refChr1,
|
||||||
|
|||||||
@ -153,7 +153,7 @@ export default function RegistForm() {
|
|||||||
選択してください
|
選択してください
|
||||||
</option>
|
</option>
|
||||||
{commonCodeList
|
{commonCodeList
|
||||||
.filter((code) => code.headCd === '204200')
|
.filter((code) => code.headId === 'QNA_CLS_LRG_CD')
|
||||||
.map((code) => (
|
.map((code) => (
|
||||||
<option key={code.code} value={code.code}>
|
<option key={code.code} value={code.code}>
|
||||||
{code.name}
|
{code.name}
|
||||||
|
|||||||
@ -185,6 +185,7 @@ export type InquirySaveResponse = {
|
|||||||
*/
|
*/
|
||||||
export type CommonCode = {
|
export type CommonCode = {
|
||||||
headCd: string
|
headCd: string
|
||||||
|
headId: string
|
||||||
code: string
|
code: string
|
||||||
name: string
|
name: string
|
||||||
refChar1: string
|
refChar1: string
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user