-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[#107] Feat: 유저페이지 구현 #132
Closed
Closed
Changes from all commits
Commits
Show all changes
24 commits
Select commit
Hold shift + click to select a range
d5c5ca4
fix: 프로필페이지 구조 변경
HoberMin 981c89d
feat: 마이페이지 구현
HoberMin d50632b
refactor: GNB를 레이아웃에서 페이지로 이동
HoberMin 058d47a
fix: 레거시 코드 삭제
HoberMin 7496c29
feat: user페이지의 공통 컴포넌트로 변경
HoberMin fd2df94
chore: 타입선언 및 모듈 수정
HoberMin eba5062
feat: 접근자 권한에 따른 강제 라우팅처리
HoberMin a53fff9
feat: 타 사용자 유저페이지 UI 구현
HoberMin 698abf3
feat: 마이페이지 라우팅 코드 추가
HoberMin d31f219
feat: 팔로우 api 추가
HoberMin 5130e71
feat: pathname에 따른 화면 조회 변경
HoberMin c79570e
fix: build 오류 수정
HoberMin e8297d6
feat: 프로필 페이지 로그인 로직 추가
HoberMin 9cfbb7f
refactor: 프로필 조회 API 타입 수정
HoberMin 5a2367e
refactor: 빈 화면 컴포넌트에 대한 수정
HoberMin ddf209e
fix: 레거시 코드 삭제
HoberMin 42a8f17
refactor: 닉네임 없는 게시글 아이템으로 리팩토링
HoberMin d2c7ca5
feat: 유저 팔로우 로직 추가
HoberMin d756f22
style: CSS 변경
HoberMin df099a0
feat: 게시글 목록 리스트 구현 - 프로필 페이지별 사용 목적
HoberMin 31eb374
fix: GNB 컴포넌트 하이라이팅 변경
HoberMin 24533c7
style: GNB컴포너트 스타일링 변경
HoberMin b961728
feat: 로그아웃 API 연결 추가
HoberMin 9e216ef
refactor: 코드리뷰 반영
HoberMin File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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,42 @@ | ||
import { useMutation, useQueryClient } from '@tanstack/react-query'; | ||
|
||
import { api } from './core'; | ||
|
||
const postFollow = (userId: string) => { | ||
return api.post({ | ||
url: `/follow/${userId}`, | ||
}); | ||
}; | ||
|
||
const deleteFollow = (userId: string) => { | ||
return api.delete({ | ||
url: `/unfollow/${userId}`, | ||
}); | ||
}; | ||
|
||
export const usePostFollowAPI = (userId: string) => { | ||
const QueryClient = useQueryClient(); | ||
const { mutateAsync } = useMutation({ | ||
mutationFn: () => postFollow(userId), | ||
onSuccess: () => | ||
QueryClient.invalidateQueries({ | ||
queryKey: ['profile', userId], | ||
}), | ||
}); | ||
|
||
return mutateAsync; | ||
}; | ||
|
||
export const useDeleteFollowAPI = (userId: string) => { | ||
const QueryClient = useQueryClient(); | ||
|
||
const { mutateAsync } = useMutation({ | ||
mutationFn: () => deleteFollow(userId), | ||
onSuccess: () => | ||
QueryClient.invalidateQueries({ | ||
queryKey: ['profile', userId], | ||
}), | ||
}); | ||
|
||
return mutateAsync; | ||
}; |
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,17 @@ | ||
import { useMutation } from '@tanstack/react-query'; | ||
|
||
import { api } from './core'; | ||
|
||
const logout = () => { | ||
return api.post({ | ||
url: `/user/logout`, | ||
}); | ||
}; | ||
|
||
export const useLogoutAPI = () => { | ||
const { mutateAsync } = useMutation({ | ||
mutationFn: () => logout(), | ||
}); | ||
|
||
return mutateAsync; | ||
}; |
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 |
---|---|---|
@@ -0,0 +1,73 @@ | ||
import { useSuspenseQuery } from '@tanstack/react-query'; | ||
|
||
import { PostingNavigation } from '@/src/app/users/profile/(posting)/layout'; | ||
|
||
import { api } from '../core'; | ||
|
||
export interface PostListContent { | ||
postId: number; | ||
voteId: number; | ||
title: string; | ||
commentCount: number; | ||
likeCount: number; | ||
voterCount: number; | ||
author: string; | ||
profileImageUrl: string | null; | ||
postImageUrl: string | null; | ||
createdAt: string; | ||
} | ||
|
||
interface PostListPageable { | ||
pageNumber: number; | ||
pageSize: number; | ||
sort: PostListSort; | ||
offset: number; | ||
paged: boolean; | ||
unpaged: boolean; | ||
} | ||
|
||
interface PostListSort { | ||
empty: boolean; | ||
unsorted: boolean; | ||
sorted: boolean; | ||
} | ||
|
||
export interface PostList { | ||
content: PostListContent[]; | ||
pageable: PostListPageable; | ||
last: boolean; | ||
totalPages: number; | ||
totalElements: number; | ||
first: boolean; | ||
size: number; | ||
number: number; | ||
sort: PostListSort; | ||
numberOfElements: number; | ||
empty: boolean; | ||
} | ||
|
||
export interface PostListInitialParams { | ||
page: number; | ||
size: number; | ||
} | ||
|
||
export const getPosting = async ( | ||
params: PostListInitialParams, | ||
category: PostingNavigation, | ||
) => | ||
await api.get<PostList>({ | ||
url: `/posts/${category}`, | ||
params, | ||
}); | ||
|
||
export const useGetPostingAPI = ( | ||
params: PostListInitialParams, | ||
category: PostingNavigation, | ||
) => { | ||
const { data } = useSuspenseQuery({ | ||
queryKey: ['postList', category, ...Object.values(params)], | ||
queryFn: () => getPosting(params, category), | ||
}); | ||
|
||
return data.body; | ||
}; |
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
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
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Body보다 더 구체적인 변수명이면 좋을 거 같은데 어떠신가요?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
네네 그렇게 할게요 ! 병합하는과정에서 꼬인게 있나봅니다..