diff --git a/apps/client/apis/studyHistoryApi.ts b/apps/client/apis/studyHistoryApi.ts index 24b1a619..4081de3c 100644 --- a/apps/client/apis/studyHistoryApi.ts +++ b/apps/client/apis/studyHistoryApi.ts @@ -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 }; + }, }; diff --git a/apps/client/app/(afterLogin)/my-study/my-assignment/_components/AssignmentContent/AssignmentOverviewBox/AssignmenBoxButtons.tsx b/apps/client/app/(afterLogin)/my-study/my-assignment/_components/AssignmentContent/AssignmentOverviewBox/AssignmenBoxButtons.tsx index b222d8bb..65a34f46 100644 --- a/apps/client/app/(afterLogin)/my-study/my-assignment/_components/AssignmentContent/AssignmentOverviewBox/AssignmenBoxButtons.tsx +++ b/apps/client/app/(afterLogin)/my-study/my-assignment/_components/AssignmentContent/AssignmentOverviewBox/AssignmenBoxButtons.tsx @@ -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"; @@ -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 = () => { diff --git a/apps/client/constants/assignmentMockData.ts b/apps/client/constants/assignmentMockData.ts index e5acb8ac..b895c887 100644 --- a/apps/client/constants/assignmentMockData.ts +++ b/apps/client/constants/assignmentMockData.ts @@ -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", + }, ];