diff --git a/src/components/common/ProfileBox.tsx b/src/components/common/ProfileBox.tsx index c4949af..796a337 100644 --- a/src/components/common/ProfileBox.tsx +++ b/src/components/common/ProfileBox.tsx @@ -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 = ({ - name, - profile_image_url, - grade, - class_num, -}) => { +const ProfileBox: React.FC = ({ userId }) => { + const { data } = useSWR( + `/teachers/users/${userId}?startAt=${dayjs() + .subtract(6, "day") + .format("YYYY-MM-DD")}&endAt=${dayjs().format("YYYY-MM-DD")}` + ); + return ( - + -

{name}

+

{data?.name}

-

{grade}학년

-

3반

-

{class_num}번

+ {data?.grade && data?.class_num && ( + <> +

{data?.grade}학년

+

{data?.class_num}반

+ + )} +

{data?.number ? `${data?.number}번` : "선생님"}

@@ -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;