-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
315 additions
and
0 deletions.
There are no files selected for viewing
38 changes: 38 additions & 0 deletions
38
...dies/detail-info/[studyId]/@modal/(.)detail-Info-check/_hooks/useSubmitStudyDetailInfo.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { createStudyApi } from "apis/study/createStudyApi"; | ||
import { routerPath } from "constants/router/routerPath"; | ||
import { tags } from "constants/tags"; | ||
import { useRouter } from "next/navigation"; | ||
import { useState } from "react"; | ||
import type { CreateStudyDetailInfoApiRequestDto } from "types/dtos/studyDetailInfo"; | ||
import { revalidateTagByName } from "utils/revalidateTagByName"; | ||
|
||
const useSubmitStudyDetailInfo = ( | ||
studyId: number, | ||
studyDetailData: CreateStudyDetailInfoApiRequestDto | ||
) => { | ||
const [isSuccess, setIsSuccess] = useState(false); | ||
const router = useRouter(); | ||
|
||
const handleSubmitDetailInfo = async () => { | ||
const data = await createStudyApi.postStudyDetailInfo( | ||
studyDetailData, | ||
studyId | ||
); | ||
if (data.success) { | ||
setIsSuccess(true); | ||
revalidateTagByName(tags.curriculums); | ||
const timerId = setTimeout(() => { | ||
router.push(`${routerPath.root.href}/${studyId}`); | ||
}, 500); | ||
return () => clearTimeout(timerId); | ||
} else { | ||
setIsSuccess(false); | ||
window.alert("스터디 상세 정보 저장에 실패했어요."); | ||
router.push(`${routerPath.root.href}`); | ||
} | ||
}; | ||
|
||
return { isSuccess, handleSubmitDetailInfo }; | ||
}; | ||
|
||
export default useSubmitStudyDetailInfo; |
112 changes: 112 additions & 0 deletions
112
apps/admin/app/studies/detail-info/[studyId]/@modal/(.)detail-Info-check/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
"use client"; | ||
|
||
import { Flex } from "@styled-system/jsx"; | ||
import { Modal, Space, Text } from "@wow-class/ui"; | ||
import { useModalRoute } from "@wow-class/ui/hooks"; | ||
import { studyApi } from "apis/study/studyApi"; | ||
import useParseSearchParams from "hooks/useParseSearchParams"; | ||
import { useSearchParams } from "next/navigation"; | ||
import { useEffect, useState } from "react"; | ||
import type { CreateStudyDetailInfoApiRequestDto } from "types/dtos/studyDetailInfo"; | ||
import Button from "wowds-ui/Button"; | ||
|
||
import useSubmitStudyDetailInfo from "./_hooks/useSubmitStudyDetailInfo"; | ||
|
||
const StudyDetailInfoCheckModal = () => { | ||
const [studyName, setStudyName] = useState(""); | ||
const { onClose } = useModalRoute(); | ||
const { parseQueryString } = useParseSearchParams(); | ||
const searchParams = useSearchParams(); | ||
const { studyId, ...formData } = parseQueryString< | ||
CreateStudyDetailInfoApiRequestDto & { studyId: string } | ||
>(searchParams.toString()); | ||
|
||
const { isSuccess, handleSubmitDetailInfo } = useSubmitStudyDetailInfo( | ||
parseInt(studyId, 10), | ||
formData | ||
); | ||
|
||
useEffect(() => { | ||
const fetchStudyData = async () => { | ||
const response = await studyApi.getStudyBasicInfo(parseInt(studyId, 10)); | ||
if (response) setStudyName(response.title); | ||
}; | ||
fetchStudyData(); | ||
}, [studyId]); | ||
|
||
return ( | ||
<Modal> | ||
<SubmitSuccessMessage studyName={studyName} success={isSuccess} /> | ||
<SubmitConfirmMessage | ||
closeModal={onClose} | ||
handleSubmitDetailInfo={handleSubmitDetailInfo} | ||
studyName={studyName} | ||
success={isSuccess} | ||
/> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default StudyDetailInfoCheckModal; | ||
|
||
const SubmitSuccessMessage = ({ | ||
success, | ||
studyName, | ||
}: { | ||
success: boolean; | ||
studyName: string; | ||
}) => { | ||
return ( | ||
<> | ||
{success && ( | ||
<Flex alignItems="center" direction="column" gap="4px"> | ||
<Text as="h1" color="primary" typo="h1"> | ||
{studyName} | ||
</Text> | ||
<Text as="h1" color="textBlack" typo="h1"> | ||
상세 정보가 저장되었어요. | ||
</Text> | ||
</Flex> | ||
)} | ||
</> | ||
); | ||
}; | ||
|
||
const SubmitConfirmMessage = ({ | ||
success, | ||
studyName, | ||
closeModal, | ||
handleSubmitDetailInfo, | ||
}: { | ||
success: boolean; | ||
studyName: string; | ||
closeModal: () => void; | ||
handleSubmitDetailInfo: () => void; | ||
}) => { | ||
if (!success) { | ||
return ( | ||
<Flex alignItems="center" direction="column" padding="24px" width="100%"> | ||
<Flex alignItems="center" justify="center" marginBottom="2px"> | ||
<Text as="p" color="primary" typo="h1"> | ||
{studyName} | ||
</Text> | ||
<Text as="p" typo="h1"> | ||
의 상세정보 | ||
</Text> | ||
</Flex> | ||
<Text as="p" typo="h1"> | ||
입력 내용을 저장하시겠어요? | ||
</Text> | ||
<Space height={28} /> | ||
<Flex gap="sm" justify="center" width="21rem"> | ||
<Button variant="outline" onClick={closeModal}> | ||
취소 | ||
</Button> | ||
<Button onClick={handleSubmitDetailInfo}>저장하기</Button> | ||
</Flex> | ||
</Flex> | ||
); | ||
} else { | ||
return; | ||
} | ||
}; |
5 changes: 5 additions & 0 deletions
5
apps/admin/app/studies/detail-info/[studyId]/@modal/default.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const Default = () => { | ||
return null; | ||
}; | ||
|
||
export default Default; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const Default = () => { | ||
return null; | ||
}; | ||
|
||
export default Default; |
Empty file.
46 changes: 46 additions & 0 deletions
46
...nt/app/(afterLogin)/my-study/my-assignment/@modal/(.)repository-url/confirmation/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
"use client"; | ||
|
||
import { css } from "@styled-system/css"; | ||
import { Flex } from "@styled-system/jsx"; | ||
import { Modal, Space, Text } from "@wow-class/ui"; | ||
import { tags } from "constants/tags"; | ||
import useMatchedStudyHistoryId from "hooks/useMatchedStudyHistoryId"; | ||
import { useSearchParams } from "next/navigation"; | ||
import { revalidateTagByName } from "utils/revalidateTagByName"; | ||
import Button from "wowds-ui/Button"; | ||
|
||
const RepositoryUrlConfirmationModal = () => { | ||
const searchParams = useSearchParams(); | ||
const url = searchParams.get("repositoryUrl"); | ||
//const studyHistoryId = useMatchedStudyHistoryId(); | ||
|
||
const handleClickSubmitButton = async () => { | ||
//await studyHistoryApi.putRepository(studyHistoryId, url); | ||
//TODO: 제출 후에 RepositoryBox 를 SUBMITTED 로 상태로 바꿔줘야함. | ||
revalidateTagByName(tags.studyDetailDashboard); | ||
}; | ||
return ( | ||
<Modal> | ||
<Flex alignItems="center" direction="column" width="21rem"> | ||
<Text typo="h1">레포지토리를 입력하시겠어요?</Text> | ||
<Space height={12} /> | ||
<Text color="sub">최초 과제 제출 전까지 수정이 가능해요.</Text> | ||
<Space height={8} /> | ||
<div className={urlBoxStyle}>{url}</div> | ||
<Space height={28} /> | ||
<Button onClick={handleClickSubmitButton}>입력하기</Button> | ||
</Flex> | ||
</Modal> | ||
); | ||
}; | ||
|
||
export default RepositoryUrlConfirmationModal; | ||
|
||
const urlBoxStyle = css({ | ||
backgroundColor: "backgroundAlternative", | ||
borderRadius: "5px", | ||
color: "sub", | ||
paddingX: "lg", | ||
paddingY: "md", | ||
textStyle: "h2", | ||
}); |
5 changes: 5 additions & 0 deletions
5
apps/client/app/(afterLogin)/my-study/my-assignment/@modal/(.)repository-url/default.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const Default = () => { | ||
return null; | ||
}; | ||
|
||
export default Default; |
5 changes: 5 additions & 0 deletions
5
apps/client/app/(afterLogin)/my-study/my-assignment/@modal/default.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
const Default = () => { | ||
return null; | ||
}; | ||
|
||
export default Default; |
8 changes: 8 additions & 0 deletions
8
apps/client/app/(afterLogin)/my-study/my-assignment/repository-url/confirmation/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { routePath } from "constants/routePath"; | ||
import { redirect } from "next/navigation"; | ||
|
||
const RepositoryUrlConfirmationPage = () => { | ||
return redirect(routePath["my-assignment"]); | ||
}; | ||
|
||
export default RepositoryUrlConfirmationPage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import type { ComponentProps } from "react"; | ||
import type { AssignmentSubmissionStatusType } from "types/entities/common/assignment"; | ||
import type Tag from "wowds-ui/Tag"; | ||
|
||
export const assignmentSubmissionStatusMap: Record< | ||
AssignmentSubmissionStatusType, | ||
{ label: string; color: ComponentProps<typeof Tag>["color"] } | ||
> = { | ||
SUCCESS: { label: "제출 완료", color: "blue" }, | ||
FAILURE: { label: "제출 실패", color: "red" }, | ||
PENDING: { label: "과제 휴강", color: "grey" }, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { myStudyApi } from "apis/myStudyApi"; | ||
import { useEffect, useState } from "react"; | ||
|
||
const useFetchAttendanceCheckModalInfoData = () => { | ||
const [studyInfo, setStudyInfo] = useState({ | ||
currentWeek: 0, | ||
studyName: "", | ||
}); | ||
|
||
useEffect(() => { | ||
const fetchAttendanceCheckModalInfoData = async () => { | ||
const myOngoingStudyData = await myStudyApi.getMyOngoingStudyInfo(); | ||
|
||
if (!myOngoingStudyData?.studyId) { | ||
return null; | ||
} | ||
|
||
const dailyTaskListData = await myStudyApi.getDailyTaskList( | ||
myOngoingStudyData?.studyId | ||
); | ||
const basicStudyInfoData = await myStudyApi.getBasicStudyInfo( | ||
myOngoingStudyData?.studyId | ||
); | ||
|
||
const attendanceDailyTask = dailyTaskListData?.find( | ||
(dailyTask) => dailyTask.todoType === "ATTENDANCE" | ||
); | ||
|
||
if (!attendanceDailyTask?.week || !basicStudyInfoData?.title) { | ||
return null; | ||
} | ||
|
||
setStudyInfo({ | ||
currentWeek: attendanceDailyTask?.week, | ||
studyName: basicStudyInfoData?.title, | ||
}); | ||
}; | ||
|
||
fetchAttendanceCheckModalInfoData(); | ||
}, []); | ||
|
||
return { studyInfo }; | ||
}; | ||
|
||
export default useFetchAttendanceCheckModalInfoData; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
"use client"; | ||
|
||
import { studyDetailApi } from "apis/studyDetailApi"; | ||
import { studyHistoryApi } from "apis/studyHistoryApi"; | ||
import { history, studyDashBoardData } from "constants/assignmentMockData"; | ||
import { useEffect, useState } from "react"; | ||
|
||
export default function useMatchedStudyHistoryId() { | ||
const [matchedStudyHistoryId, setMatchedStudyHistoryId] = useState<number>(); | ||
useEffect(() => { | ||
const fetchData = async () => { | ||
//TODO: 수강 중인 스터디 api 호출 | ||
//const studyId = await myStudyApi.getMyOngoingStudyInfo(); | ||
//const studyHistories = await studyHistoryApi.getStudyHistory(studyId); | ||
const studyHistories = history; | ||
// const studyDashboard = | ||
// await studyDetailApi.getStudyDetailDashboard(studyId); | ||
const studyDashboard = studyDashBoardData; | ||
if (studyHistories && studyDashboard) { | ||
const submittableWeek = studyDashboard.submittableAssignments[0]?.week; | ||
const matchedHistory = studyHistories.find( | ||
(item) => item.week === submittableWeek | ||
); | ||
|
||
setMatchedStudyHistoryId(matchedHistory?.assignmentHistoryId); | ||
} | ||
}; | ||
|
||
fetchData(); | ||
}, []); | ||
|
||
return { matchedStudyHistoryId }; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { default as isDeadlinePassed } from "./isDeadlinePassed"; |