-
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.
Browse files
Browse the repository at this point in the history
[Feat] 프로필 정보 UI 구현
- Loading branch information
Showing
38 changed files
with
378 additions
and
67 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
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 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 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 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,24 @@ | ||
import { | ||
UserProfileOfMeResponse, | ||
UserProfileOfMeSchema, | ||
UserProfileResponse, | ||
UserProfileSchema, | ||
} from '@repo/types'; | ||
|
||
import request from '@/hooks/api/request'; | ||
|
||
export const getUserProfileOfMe = async () => { | ||
return request<UserProfileOfMeResponse>({ | ||
method: 'GET', | ||
url: '/user/me', | ||
schema: UserProfileOfMeSchema, | ||
}); | ||
}; | ||
|
||
export const getUserProfileByUserId = async (userId: number) => { | ||
return request<UserProfileResponse>({ | ||
method: 'GET', | ||
url: `/user/${userId}`, | ||
schema: UserProfileSchema, | ||
}); | ||
}; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* eslint-disable react-refresh/only-export-components */ | ||
import { Link } from '@tanstack/react-router'; | ||
import axios from 'axios'; | ||
import { Provider } from '@repo/types'; | ||
|
||
import UserProfileOfMeDialog from '@/components/user/UserProfileOfMeDialog'; | ||
import { useUserProfileOfMe } from '@/hooks/api/user'; | ||
import useModal from '@/hooks/useModal'; | ||
|
||
import Avatar from '../Avatar'; | ||
import Button from '../Button'; | ||
|
||
export const LOGIN_TYPE: Record<Provider, string> = { | ||
github: 'Github 로그인', | ||
google: 'Google 로그인', | ||
guest: '게스트 로그인', | ||
local: '티클 로그인', | ||
}; | ||
|
||
function User() { | ||
const { data, error } = useUserProfileOfMe(); | ||
const { isOpen, onOpen, onClose } = useModal(); | ||
|
||
const isUnauthorized = axios.isAxiosError(error) && error.response?.status === 401; | ||
|
||
const loginType = data?.provider && LOGIN_TYPE[data.provider]; | ||
|
||
const AuthorizedContent = () => ( | ||
<> | ||
<section className="flex cursor-pointer items-center gap-2" onClick={onOpen}> | ||
<Avatar size="xs" src={data?.profileImageUrl} /> | ||
<span className="text-body1 text-alt">{data?.nickname}</span> | ||
</section> | ||
{isOpen && data && loginType && ( | ||
<UserProfileOfMeDialog | ||
onClose={onClose} | ||
isOpen={isOpen} | ||
profileImageUrl={data.profileImageUrl} | ||
nickname={data.nickname} | ||
loginType={loginType} | ||
/> | ||
)} | ||
</> | ||
); | ||
|
||
const UnauthorizedContent = () => ( | ||
<Link to="/auth/oauth"> | ||
<section className="flex items-center justify-center"> | ||
<Button size="sm">로그인</Button> | ||
</section> | ||
</Link> | ||
); | ||
|
||
return ( | ||
<aside className="flex gap-3"> | ||
{isUnauthorized ? <UnauthorizedContent /> : <AuthorizedContent />} | ||
</aside> | ||
); | ||
} | ||
|
||
export default User; |
Oops, something went wrong.