-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from KDT-Web-IDE-Project/79-feat
feat: 마이페이지 api 연결
- Loading branch information
Showing
7 changed files
with
202 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,19 @@ | ||
// src/queryClient.ts | ||
import { QueryClient } from '@tanstack/react-query'; | ||
|
||
export const queryClient = new QueryClient({ | ||
defaultOptions: { | ||
queries: { | ||
retry: 1, // 실패 시 재시도 횟수 | ||
refetchOnWindowFocus: false, // 창이 포커스될 때 데이터 리패치 방지 | ||
staleTime: 5 * 60 * 1000, // 데이터가 신선한 상태로 유지되는 시간 (5분) | ||
retry: 3, // 실패 시 최대 3번 재시도 (네트워크 불안정성 보완) | ||
refetchOnWindowFocus: true, // 창 포커스 시 리패치 활성화 (실시간성 강화) | ||
refetchOnReconnect: true, // 네트워크 재연결 시 데이터 리패치 | ||
staleTime: 0, // 데이터는 항상 신선하지 않다고 간주 (실시간 데이터 반영) | ||
gcTime: 5 * 60 * 1000, // 캐시는 5분 동안 유지 (짧은 시간 안에 동일 데이터를 캐시 활용) | ||
}, | ||
mutations: { | ||
retry: 1, // 실패 시 재시도 횟수 | ||
retry: 1, // Mutation은 1번만 재시도 (중복 작업 방지) | ||
onError: (error) => { | ||
console.error('Mutation 에러:', error); | ||
}, | ||
}, | ||
}, | ||
}); |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { http } from '../../apis/httpClient'; | ||
|
||
export const useUpdateProfile = () => ({ | ||
patchUserProfileImage: async (image: File) => { | ||
const formData = new FormData(); | ||
formData.append('image', image); | ||
|
||
const data = await http.patch(`/api/auth/profile/profile-image`, formData, { | ||
headers: { | ||
'Content-Type': 'multipart/form-data', // 헤더에 multipart/form-data 설정 | ||
}, | ||
}); | ||
|
||
return data; | ||
}, | ||
|
||
patchUserNickName: async (nickName: string) => { | ||
const data = await http.patch(`/api/auth/profile/nickname`, null, { | ||
params: { nickName }, | ||
}); | ||
return data; | ||
}, | ||
|
||
patchUserLoginId: async (loginId: string) => { | ||
const data = await http.patch('/api/auth/profile/login-id', null, { | ||
params: { loginId }, | ||
}); | ||
return data; | ||
}, | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { UserProfileResponse } from '../../models/Auth'; | ||
import { http } from '../../apis/httpClient'; | ||
|
||
export const useUserProfile = () => { | ||
return useQuery<UserProfileResponse>({ | ||
queryKey: ['userInfo'], | ||
queryFn: async () => { | ||
const data = await http.get<UserProfileResponse>(`/api/auth/profile`); | ||
return data; | ||
}, | ||
staleTime: 1000, | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters