40 lines
957 B
TypeScript
40 lines
957 B
TypeScript
|
|
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 }),
|
||
|
|
}
|