diff --git a/src/api/service/user-service/index.ts b/src/api/service/user-service/index.ts index be48952e..eedfb72e 100644 --- a/src/api/service/user-service/index.ts +++ b/src/api/service/user-service/index.ts @@ -1,21 +1,29 @@ import { api } from '@/api/core'; import { + Availability, FollowParams, + GetEmailAvailabilityParams, + GetNickNameAvailabilityParams, GetUserParams, UpdateMePayload, - UpdateMyImagePayload, UpdateMyNotiParams, + UpdateMyProfileImagePayload, User, } from '@/types/service/user'; export const userServiceRemote = () => ({ - // 2. 프로필 편집 + // 1. 사용자 팔로우 + followUser: async (payload: FollowParams) => { + return api.post(`/follows/${payload.followNickname}`); + }, + + // 2. 유저 프로필 변경 updateMe: async (payload: UpdateMePayload) => { return api.patch('/users', payload); }, - // 3. 프로필 이미지 편집 - updateMyImage: async (payload: UpdateMyImagePayload) => { + // 3. 프로필 이미지 변경 + updateMyProfileImage: async (payload: UpdateMyProfileImagePayload) => { return api.patch(`/users/profile-image`, payload); }, @@ -24,23 +32,23 @@ export const userServiceRemote = () => ({ return api.patch(`/users/notification/${payload.isNotificationEnabled}`); }, - // 5. 사용자 단건 조회 + // 5. 유저 프로필 조회 getUser: async (payload: GetUserParams) => { return api.get(`/users/${payload.userId}`); }, - // 1. 사용자 팔로우 - followUser: async (payload: FollowParams) => { - return api.post(`/follows/${payload.followNickname}`); + // 6. 닉네임 중복 검사 + getNicknameAvailability: async (params: GetNickNameAvailabilityParams) => { + return api.get(`/users/nickname/availability?nickname=${params.nickName}`); + }, + + // 7. 이메일 중복 검사 + getEmailAvailability: async (params: GetEmailAvailabilityParams) => { + return api.get(`/users/email/availability?email=${params.email}`); }, - // 6. 사용자 언팔로우 + // 8. 사용자 언팔로우 unfollowUser: async (payload: FollowParams) => { return api.delete(`/follows/${payload.followNickname}`); }, - - // 7. 회원탈퇴 - deleteMe: async () => api.delete(`/users`), - - // 8. 사용자 프로필 이미지 변경 }); diff --git a/src/hooks/use-user/index.ts b/src/hooks/use-user/index.ts index 1c1909b3..6004fdb1 100644 --- a/src/hooks/use-user/index.ts +++ b/src/hooks/use-user/index.ts @@ -1,4 +1,3 @@ -export { useDeleteUser } from './use-user-delete'; export { useFollowUser } from './use-user-follow'; export { useGetUser } from './use-user-get'; export { useUnfollowUser } from './use-user-unfollow'; diff --git a/src/hooks/use-user/use-user-delete/index.ts b/src/hooks/use-user/use-user-delete/index.ts deleted file mode 100644 index bef8abf8..00000000 --- a/src/hooks/use-user/use-user-delete/index.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { useMutation, useQueryClient } from '@tanstack/react-query'; - -import { API } from '@/api'; -import { userKeys } from '@/lib/query-key/query-key-user'; - -export const useDeleteUser = () => { - const queryClient = useQueryClient(); - const query = useMutation({ - mutationFn: () => API.userService.deleteMe(), - onSuccess: (data, _variables, _context) => { - queryClient.invalidateQueries({ queryKey: userKeys.item(data.userId) }); - console.log('요청 성공'); - }, - onError: () => { - console.log('요청 실패'); - }, - }); - return query; -}; diff --git a/src/types/service/user.ts b/src/types/service/user.ts index 8b73a9b4..a7bdcf2d 100644 --- a/src/types/service/user.ts +++ b/src/types/service/user.ts @@ -24,7 +24,7 @@ export interface UpdateMePayload { profileMessage?: string; } -export interface UpdateMyImagePayload { +export interface UpdateMyProfileImagePayload { file: File; } @@ -35,3 +35,15 @@ export interface UpdateMyNotiParams { export interface FollowParams { followNickname: string; } + +export interface Availability { + available: boolean; +} + +export interface GetNickNameAvailabilityParams { + nickName: string; +} + +export interface GetEmailAvailabilityParams { + email: string; +}