File tree Expand file tree Collapse file tree 3 files changed +35
-4
lines changed
services/ahhachul.com/src Expand file tree Collapse file tree 3 files changed +35
-4
lines changed Original file line number Diff line number Diff line change 11import axios from 'axios' ;
22
33import axiosInstance from '@/apis/fetcher' ;
4- import type { ApiResponse , UserProfileResponseDto } from '@/types' ;
4+ import type { ApiResponse , UserFavoriteStations , UserProfileResponseDto } from '@/types' ;
55import { getAccessTokenInLocalStorage } from '@/utils/localStorage' ;
66
77import { BASE_URL } from '../baseUrl' ;
@@ -29,11 +29,21 @@ export const prefetchUserProfile = async () => {
2929} ;
3030
3131export const fetchUserFavoriteStations = async ( ) => {
32- const { data } = await axiosInstance . get < ApiResponse < { id : 'hello' } > > (
32+ const { data } = await axiosInstance . get < ApiResponse < UserFavoriteStations > > (
3333 '/members/bookmarks/stations' ,
3434 ) ;
3535
3636 return data ;
3737} ;
3838
39- // export const createUserFavoriteStations = () => {}
39+ export const createUserFavoriteStations = ( stations : {
40+ stations : {
41+ stationName : string ;
42+ label : string ;
43+ } [ ] ;
44+ } ) => {
45+ return axiosInstance . post < ApiResponse < UserFavoriteStations > > (
46+ '/members/bookmarks/stations' ,
47+ stations ,
48+ ) ;
49+ } ;
Original file line number Diff line number Diff line change 1- import { useQuery } from '@tanstack/react-query' ;
1+ import { useMutation , useQuery } from '@tanstack/react-query' ;
22
33import * as api from '@/apis/request' ;
44import { useAuth } from '@/contexts' ;
@@ -31,5 +31,12 @@ export const useFetchUserFavoriteStations = () => {
3131 queryKey : userKeys . stations ( ) ,
3232 enabled : authService . isAuthenticated ,
3333 queryFn : api . fetchUserFavoriteStations ,
34+ select : res => res . result . stationInfoList ,
35+ } ) ;
36+ } ;
37+
38+ export const useCreateUserFavoriteStations = ( ) => {
39+ return useMutation ( {
40+ mutationFn : api . createUserFavoriteStations ,
3441 } ) ;
3542} ;
Original file line number Diff line number Diff line change @@ -20,3 +20,17 @@ export interface UserProfileResponseDto {
2020 gender ?: Gender ;
2121 ageRange ?: AgeRange ;
2222}
23+
24+ export interface UserStation {
25+ stationId : number ;
26+ stationName : string ;
27+ label : string ;
28+ subwayLineInfoList : {
29+ subwayLineId : number ;
30+ subwayLineName : string ;
31+ } [ ] ;
32+ }
33+
34+ export interface UserFavoriteStations {
35+ stationInfoList : UserStation [ ] ;
36+ }
You can’t perform that action at this time.
0 commit comments