-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Refactor : 서버 API 엔드포인트 상수로 관리 * Refactor : UserAvatar 컴포넌트 분리 * Minor : 스타일 변경 * New : 유저정보 페이지 구현
- Loading branch information
1 parent
f22ee31
commit 62bb4c2
Showing
11 changed files
with
185 additions
and
28 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
"use client"; | ||
import CustomAppbar from "@/components/CustomAppbar"; | ||
import { Container, Paper } from "@mui/material"; | ||
import React from "react"; | ||
|
||
type Props = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
const UserInfoPageLayout = ({ children }: Props) => { | ||
|
||
return ( | ||
<Paper> | ||
<CustomAppbar | ||
title={""} | ||
buttonTitle={"설정"} | ||
onClickButton={() => { | ||
console.log("눌림"); | ||
}} | ||
/> | ||
<Container sx={{ p: { xs: 0, sm: 4 } }} maxWidth={"lg"}> | ||
<Paper | ||
sx={{ | ||
display: "flex", | ||
position: "relative", | ||
flexDirection: "column", | ||
gap: 2, | ||
p: 2, | ||
}} | ||
> | ||
{children} | ||
</Paper> | ||
</Container> | ||
</Paper> | ||
); | ||
}; | ||
|
||
export default UserInfoPageLayout; |
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,5 +1,37 @@ | ||
const page = ({ params }: { params: { userId: string } }) => { | ||
return <div>{params.userId}님의 page 입니다</div>; | ||
import UserInfoCard from "@/components/user/info/UserInfoCard"; | ||
import axios from "@/libs/axios"; | ||
import { MyInfoInterface } from "@/types/auth/myInfo"; | ||
|
||
import NoResult from "@/assets/images/noResult.png"; | ||
import { Box } from "@mui/material"; | ||
import Image from "next/image"; | ||
import PostCardList from "@/components/post/PostCardList"; | ||
|
||
const page = async ({ params }: { params: { userId: string } }) => { | ||
try { | ||
const { data } = await axios.get< | ||
MyInfoInterface & { isFollowing: boolean } | ||
>(`/user/${params.userId}/summary`); | ||
return ( | ||
<> | ||
<UserInfoCard data={data} /> | ||
<PostCardList/> | ||
</> | ||
); | ||
} catch { | ||
return ( | ||
<Box | ||
sx={{ | ||
display: "flex", | ||
alignItems: "center", | ||
justifyContent: "center", | ||
py: 8, | ||
}} | ||
> | ||
<Image priority src={NoResult} alt="no result alert" /> | ||
</Box> | ||
); | ||
} | ||
}; | ||
|
||
export default page; |
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,21 @@ | ||
import { Avatar, AvatarProps } from "@mui/material"; | ||
import { ReactNode } from "react"; | ||
|
||
interface UserAvatarProps extends AvatarProps { | ||
fallback: ReactNode; | ||
} | ||
|
||
const UserAvatar = ({ src, fallback,sx,...others }: UserAvatarProps) => { | ||
return ( | ||
<Avatar | ||
sx={{...sx, bgcolor: "secondary.main" }} | ||
src={src} | ||
data-testid="avatar" | ||
{...others} | ||
> | ||
{typeof fallback === "string" ? fallback[0].toUpperCase() : fallback} | ||
</Avatar> | ||
); | ||
}; | ||
|
||
export default UserAvatar; |
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,58 @@ | ||
import { MyInfoInterface } from "@/types/auth/myInfo"; | ||
import React from "react"; | ||
import UserAvatar from "@/components/user/info/UserAvatar"; | ||
import { Box, Button, Typography } from "@mui/material"; | ||
|
||
type Props = { | ||
data: MyInfoInterface & { isFollowing: boolean }; | ||
}; | ||
|
||
const UserInfo = ({ data }: Props) => { | ||
|
||
const { | ||
id, | ||
followerCount, | ||
nickname, | ||
profileImages, | ||
isFollowing, | ||
introduction, | ||
} = data; | ||
|
||
return ( | ||
<Box sx={{display:'flex',alignItems:'center',flexDirection:'column', gap:1}}> | ||
<UserAvatar | ||
src={profileImages[0]?.attachUrl} | ||
fallback={id} | ||
sx={{width:"56px",height:'56px'}} | ||
/> | ||
<Box sx={RowWrapperSX}> | ||
<Typography color="primary.main" fontWeight="bold"> | ||
{nickname} | ||
</Typography> | ||
<Typography color="text.secondary">@{id}</Typography> | ||
</Box> | ||
<Box sx={{height:48}}> | ||
<Typography color="text.secondary"> | ||
{introduction ?? "자기소개가 없습니다"} | ||
</Typography></Box> | ||
<Box sx={RowWrapperSX}> | ||
<Typography fontWeight="bold">{followerCount}</Typography> | ||
<Typography color="text.secondary">팔로워</Typography> | ||
</Box> | ||
{isFollowing ? ( | ||
<Button variant="outlined" fullWidth> | ||
언팔로우 | ||
</Button> | ||
) : ( | ||
<Button fullWidth>팔로우</Button> | ||
)} | ||
</Box> | ||
); | ||
}; | ||
|
||
const RowWrapperSX = { | ||
display: "flex", | ||
gap: 1, | ||
}; | ||
|
||
export default UserInfo; |
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