-
Notifications
You must be signed in to change notification settings - Fork 1
Refactor/#54 API 응답 형식 수정 및 연결 테스트, 로직 수정 #55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
5d98f88
751745c
625e3d4
ed23179
9d85026
dcd22b7
d058887
f1fd0f8
9a21ca0
47a5bd2
bc6a31d
492ceb4
de95eb5
fa0b30f
ede094d
3025941
00752bc
4afcef2
b5b3705
edfb9f4
49b9ea3
c8562f5
6930dd9
b529cd7
83ba81f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,25 @@ | ||
| import { useMutation } from '@tanstack/react-query' | ||
| import type { NewPlaceRequest } from '@/_apis/schemas/place' | ||
| import { createNewPlace } from '@/_apis/services/place' | ||
| import { useRouter } from 'next/navigation' | ||
| import { CLIENT_PATH } from '@/_constants/path' | ||
|
|
||
| export const useCreateNewPlace = () => { | ||
| const { replace } = useRouter() | ||
|
|
||
| return useMutation({ | ||
| mutationFn: async (placeData: NewPlaceRequest) => | ||
| await createNewPlace(placeData), | ||
| onSuccess: (res) => { | ||
| if (res.status === 'OK') { | ||
| replace(CLIENT_PATH.PLACE_NEW_SUCCESS) | ||
| } else { | ||
| replace(CLIENT_PATH.PLACE_NEW_FAIL) | ||
| } | ||
| }, | ||
| onError: (error) => { | ||
| console.error(error) | ||
| replace(CLIENT_PATH.PLACE_NEW_FAIL) | ||
| }, | ||
| }) | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3,6 +3,7 @@ import { API_PATH } from '@/_constants/path' | |
| import { CategorySchema, Category } from '../schemas/category' | ||
|
|
||
| export const getCategories = async (): Promise<Category[]> => { | ||
| const { data } = await axiosInstance.get(API_PATH.CATEGORY) | ||
| const { data: response } = await axiosInstance.get(API_PATH.CATEGORY) | ||
| const { data } = response | ||
| return CategorySchema.array().parse(data) | ||
| } | ||
|
Comment on lines
5
to
9
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain중첩된 API 응답 구조를 올바르게 처리하고 있습니다. 백엔드 응답 형식 변경에 맞춰 2단계 데이터 추출 로직이 정확하게 구현되었습니다. Zod 스키마를 통한 런타임 검증도 유지되고 있어 타입 안정성이 보장됩니다. 다만, PR 설명에 따르면 이 변경사항이 여러 API 서비스에 영향을 미친다고 하니, 다른 API 서비스 파일들도 동일한 패턴으로 업데이트되었는지 확인해주세요. 다음 스크립트를 실행하여 다른 API 서비스 파일들의 일관성을 확인하세요: 🏁 Script executed: #!/bin/bash
# Description: 다른 API 서비스 파일들이 동일한 중첩 응답 구조를 처리하는지 확인
# API 서비스 파일들에서 axiosInstance.get/post/put/delete 호출 패턴 검색
echo "=== Checking API service files for response handling pattern ==="
fd -e ts -e tsx --full-path '_apis/services' --exec rg -n -A 3 -B 1 'axiosInstance\.(get|post|put|delete|patch)' {}
echo ""
echo "=== Checking for old pattern (direct data destructuring) ==="
# 이전 패턴 (const { data } = await axiosInstance...)을 직접 사용하는 경우 검색
fd -e ts -e tsx --full-path '_apis/services' --exec rg -n 'const\s*\{\s*data\s*\}\s*=\s*await\s+axiosInstance' {}Length of output: 3516 API 서비스 파일들 간 응답 처리 패턴이 일관되지 않습니다. 즉각적인 수정이 필요합니다. 검증 결과 일부 함수는 새로운 중첩 응답 구조(데이터 2단계 추출)로 업데이트되었으나, 다른 함수들은 여전히 이전 패턴(직접 데이터 추출)을 사용하고 있습니다. 백엔드 응답 형식이 실제로 변경되었다면, 다음 함수들은 런타임에 실패할 것입니다: 수정 필요 위치:
이 모든 함수를 category.ts의 getCategories와 동일한 패턴으로 업데이트하세요: const { data: response } = await axiosInstance.get(...)
const { data } = response
return Schema.parse(data)🤖 Prompt for AI Agents |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,21 +1,21 @@ | ||
| import { COLOR_VARIANTS } from '@repo/ui/consts/colorVariant' | ||
|
|
||
| export const CAMPUS = { | ||
| singwan: '신관', | ||
| cheonan: '천안', | ||
| yesan: '예산', | ||
| SINGWAN: '신관', | ||
| CHEONAN: '천안', | ||
| YESAN: '예산', | ||
| } as const | ||
|
|
||
| export const CAMPUS_LOCATION = { | ||
| singwan: { latitude: 36.469483428385914, longitude: 127.14059828594706 }, | ||
| cheonan: { latitude: 36.85101236046876, longitude: 127.15093333537096 }, | ||
| yesan: { latitude: 36.66990298154316, longitude: 126.85937468290652 }, | ||
| SINGWAN: { latitude: 36.469483428385914, longitude: 127.14059828594706 }, | ||
| CHEONAN: { latitude: 36.85101236046876, longitude: 127.15093333537096 }, | ||
| YESAN: { latitude: 36.66990298154316, longitude: 126.85937468290652 }, | ||
| } as const | ||
|
|
||
| export const CAMPUS_COLOR = { | ||
| singwan: COLOR_VARIANTS.red, | ||
| cheonan: COLOR_VARIANTS.blue, | ||
| yesan: COLOR_VARIANTS.yellow, | ||
| SINGWAN: COLOR_VARIANTS.red, | ||
| CHEONAN: COLOR_VARIANTS.blue, | ||
| YESAN: COLOR_VARIANTS.yellow, | ||
| } as const | ||
| export type CampusType = keyof typeof CAMPUS | ||
| export const CAMPUS_LIST = Object.keys(CAMPUS) as CampusType[] |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,11 +1,11 @@ | ||
| import { CategoryHandlers } from './categoryHandlers' | ||
| // import { CategoryHandlers } from './categoryHandlers' | ||
| import { PlaceHandlers } from './placeHandlers' | ||
| import { EventHandlers } from './eventHandlers' | ||
| import { LikeHandlers } from './likeHandlers' | ||
| import { RequestHandlers } from './requestHandlers' | ||
|
|
||
| export const handlers = [ | ||
| ...CategoryHandlers, | ||
| // ...CategoryHandlers, | ||
|
Comment on lines
+1
to
+8
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chainCategoryHandlers 비활성화 확인 필요
다음 스크립트로 카테고리 API 사용처를 확인하여 영향 범위를 검증하세요: 🏁 Script executed: #!/bin/bash
# Description: 카테고리 관련 API 호출 및 의존성 확인
# 카테고리 API 서비스 호출 확인
echo "=== Category API 사용처 확인 ==="
rg -n --type=ts --type=tsx 'from.*@/_apis/services/category' -A 3
# 카테고리 쿼리 훅 사용 확인
echo -e "\n=== Category Query 사용처 확인 ==="
rg -n --type=ts --type=tsx 'useCategoryQueries' -A 2Length of output: 114 스크립트가 🏁 Script executed: #!/bin/bash
# Description: 카테고리 관련 API 호출 및 의존성 확인 (수정)
# 카테고리 핸들러 사용처 확인
echo "=== CategoryHandlers 사용처 확인 ==="
rg -n 'CategoryHandlers' --type=ts
# 카테고리 API 서비스 호출 확인 (다양한 패턴)
echo -e "\n=== Category API 서비스 사용처 확인 ==="
rg -n 'category' --type=ts -i | grep -E '(import|from|service|api)' | head -20
# categoryHandlers 파일 존재 확인
echo -e "\n=== categoryHandlers 파일 검색 ==="
fd categoryHandlers
# 전체 handlers 파일 내용 확인
echo -e "\n=== handlers 파일 전체 내용 ==="
cat apps/web/app/_mocks/handlers/index.tsLength of output: 3116 categoryHandlers 파일의 내용과 useCategoryQueries 구현을 확인하여 영향 범위를 정확하게 파악하겠습니다. 🏁 Script executed: #!/bin/bash
# Description: 카테고리 핸들러와 쿼리 훅 상세 분석
# categoryHandlers.ts 파일 내용 확인
echo "=== categoryHandlers.ts 파일 내용 ==="
cat apps/web/app/_mocks/handlers/categoryHandlers.ts
# useCategoryQueries 구현 확인
echo -e "\n=== useCategoryQueries 훅 구현 확인 ==="
fd category -type f | grep -E '(queries|query)' | head -10
# category 쿼리 파일 찾기
echo -e "\n=== category 쿼리 파일 정확한 위치 ==="
find . -name "*category*" -type f | grep -E '(queries|query)' | grep -v node_modules
# category 쿼리 파일 내용
echo -e "\n=== category 쿼리 구현 ==="
cat apps/web/app/_apis/queries/category.ts 2>/dev/null || cat apps/web/app/_apis/queries/category/index.ts 2>/dev/null || echo "File not found in expected locations"Length of output: 1135 getCategories 서비스 구현을 확인하여 실제 API 호출 endpoint를 검증하겠습니다. 🏁 Script executed: #!/bin/bash
# Description: getCategories 서비스 구현 확인
# category 서비스 파일 확인
echo "=== category 서비스 구현 ==="
cat apps/web/app/_apis/services/category.ts 2>/dev/null || echo "File not found"
# API_PATH 상수 확인 (CATEGORY endpoint)
echo -e "\n=== API_PATH.CATEGORY 정의 확인 ==="
rg -n 'CATEGORY' apps/web/app/_constants/path.ts
# 테스트 파일에서 categoryHandlers 사용 여부 확인
echo -e "\n=== 테스트 파일에서 categoryHandlers 사용 여부 ==="
fd -e test.ts -e spec.ts -e test.tsx -e spec.tsx | xargs rg -l 'CategoryHandlers\|category.*handlers\|Category.*mock' 2>/dev/null || echo "테스트 파일에서 CategoryHandlers 직접 사용 없음"
# handlers 등록 파일 자체가 어디서 사용되는지 확인
echo -e "\n=== handlers 파일(index.ts) 사용처 ==="
rg -n 'from.*_mocks/handlers' --type=ts | head -20Length of output: 687 CategoryHandlers 주석 처리로 인한 카테고리 기능 중단 문제 확인 검증 결과, CategoryHandlers 주석 처리는 실제 문제입니다:
CategoryHandlers의 주석을 제거하고 활성화하세요: 🤖 Prompt for AI Agents |
||
| ...PlaceHandlers, | ||
| ...EventHandlers, | ||
| ...LikeHandlers, | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
photoId의 nullable 변경 확인 필요photoId가 nullable로 변경되었습니다. 이는 기존에photoId를 사용하는 모든 컴포넌트에서 null 케이스를 처리하는지 확인이 필요합니다.다음 스크립트로
photoId사용처를 확인하세요:🏁 Script executed:
Length of output: 27
Now I'll run a corrected script to search for photoId usage:
Length of output: 11259
이제 PreviewPlace 컴포넌트의 상세 코드를 검토하여 null 처리 여부를 확인하겠습니다.
Length of output: 879
PreviewPlace 컴포넌트의 타입 정의와 전체 구조를 확인하겠습니다.
Length of output: 2009
이제 place.ts 파일의 PlaceByMap 타입 정의를 확인하겠습니다.
Length of output: 1935
PreviewPlace.tsx에서 nullable photoId 처리 필수
photoId가 nullable로 변경되었으나PreviewPlace.tsx40줄에서 React 키로 직접 사용되고 있습니다.photo.photoId가null이면 React는 유효하지 않은 키 경고를 발생시키고 런타임 오류가 발생합니다.apps/web/app/map/_components/PreviewPlace/PreviewPlace.tsx40줄:key={photo.photoId}- null 체크 필수apps/admin/src/app/request/[id]/_api/types.ts4줄:photoId: string타입도 nullable로 업데이트 필요null인 사진을 필터링하거나, displayOrder 같은 다른 고유 값을 키로 사용하거나, null 체크 로직을 추가해야 합니다.
🤖 Prompt for AI Agents