feat: 백엔드 API 연동 (HTTP 클라이언트 + 홈 화면 실데이터)
- VITE_API_BASE_URL 기반 fetch 클라이언트 및 ApiError 처리 - api/spots, api/matches 타입드 모듈 - HomePage: 스팟/한줄평/메이트 실제 로드, 체크인·매칭 신청 API 연동 - 임시 세션 스토어(인증 도입 전, userId/dogId) - 로딩/에러/빈 상태 처리 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
import { http } from './http'
|
||||
|
||||
export interface Spot {
|
||||
id: number
|
||||
name: string
|
||||
type: string
|
||||
latitude: number | null
|
||||
longitude: number | null
|
||||
}
|
||||
|
||||
export interface Mate {
|
||||
dogId: number
|
||||
name: string
|
||||
breed: string | null
|
||||
}
|
||||
|
||||
export interface Review {
|
||||
id: number
|
||||
tag: string | null
|
||||
content: string | null
|
||||
createdAt: string
|
||||
}
|
||||
|
||||
export interface CheckInResult {
|
||||
id: number
|
||||
spotId: number
|
||||
dogId: number
|
||||
expiresAt: string
|
||||
}
|
||||
|
||||
export const spotsApi = {
|
||||
list: () => http.get<Spot[]>('/api/spots'),
|
||||
mates: (spotId: number) => http.get<Mate[]>(`/api/spots/${spotId}/mates`),
|
||||
reviews: (spotId: number) => http.get<Review[]>(`/api/spots/${spotId}/reviews`),
|
||||
checkIn: (spotId: number, userId: number, dogId: number) =>
|
||||
http.post<CheckInResult>(`/api/spots/${spotId}/checkins`, { userId, dogId }),
|
||||
addReview: (spotId: number, userId: number, tag: string) =>
|
||||
http.post<Review>(`/api/spots/${spotId}/reviews`, { userId, tag }),
|
||||
}
|
||||
Reference in New Issue
Block a user