Skip to content

Commit

Permalink
feat: assignment 제출 api 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
SeieunYoo committed Aug 21, 2024
1 parent ac7df1b commit 84260e8
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 2 deletions.
14 changes: 14 additions & 0 deletions apps/client/apis/studyHistoryApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,4 +25,18 @@ export const studyHistoryApi = {

return { success: response.ok };
},

submitAssignment: async (studyDetailId: number) => {
const response = await fetcher.post(
`${apiPath.studyHistory}/submit?studyDetailId=${studyDetailId}`,
null,
{
headers: {
Authorization: `Bearer ${process.env.NEXT_PUBLIC_DEV_AUTH_TOKEN}`,
},
}
);

return { success: response.ok };
},
};
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
"use client";

import { Space } from "@wow-class/ui";
import { studyHistoryApi } from "apis/studyHistoryApi";
import { tags } from "constants/tags";
import { revalidateTag } from "next/cache";
import Link from "next/dist/client/link";
Expand All @@ -24,10 +25,16 @@ export const AssignmentButtons = ({
submissionLink,
deadline,
committedAt,
studyDetailId,
} = assignment;

const handleClickSubmissionComplete = () => {
revalidateTag(tags.studyDetailDashboard);
const handleClickSubmissionComplete = async () => {
const response = await studyHistoryApi.submitAssignment(studyDetailId);
if (response.success) {
//TODO: 과제 제출 이후에는 과제 상태에 대한 업데이트 필요
//이번주 과제 조회 api, 대시보드 api revaliate
//revalidateTag()
}
};

const getButtonProps = () => {
Expand Down
12 changes: 12 additions & 0 deletions apps/client/constants/assignmentMockData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,16 @@ export const assignmentData: Assignment[] = [
submissionFailureType: "NOT_SUBMITTED",
committedAt: "2024-08-20T14:30:00",
},
{
studyDetailId: 124,
assignmentStatus: "OPEN",
week: 4,
title: "API Development",
assignmentSubmissionStatus: "SUCCESS",
descriptionLink: "https://example.com/assignment/124",
deadline: "2024-08-20T14:30:00",
submissionLink: "https://github.com/GDSC-Hongik/wow-class",
submissionFailureType: "NONE",
committedAt: "2024-08-20T14:30:00",
},
];

0 comments on commit 84260e8

Please sign in to comment.