Feat/#113 등록된 맛집 검색 기능에서 캠퍼스 필터링 기능 추가#114
Conversation
- getPlacesByNameSearch, getPlacesByMenuSearch API에 campus 파라미터 추가 - 검색 페이지에서 useCampusStore로 현재 캠퍼스를 가져와 검색에 적용
|
No actionable comments were generated in the recent review. 🎉 Walkthrough캠퍼스 타입 파라미터를 장소 검색 API와 검색 페이지로 전달하도록 변경했습니다. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related issues
Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (3)
apps/web/app/places/search/page.tsx (3)
26-46:⚠️ Potential issue | 🟡 Minor
searchFunc커링 함수들에 명시적 반환 타입이 없습니다.코딩 가이드라인에서 "return types required on functions"를 요구하지만, 두
searchFunc모두 외부 함수와 내부 async 함수에 반환 타입 어노테이션이 없습니다.🔧 제안된 수정
- searchFunc: (campus: CampusType) => async (query: string) => { + searchFunc: (campus: CampusType) => async (query: string): Promise<{ id: string; name: string; address: string }[]> => { const result = await getPlacesByNameSearch(query, campus) return result.map((place) => ({ id: place.placeId, name: place.placeName, address: place.address, })) },- searchFunc: (campus: CampusType) => async (query: string) => { + searchFunc: (campus: CampusType) => async (query: string): Promise<{ id: string; name: string; address: string }[]> => { const result = await getPlacesByMenuSearch(query, campus) return result.map((place) => ({ id: place.placeId, name: place.menuName, address: place.placeName, })) },As per coding guidelines,
**/*.{ts,tsx}파일에서 함수에 반환 타입이 필요합니다.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web/app/places/search/page.tsx` around lines 26 - 46, The two curried searchFunc definitions lack explicit return types; add explicit TypeScript return annotations for both the outer function (searchFunc: (campus: CampusType) => ...) and the inner async function ((query: string) => Promise<...>) so they satisfy the "return types required on functions" rule. For the inner async function, annotate the return as Promise<Array<{id: string; name: string; address: string}>> (or the appropriate place DTO type), and for the outer one annotate it as (campus: CampusType) => (query: string) => Promise<...>; update both the NAME variant (using getPlacesByNameSearch) and the MENU variant (using getPlacesByMenuSearch) accordingly.
49-76:⚠️ Potential issue | 🟡 Minor
Page컴포넌트에 명시적 반환 타입이 없습니다.
const Page = () => {선언에 반환 타입이 누락되었습니다.🔧 제안된 수정
-const Page = () => { +const Page = (): JSX.Element => {As per coding guidelines,
**/*.{ts,tsx}파일에서 함수에 반환 타입이 필요합니다.🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web/app/places/search/page.tsx` around lines 49 - 76, The Page component lacks an explicit return type; update the Page declaration to include a React return type (e.g., change `const Page = () => {` to `const Page = (): JSX.Element => {` or `const Page = (): React.ReactElement => {`) so the function in apps/web/app/places/search/page.tsx (symbol: Page) has an explicit typed return value; no other logic changes needed—just add the return type to the Page function signature and ensure React types are available in the file.
65-73:⚠️ Potential issue | 🟡 Minor캠퍼스 변경 시
SearchPage가 리마운트되지 않아 이전 캠퍼스의 검색 결과가 잔존할 수 있습니다.
key={searchType}는 검색 타입 변경 시에만SearchPage를 리마운트합니다. 사용자가 캠퍼스를 변경하면Page가 리렌더링되어 새searchFunc클로저가 props로 전달되지만,SearchPage의 내부 상태(기존 검색 결과 등)는 초기화되지 않습니다. 결과적으로 이전 캠퍼스의 검색 결과가 새 검색을 수행하기 전까지 그대로 표시됩니다.
key에campus를 포함하면 캠퍼스 변경 시에도 내부 상태가 리셋됩니다.🐛 제안된 수정
- key={searchType} + key={`${searchType}-${campus}`}
SearchPage컴포넌트가 내부 상태로 검색 결과를 관리하는지 확인하려면 아래 스크립트를 실행하세요.#!/bin/bash # SearchPage 컴포넌트 내부 상태 및 searchFunc 의존성 확인 fd -e tsx -e ts SearchPage --exec cat {}🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@apps/web/app/places/search/page.tsx` around lines 65 - 73, The SearchPage currently only remounts when searchType changes (key={searchType}), so when campus changes its internal state (previous search results) persists; update the SearchPage key to include the campus as well (combine searchType and campus) so that when campus changes the component is remounted and its internal state resets; modify the JSX where SearchPage is rendered (the element with props useBackHandler, placeholder, searchFunc, onSelectPlace) to use a composite key containing both searchType and campus (e.g., a concatenation or tuple) so remounting occurs on either change.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Outside diff comments:
In `@apps/web/app/places/search/page.tsx`:
- Around line 26-46: The two curried searchFunc definitions lack explicit return
types; add explicit TypeScript return annotations for both the outer function
(searchFunc: (campus: CampusType) => ...) and the inner async function ((query:
string) => Promise<...>) so they satisfy the "return types required on
functions" rule. For the inner async function, annotate the return as
Promise<Array<{id: string; name: string; address: string}>> (or the appropriate
place DTO type), and for the outer one annotate it as (campus: CampusType) =>
(query: string) => Promise<...>; update both the NAME variant (using
getPlacesByNameSearch) and the MENU variant (using getPlacesByMenuSearch)
accordingly.
- Around line 49-76: The Page component lacks an explicit return type; update
the Page declaration to include a React return type (e.g., change `const Page =
() => {` to `const Page = (): JSX.Element => {` or `const Page = ():
React.ReactElement => {`) so the function in apps/web/app/places/search/page.tsx
(symbol: Page) has an explicit typed return value; no other logic changes
needed—just add the return type to the Page function signature and ensure React
types are available in the file.
- Around line 65-73: The SearchPage currently only remounts when searchType
changes (key={searchType}), so when campus changes its internal state (previous
search results) persists; update the SearchPage key to include the campus as
well (combine searchType and campus) so that when campus changes the component
is remounted and its internal state resets; modify the JSX where SearchPage is
rendered (the element with props useBackHandler, placeholder, searchFunc,
onSelectPlace) to use a composite key containing both searchType and campus
(e.g., a concatenation or tuple) so remounting occurs on either change.
- TypeConfig 타입으로 TYPE_CONFIG 구조 명확화 - key에 campus 포함하여 캠퍼스 변경 시 컴포넌트 리마운트 보장
| searchFunc: async (query: string) => { | ||
| const result = await getPlacesByNameSearch(query) | ||
| searchFunc: (campus: CampusType) => async (query: string) => { | ||
| const result = await getPlacesByNameSearch(query, campus) |
There was a problem hiding this comment.
커링 패턴을 사용하여 캠퍼스 값을 먼저 바인딩하고, 검색 쿼리만 받는 함수 반환
이 방식을 통해 SearchPage 컴포넌트를 전혀 수정하지 않고, 기존에 요구하던 (query: string) => Promise<Result[]> Props 타입을 그대로 호환할 수 있습니다.
#️⃣연관된 이슈
📝작업 내용
가게 이름 및 메뉴 검색 기능에 캠퍼스별 필터링을 추가하여, 사용자가 선택한 캠퍼스에 맞는 검색 결과만 표시되도록 개선했습니다.
1. 검색 API에 캠퍼스 파라미터 추가
커링 패턴을 사용하여
searchFunc에 캠퍼스 적용SearchPage컴포넌트가 요구하는(query: string) => Promise<Result[]>타입과 호환searchFunc: (campus) => async (query) => { ... }형태로 구현스크린샷 (선택)
💬리뷰 요구사항(선택)
Summary by CodeRabbit