Skip to content

Commit

Permalink
⚡️ :: (#118) 프로필 박스 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
kimulchan committed May 31, 2022
1 parent 4d2de06 commit 458c60d
Showing 1 changed file with 29 additions and 18 deletions.
47 changes: 29 additions & 18 deletions src/components/common/ProfileBox.tsx
Original file line number Diff line number Diff line change
@@ -1,27 +1,39 @@
import styled from "@emotion/styled";

import useSWR from "swr";
import dayjs from "dayjs";
import Image from "next/image";
interface Props {
name: string;
profile_image_url?: string;
grade: number;
class_num: number;
userId: number;
}

const ProfileBox: React.FC<Props> = ({
name,
profile_image_url,
grade,
class_num,
}) => {
const ProfileBox: React.FC<Props> = ({ userId }) => {
const { data } = useSWR(
`/teachers/users/${userId}?startAt=${dayjs()
.subtract(6, "day")
.format("YYYY-MM-DD")}&endAt=${dayjs().format("YYYY-MM-DD")}`
);

return (
<UserSchoolInfo>
<img src={profile_image_url}></img>
<img
src={
data?.profile_image_url ||
"https://blog.kakaocdn.net/dn/bftRiB/btqAjaghSBk/5CcN9W5qyCU8HLylVYcXb1/img.png"
}
width={90}
height={90}
alt=''
/>
<Box>
<h2>{name}</h2>
<h2>{data?.name}</h2>
<div>
<p>{grade}학년</p>
<p>3반</p>
<p>{class_num}</p>
{data?.grade && data?.class_num && (
<>
<p>{data?.grade}학년</p>
<p>{data?.class_num}</p>
</>
)}
<p>{data?.number ? `${data?.number}번` : "선생님"}</p>
</div>
</Box>
</UserSchoolInfo>
Expand All @@ -32,8 +44,7 @@ const UserSchoolInfo = styled.div`
display: flex;
gap: 28px;
align-items: center;
> img {
background-color: ${({ theme }) => theme.color.main};
& img {
border-radius: 50%;
width: 90px;
height: 90px;
Expand Down

0 comments on commit 458c60d

Please sign in to comment.