diff --git a/src/features/write/components/create-quiz-drawer.tsx b/src/features/write/components/create-quiz-drawer.tsx new file mode 100644 index 00000000..19a4a3a8 --- /dev/null +++ b/src/features/write/components/create-quiz-drawer.tsx @@ -0,0 +1,134 @@ +'use client' + +import Icon from '@/shared/components/custom/icon' +import { Button } from '@/shared/components/ui/button' +import { Drawer, DrawerContent, DrawerTitle, DrawerTrigger } from '@/shared/components/ui/drawer' +import { Slider } from '@/shared/components/ui/slider' +import Text from '@/shared/components/ui/text' +import { cn } from '@/shared/lib/utils' +import { useState } from 'react' + +interface Props { + handleCreateDocument: (params: { quizType: Quiz.Type; star: number }) => void +} + +const CreateQuizDrawer = ({ handleCreateDocument }: Props) => { + const totalQuizCount = 40 + const [selectedQuizCount, setSelectedQuizCount] = useState(10) + const [selectedQuizType, setSelectedQuizType] = useState('MULTIPLE_CHOICE') + + const handleSliderChange = (value: number[]) => { + const newCount = Math.round((value[0] / 100) * totalQuizCount) + setSelectedQuizCount(newCount) + } + + const handleClickQuizType = (quizType: Quiz.Type) => { + setSelectedQuizType(quizType) + } + + return ( + + + + + + + + + 원하는 유형과 문제 수를 선택해주세요 + + + +
+ + +
+ +
+ +
+ + 만들 문제 + + + {selectedQuizCount} 문제 + + +
+ + {selectedQuizCount} 문제 + + + {totalQuizCount} 문제 + +
+
+ +
+ + 현재 나의 별: 16개 + + +
+ + + ) +} + +export default CreateQuizDrawer diff --git a/src/features/write/pages/write-document-page.tsx b/src/features/write/pages/write-document-page.tsx index d3581905..17ab5e7e 100644 --- a/src/features/write/pages/write-document-page.tsx +++ b/src/features/write/pages/write-document-page.tsx @@ -6,36 +6,46 @@ import Icon from '@/shared/components/custom/icon' import Text from '@/shared/components/ui/text' import dynamic from 'next/dynamic' import FixedBottom from '@/shared/components/custom/fixed-bottom' -import { Button } from '@/shared/components/ui/button' import { useCreateDocument } from '@/requests/document/hooks' import { MAX_CHARACTERS, MIN_CHARACTERS } from '@/features/document/config' import { useDirectoryContext } from '@/features/directory/contexts/directory-context' +import CreateQuizDrawer from '../components/create-quiz-drawer' +import { useRouter } from 'next/navigation' const Editor = dynamic(() => import('../components/editor'), { ssr: false, }) const WriteDocumentPage = () => { + const router = useRouter() + const { selectedDirectory } = useDirectoryContext() const [title, setTitle] = useState('') const [content, setContent] = useState('') const { mutate: createDocumentMutate } = useCreateDocument() - const handleCreateDocument = () => { + const handleCreateDocument = ({ quizType, star }: { quizType: Quiz.Type; star: number }) => { // TODO: validation if (!selectedDirectory) { return } - createDocumentMutate({ - directoryId: selectedDirectory.id, - documentName: title, - file: content, - quizType: 'MULTIPLE_CHOICE', - star: 5, - documentType: 'TEXT', - }) + createDocumentMutate( + { + directoryId: selectedDirectory.id, + documentName: title, + file: content, + quizType, + star, + documentType: 'TEXT', + }, + { + onSuccess: ({ id }) => { + router.push(`/document/${id}`) + }, + } + ) } return ( @@ -67,14 +77,7 @@ const WriteDocumentPage = () => { setContent(value)} /> - +
) diff --git a/src/types/quiz.d.ts b/src/types/quiz.d.ts index 69ad2eaa..542b8db1 100644 --- a/src/types/quiz.d.ts +++ b/src/types/quiz.d.ts @@ -150,61 +150,11 @@ declare namespace Quiz { type Item = CombineQuiz type List = CombineQuiz[] type ItemWithMetadata = QuizWithMetadata - type QuizType = QuizType + type Type = QuizType type Record = QuizRecord type Result = UpdateQuizResultPayload['quizzes'][number] declare namespace Request { - /** GET /api/v2/today-quiz-info - * 오늘의 퀴즈 현황 - */ - type GetTodayInfo = void - - /** GET /api/v2/quizzes - * 생성된 모든 퀴즈 가져오기(전체 문서) - */ - type GetAllQuizzes = void - - /** GET /api/v2/quizzes/{quiz_set_id}/quiz-record - * 퀴즈 세트에 대한 상세 기록 - */ - type GetQuizSetRecord = void - - /** GET /api/v2/quizzes/quiz-records - * 전체 퀴즈 기록 - */ - type GetQuizRecords = void - - /** GET /api/v2/quiz-sets/{quiz_set_id} - * quizSet_id로 퀴즈 가져오기 - */ - type GetQuizSet = void - - /** GET /api/v2/quiz-sets/today - * 오늘의 퀴즈 세트 정보 가져오기 - */ - type GetTodayQuizSet = void - - /** GET /api/v2/quiz-analysis - * 퀴즈 분석 - */ - type GetQuizAnalysis = void - - /** GET /api/v2/documents/{document_id}/review-pick - * document_id로 복습 pick 가져오기 - */ - type GetReviewPick = void - - /** GET /api/v2/documents/{document_id}/quizzes - * document_id에 해당하는 모든 퀴즈 가져오기 - */ - type GetDocumentQuizzes = void - - /** GET /api/v2/documents/{document_id}/download-quiz - * 퀴즈 다운로드 - */ - type DownloadQuiz = void - /** PATCH /api/v2/quiz/result * 퀴즈 결과 업데이트 */ @@ -214,16 +164,6 @@ declare namespace Quiz { * 사용자가 생성한 문서에서 직접 퀴즈 생성(랜덤, OX, 객관식) */ type CreateQuizzes = CreateQuizzesPayload - - /** DELETE /api/v2/quizzes/{quiz_id}/delete-quiz - * 퀴즈 삭제 - */ - type DeleteQuiz = void - - /** DELETE /api/v2/quizzes/{quiz_id}/delete-invalid-quiz - * 잘못된 퀴즈 삭제 - */ - type DeleteInvalidQuiz = void } declare namespace Response { @@ -281,20 +221,5 @@ declare namespace Quiz { * 퀴즈 결과 업데이트 */ type UpdateQuizResult = UpdateQuizResultResponse - - /** POST /api/v2/quizzes/documents/{document_id}/create-quizzes - * 사용자가 생성한 문서에서 직접 퀴즈 생성(랜덤, OX, 객관식) - */ - type CreateQuizzes = void - - /** DELETE /api/v2/quizzes/{quiz_id}/delete-quiz - * 퀴즈 삭제 - */ - type DeleteQuiz = void - - /** DELETE /api/v2/quizzes/{quiz_id}/delete-invalid-quiz - * 잘못된 퀴즈 삭제 - */ - type DeleteInvalidQuiz = void } }