Skip to content

Commit

Permalink
feat: merge dev
Browse files Browse the repository at this point in the history
  • Loading branch information
SeieunYoo committed Sep 7, 2024
2 parents 6f3672d + 0e8bbb3 commit 1c76cb9
Show file tree
Hide file tree
Showing 8 changed files with 26 additions and 46 deletions.
13 changes: 1 addition & 12 deletions apps/admin/apis/auth/dashboardApi.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import { fetcher } from "@wow-class/utils";
import { apiPath, mentorApiPath } from "constants/apiPath";
import { apiPath } from "constants/apiPath";
import { tags } from "constants/tags";
import type { DashboardApiResponseDto } from "types/dtos/auth";
import type { MyStudyListApiResponseDto } from "types/dtos/studyList";

export const dashboardApi = {
getDashboardInfo: async () => {
Expand All @@ -19,14 +18,4 @@ export const dashboardApi = {

return { studyRole, manageRole };
},
getMyStudyList: async () => {
const response = await fetcher.get<MyStudyListApiResponseDto[]>(
mentorApiPath.studyList,
{
next: { tags: [tags.dashboard] },
cache: "force-cache",
}
);
return response.data;
},
};
10 changes: 10 additions & 0 deletions apps/admin/apis/study/studyApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,16 @@ export const studyApi = {

return response.data;
},
getMyStudyList: async () => {
const response = await fetcher.get<StudyListApiResponseDto[]>(
mentorApiPath.studyList,
{
next: { tags: [tags.myStudyList] },
cache: "force-cache",
}
);
return response.data;
},
getStudyBasicInfo: async (studyId: number) => {
const response = await fetcher.get<StudyBasicInfoApiResponseDto>(
`/common/studies/${studyId}`,
Expand Down
6 changes: 5 additions & 1 deletion apps/admin/app/studies/_components/StudyList.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
import { css } from "@styled-system/css";
import { studyApi } from "apis/study/studyApi";
import isAdmin from "utils/isAdmin";

import EmptyStudyList from "./EmptyStudyList";
import StudyListItem from "./StudyListItem";

const StudyList = async () => {
const studyList = await studyApi.getStudyList();
const adminStatus = await isAdmin();
const studyList = adminStatus
? await studyApi.getStudyList()
: await studyApi.getMyStudyList();

if (studyList?.length === 0) {
return <EmptyStudyList />;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ const CreatedStudyCheckModal = () => {

if (result.success) {
await revalidateTagByName(tags.studyList);
await revalidateTagByName(tags.myStudyList);
window.alert("스터디 생성에 성공했어요.");
router.push(`${routerPath.root.href}`);
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,21 +61,6 @@ const StudyStartDatePick = () => {
}
}, [handleStudyDateSelect, studyDate.fromValue, studyDate.toValue, week]);

const disableDateList = [
{
from: new Date(0),
to: yesterday,
},
...(watch("applicationEndDate")
? [
{
from: new Date(0),
to: studyApplyEndDate,
},
]
: []),
];

return (
<Flex direction="column" position="relative" width={358}>
<Text color="sub" style={{ marginBottom: "8px" }} typo="label2">
Expand Down Expand Up @@ -115,9 +100,12 @@ const StudyStartDatePick = () => {
{isOpen && (
<div ref={datepickerRef}>
<DayPicker
disabled={disableDateList}
mode="range"
weekStartsOn={1}
disabled={{
from: new Date(0),
to: yesterday,
}}
selected={{
from: formatStringToDate(studyDate.fromValue),
to: formatStringToDate(studyDate.toValue),
Expand Down
6 changes: 3 additions & 3 deletions apps/admin/components/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { css } from "@styled-system/css";
import { NavItem } from "@wow-class/ui";
import { dashboardApi } from "apis/auth/dashboardApi";
import { studyApi } from "apis/study/studyApi";
import { clientUrl } from "constants/url";
import Image from "next/image";
Expand All @@ -18,9 +17,10 @@ import participantImageUrl from "../public/images/particpant.svg";
*/

const Navbar = async () => {
const studyList = (await isAdmin())
const adminStatus = await isAdmin();
const studyList = adminStatus
? await studyApi.getStudyList()
: await dashboardApi.getMyStudyList();
: await studyApi.getMyStudyList();

const navMenu = [
{
Expand Down
1 change: 1 addition & 0 deletions apps/admin/constants/tags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ export const enum tags {
assignments = "assignments",
curriculums = "curriculums",
studyList = "studyList",
myStudyList = "myStudyList",
studyBasicInfo = "studyBasicInfo",
announcements = "announcements",
memberList = "memberList",
Expand Down
15 changes: 1 addition & 14 deletions apps/admin/types/dtos/studyList.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import type { DayOfWeekType } from "types/entities/dayofweek";
import type {
StudyKoreanType,
StudySemesterType,
StudyType,
} from "types/entities/study";
import type { StudyKoreanType, StudySemesterType } from "types/entities/study";
import type { TimeType } from "types/entities/time";

export interface StudyListApiResponseDto {
Expand All @@ -20,12 +16,3 @@ export interface StudyListApiResponseDto {
totalWeek: number;
openingDate: string;
}

export interface MyStudyListApiResponseDto {
studyId: number;
semester: string;
title: string;
studyType: StudyType;
notionLink: string;
mentorName: string;
}

0 comments on commit 1c76cb9

Please sign in to comment.