fix: change search by srlNo instead of id when search option is registration number
This commit is contained in:
parent
0521c88e79
commit
431512f5bf
@ -32,6 +32,7 @@ const SEARCH_OPTIONS = [
|
|||||||
'POST_CODE', // 우편번호
|
'POST_CODE', // 우편번호
|
||||||
'ADDRESS', // 주소
|
'ADDRESS', // 주소
|
||||||
'ADDRESS_DETAIL', // 상세주소
|
'ADDRESS_DETAIL', // 상세주소
|
||||||
|
'SRL_NO', // 등록번호
|
||||||
] as const
|
] as const
|
||||||
|
|
||||||
// 페이지당 항목 수
|
// 페이지당 항목 수
|
||||||
@ -50,13 +51,6 @@ const createKeywordSearchCondition = (keyword: string, searchOption: string): Wh
|
|||||||
// 모든 필드 검색 시 OR 조건 사용
|
// 모든 필드 검색 시 OR 조건 사용
|
||||||
where.OR = []
|
where.OR = []
|
||||||
|
|
||||||
// ID가 숫자인 경우 ID 검색 조건 추가
|
|
||||||
if (keyword.match(/^\d+$/) || !isNaN(Number(keyword))) {
|
|
||||||
where.OR.push({
|
|
||||||
ID: { equals: Number(keyword) },
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
where.OR.push(
|
where.OR.push(
|
||||||
...SEARCH_OPTIONS.map((field) => ({
|
...SEARCH_OPTIONS.map((field) => ({
|
||||||
[field]: { contains: keyword },
|
[field]: { contains: keyword },
|
||||||
@ -65,15 +59,6 @@ const createKeywordSearchCondition = (keyword: string, searchOption: string): Wh
|
|||||||
} else if (SEARCH_OPTIONS.includes(searchOption.toUpperCase() as any)) {
|
} else if (SEARCH_OPTIONS.includes(searchOption.toUpperCase() as any)) {
|
||||||
// 특정 필드 검색
|
// 특정 필드 검색
|
||||||
where[searchOption.toUpperCase()] = { contains: keyword }
|
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
|
return where
|
||||||
}
|
}
|
||||||
|
|||||||
@ -6,7 +6,7 @@ export const SEARCH_OPTIONS = [
|
|||||||
label: '全体',
|
label: '全体',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'id',
|
id: 'srl_no',
|
||||||
label: '登録番号',
|
label: '登録番号',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@ -41,7 +41,7 @@ export const SEARCH_OPTIONS_PARTNERS = [
|
|||||||
label: '全体',
|
label: '全体',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
id: 'id',
|
id: 'srl_no',
|
||||||
label: '登録番号',
|
label: '登録番号',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user