Skip to content

Commit

Permalink
[Fix] 스터디 목록 조회를 멘토용 조회 API로 수정해요. (#136)
Browse files Browse the repository at this point in the history
* fix: 스터디 목록 조회 멘토용으로 수정

* fix: 사용하지 않는 DTO 제거

* chore: unuse 변수 제거

* fix: 코드리뷰 반영
  • Loading branch information
eugene028 authored Sep 5, 2024
1 parent 0623093 commit 3044b58
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 30 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
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 3044b58

Please sign in to comment.