Skip to content

Commit

Permalink
fix: 코드리뷰 반영
Browse files Browse the repository at this point in the history
  • Loading branch information
eugene028 committed Aug 25, 2024
1 parent 46f2a7e commit 26c487a
Show file tree
Hide file tree
Showing 17 changed files with 347 additions and 351 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Space, Text } from "@wow-class/ui";
import { studyInfoApi } from "apis/study/studyInfoApi";

import AssignmentItem from "./AssignmentItem";
import AssignmentListItem from "./AssignmentListItem";

const AssignmentList = async ({ studyId }: { studyId: string }) => {
const assignmentList = await studyInfoApi.getAssignmentList(
Expand All @@ -14,7 +14,7 @@ const AssignmentList = async ({ studyId }: { studyId: string }) => {
<Space height={24} />
{assignmentList?.map((assignment, index) => {
return (
<AssignmentItem
<AssignmentListItem
assignment={assignment}
key={`studyDetailId-${index}`}
/>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
"use client";
import { cva } from "@styled-system/css";
import { Flex } from "@styled-system/jsx";
import { Table, Text } from "@wow-class/ui";
import { padWithZero, parseISODate } from "@wow-class/utils";
import { studyInfoApi } from "apis/study/studyInfoApi";
import { tags } from "constants/tags";
import Link from "next/link";
import type { AssignmentApiResponseDto } from "types/dtos/assignmentList";
import getIsCurrentWeek from "utils/getIsCurrentWeek";
import { revalidateTagByName } from "utils/revalidateTagByName";
import Button from "wowds-ui/Button";

const AssignmentListItem = ({
assignment,
}: {
assignment: AssignmentApiResponseDto;
}) => {
const {
studyDetailId,
title,
deadline,
week,
descriptionLink,
assignmentStatus,
} = assignment;
const thisWeekAssignment = getIsCurrentWeek(deadline);
const { year, month, day, hours, minutes } = parseISODate(deadline);

const studyDeadline = `종료 : ${year}${month}${day}${padWithZero(hours)}:${padWithZero(minutes)}`;

const handleCancelAssignment = async (studyDetailId: number) => {
const { success } = await studyInfoApi.cancelAssignment(studyDetailId);
if (success) {
window.alert("휴강 처리에 성공했어요.");
revalidateTagByName(tags.assignments);
} else {
window.alert("휴강 처리에 실패했어요.");
}
};
return (
<Table>
<Table.Left style={TableLeftStyle}>
<Flex alignItems="center" gap="xxs">
<div
className={ThisWeekBarStyle({
type: thisWeekAssignment ? "thisWeek" : "notThisWeek",
})}
/>
<Text typo="body1">{week}주차</Text>
</Flex>
<Flex direction="column" gap="xxs">
<Text typo="h3">{title || "-"}</Text>
<Text color="sub" typo="body2">
{deadline ? studyDeadline : "-"}
</Text>
</Flex>
</Table.Left>
<Table.Right>
<>
{assignmentStatus === "OPEN" ? (
<Button
asProp={Link}
href={descriptionLink || ""}
size="sm"
variant="outline"
>
과제 내용보기
</Button>
) : (
<Flex gap="sm">
<Button
color="sub"
size="sm"
variant="sub"
onClick={() => handleCancelAssignment(studyDetailId)}
>
과제 휴강처리
</Button>
<Button
size="sm"
variant="solid"
onClick={() => {
console.log("TODO: 과제 개설 페이지 연결");
}}
>
과제 개설하기
</Button>
</Flex>
)}
</>
</Table.Right>
</Table>
);
};
export default AssignmentListItem;

const ThisWeekBarStyle = cva({
base: {
width: "4px",
height: "18px",
},
variants: {
type: {
thisWeek: {
backgroundColor: "primary",
},
notThisWeek: {
backgroundColor: "transparent",
},
},
},
});

const TableLeftStyle = {
display: "flex",
alignItems: "center",
gap: "47px",
};
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const CheckAttendanceNumber = () => {
<Space height={24} />
<div className={AttendanceContainerStyle}>
<Box
style={{ maxWidth: "282px" }}
style={AttendanceBoxStyle}
text={
<Flex direction="column" gap="lg">
<Flex direction="column" gap="xs">
Expand All @@ -25,17 +25,14 @@ const CheckAttendanceNumber = () => {
2024년 5월 23일 00:00 - 23:59까지
</Text>
</Flex>
<Text
color="primary"
style={{ fontSize: "40px", fontWeight: 700 }}
>
<Text color="primary" style={AttendanceNumberStyle}>
2143
</Text>
</Flex>
}
/>
<Box
style={{ maxWidth: "282px" }}
style={AttendanceBoxStyle}
text={
<Flex direction="column" gap="lg">
<Flex direction="column" gap="xs">
Expand All @@ -49,10 +46,7 @@ const CheckAttendanceNumber = () => {
2024년 5월 23일 00:00 - 23:59까지
</Text>
</Flex>
<Text
color="outline"
style={{ fontSize: "40px", fontWeight: 700 }}
>
<Text color="outline" style={AttendanceNumberStyle}>
4176
</Text>
</Flex>
Expand All @@ -72,6 +66,11 @@ const AttendanceContainerStyle = css({
gap: "md",
});

const SectionStyle = css({
padding: "24px 0px",
});
const AttendanceBoxStyle = {
maxWidth: "282px",
};

const AttendanceNumberStyle = {
fontSize: "40px",
fontWeight: 700,
};
165 changes: 165 additions & 0 deletions apps/admin/app/studies/[studyId]/_components/header/Header.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,165 @@
"use client";

import { css } from "@styled-system/css";
import { Flex } from "@styled-system/jsx";
import { Space, Text } from "@wow-class/ui";
import { padWithZero, parseISODate } from "@wow-class/utils";
import { studyInfoApi } from "apis/study/studyInfoApi";
import { dayToKorean } from "constants/dayToKorean";
import Image from "next/image";
import Link from "next/link";
import { useEffect, useState } from "react";
import type { StudyBasicInfoApiResponseDto } from "types/dtos/studyBasicInfo";
import { DownArrow } from "wowds-icons";
import TextButton from "wowds-ui/TextButton";

const Header = ({ studyId }: { studyId: string }) => {
const [showIntro, setShowIntro] = useState(false);
const [studyInfo, setStudyInfo] = useState<
StudyBasicInfoApiResponseDto | undefined
>(undefined);

useEffect(() => {
const fetchData = async () => {
if (studyId) {
const data = await studyInfoApi.getStudyBasicInfo(
parseInt(studyId, 10)
);
if (data) setStudyInfo(data);
}
};

fetchData();
}, [studyId]);

const handleClickShowIntro = () => {
setShowIntro((prev) => !prev);
};

const introSectionButtonAriaLabel = showIntro
? "Collapse introduction"
: "Expand introduction";
const introSectionIconAriaLabel = showIntro
? "Collapse introduction icon"
: "Expand introduction icon";

if (!studyInfo) return null;

const {
title,
academicYear,
semester,
mentorName,
studyType,
dayOfWeek,
startTime: { hour: startHour, minute: startMinute },
endTime: { hour: endHour, minute: endMinute },
totalWeek,
period: { startDate, endDate },
introduction,
notionLink,
} = studyInfo;

const { month: startMonth, day: startDay } = parseISODate(startDate);
const { month: endMonth, day: endDay } = parseISODate(endDate);
const studySemester = `${academicYear}-${semester === "FIRST" ? 1 : 2}`;
const studySchedule = `${dayToKorean[dayOfWeek]} ${startHour}:${padWithZero(startMinute)}-
${endHour}:${padWithZero(endMinute)}`;
const studyPeriod = `${padWithZero(startMonth)}.${padWithZero(startDay)}-
${padWithZero(endMonth)}.${padWithZero(endDay)}`;

return (
<header>
<section aria-label="my-study-header">
<Flex alignItems="center" gap={8}>
<Text as="h1" typo="h1">
{title}
</Text>
<button
aria-controls="intro-section"
aria-expanded={showIntro}
aria-label={introSectionButtonAriaLabel}
tabIndex={0}
onClick={handleClickShowIntro}
>
<DownArrow
aria-label={introSectionIconAriaLabel}
className={downArrowIconStyle}
height={20}
stroke="textBlack"
style={{ rotate: showIntro ? "0deg" : "180deg" }}
width={20}
/>
</button>
</Flex>
</section>
<section>
<Space height={8} />
<Flex gap="xs">
<Text as="h5" color="sub">
{studySemester}
</Text>
<ItemSeparator />
<Text as="h5" color="sub">
{mentorName} 멘토
</Text>
<ItemSeparator />
<Text as="h5" color="sub">
{studyType}
</Text>
</Flex>
</section>
{showIntro && (
<section id="intro-section">
<section aria-labelledby="study-schedule-heading">
<Space height={24} />
<Flex direction="column" gap="4">
<Text as="h3" typo="h3">
스터디 일정
</Text>
<Flex gap="xs">
<Text as="h5" color="sub">
{studySchedule}
</Text>
<ItemSeparator />
<Text as="h5" color="sub">
{totalWeek}주 코스
</Text>
<ItemSeparator />
<Text as="h5" color="sub">
{studyPeriod}
</Text>
</Flex>
</Flex>
</section>
<section aria-labelledby="study-intro-heading">
<Space height={28} />
<Flex direction="column" gap="xs">
<Text as="h3" typo="h3">
스터디 소개
</Text>
<Flex alignItems="center" gap="sm">
<Link href={notionLink || ""} role="button" tabIndex={0}>
<TextButton style={{ padding: "0px" }} text="스터디 소개" />
</Link>
<Text color="sub" typo="body1">
{introduction}
</Text>
</Flex>
</Flex>
</section>
</section>
)}
</header>
);
};

export default Header;

const ItemSeparator = () => (
<Image alt="item separator" height={4} src="/images/dot.svg" width={4} />
);

const downArrowIconStyle = css({
cursor: "pointer",
});
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Space, Text } from "@wow-class/ui";
import { studyInfoApi } from "apis/study/studyInfoApi";

import EmptySessionList from "./EmptySessionList";
import SessionItem from "./SessionItem";
import SessionListItem from "./SessionListItem";

const SessionList = async ({ studyId }: { studyId: string }) => {
const sessionList = await studyInfoApi.getSessionList(parseInt(studyId, 10));
Expand All @@ -16,7 +16,7 @@ const SessionList = async ({ studyId }: { studyId: string }) => {
<Text typo="h2">스터디 커리큘럼</Text>
<Space height={24} />
{sessionList?.map((session, index) => (
<SessionItem key={`sessionItem-${index}`} session={session} />
<SessionListItem key={`sessionItem-${index}`} session={session} />
))}
</section>
);
Expand Down
Loading

0 comments on commit 26c487a

Please sign in to comment.