From 431512f5bf11ef696e4c178df5c00f20bee29ca0 Mon Sep 17 00:00:00 2001 From: keyy1315 Date: Fri, 23 May 2025 11:02:50 +0900 Subject: [PATCH] fix: change search by srlNo instead of id when search option is registration number --- src/app/api/survey-sales/route.ts | 17 +---------------- src/store/surveyFilterStore.ts | 4 ++-- 2 files changed, 3 insertions(+), 18 deletions(-) diff --git a/src/app/api/survey-sales/route.ts b/src/app/api/survey-sales/route.ts index 7d51802..c17e96d 100644 --- a/src/app/api/survey-sales/route.ts +++ b/src/app/api/survey-sales/route.ts @@ -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 } diff --git a/src/store/surveyFilterStore.ts b/src/store/surveyFilterStore.ts index 95514e8..a27f2fc 100644 --- a/src/store/surveyFilterStore.ts +++ b/src/store/surveyFilterStore.ts @@ -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: '登録番号', }, {