fix: change search by srlNo instead of id when search option is registration number

This commit is contained in:
Dayoung 2025-05-23 11:02:50 +09:00
parent 0521c88e79
commit 431512f5bf
2 changed files with 3 additions and 18 deletions

View File

@ -32,6 +32,7 @@ const SEARCH_OPTIONS = [
'POST_CODE', // 우편번호
'ADDRESS', // 주소
'ADDRESS_DETAIL', // 상세주소
'SRL_NO', // 등록번호
] as const
// 페이지당 항목 수
@ -50,13 +51,6 @@ const createKeywordSearchCondition = (keyword: string, searchOption: string): Wh
// 모든 필드 검색 시 OR 조건 사용
where.OR = []
// ID가 숫자인 경우 ID 검색 조건 추가
if (keyword.match(/^\d+$/) || !isNaN(Number(keyword))) {
where.OR.push({
ID: { equals: Number(keyword) },
})
}
where.OR.push(
...SEARCH_OPTIONS.map((field) => ({
[field]: { contains: keyword },
@ -65,15 +59,6 @@ const createKeywordSearchCondition = (keyword: string, searchOption: string): Wh
} else if (SEARCH_OPTIONS.includes(searchOption.toUpperCase() as any)) {
// 특정 필드 검색
where[searchOption.toUpperCase()] = { contains: keyword }
} else if (searchOption === 'id') {
// ID 검색 (숫자 변환 필요)
const number = Number(keyword)
if (!isNaN(number)) {
where.ID = { equals: number }
} else {
// 유효하지 않은 ID 검색 시 빈 결과 반환
where.ID = { equals: null }
}
}
return where
}

View File

@ -6,7 +6,7 @@ export const SEARCH_OPTIONS = [
label: '全体',
},
{
id: 'id',
id: 'srl_no',
label: '登録番号',
},
{
@ -41,7 +41,7 @@ export const SEARCH_OPTIONS_PARTNERS = [
label: '全体',
},
{
id: 'id',
id: 'srl_no',
label: '登録番号',
},
{