-
Notifications
You must be signed in to change notification settings - Fork 0
멘토스터디 / 그룹스터디 미션 평가 노출 로직 수정 및 JS 로드 크기 개선 #541
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
c7fde2e
fix : 미션 제출 로직 수정
HA-SEUNG-JEONG 0cbd8d1
Merge branch 'develop' of https://github.com/code-zero-to-one/study-p…
HA-SEUNG-JEONG a28c537
feat : 아직 과제 제출 기간이 오지 않은 경우에 대한 처리 추가
HA-SEUNG-JEONG e9ce265
feat : 미션 평가 모달 다시 추가
HA-SEUNG-JEONG 6fe9f31
fix : 리더이면서 멘토스터디인 경우에 대한 로직 추가
HA-SEUNG-JEONG 6ba9b0f
Merge branch 'develop' of https://github.com/code-zero-to-one/study-p…
HA-SEUNG-JEONG 047c720
feat : mission.status 체크 추가
HA-SEUNG-JEONG 364995f
refactor : 스터디 상세 페이지 First Load JS 크기 개선
HA-SEUNG-JEONG ea7f6ac
delete : 주석 제거
HA-SEUNG-JEONG 6bd9fa0
fix : status 수정
HA-SEUNG-JEONG e2b0427
fix : 워딩 수정
HA-SEUNG-JEONG 95a849b
fix : 미션 카드 중첩 버튼 위반 및 Progress NaN 오류 수정
HA-SEUNG-JEONG b26e8b5
refactor : 날짜 선택 관련 로직 리팩토링
HA-SEUNG-JEONG 9b11f61
fix : 폴백 처리
HA-SEUNG-JEONG 79a1414
fix : 타입 안정성 추가
HA-SEUNG-JEONG File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
This file contains hidden or 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
167 changes: 167 additions & 0 deletions
167
src/components/common/modals/create-evaluation-modal.tsx
This file contains hidden or 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,167 @@ | ||
| 'use client'; | ||
|
|
||
| import { zodResolver } from '@hookform/resolvers/zod'; | ||
| import { useState } from 'react'; | ||
| import { FormProvider, useForm } from 'react-hook-form'; | ||
| import { z } from 'zod'; | ||
| import Button from '@/components/common/ui/button'; | ||
| import FormField from '@/components/common/ui/form/form-field'; | ||
| import { TextAreaInput } from '@/components/common/ui/input'; | ||
| import { Modal } from '@/components/common/ui/modal'; | ||
| import { GroupItems } from '@/components/common/ui/toggle'; | ||
| import { | ||
| useCreateEvaluation, | ||
| useGetMissionEvaluationGrades, | ||
| } from '@/hooks/queries/evaluation-api'; | ||
| import { useToastStore } from '@/stores/use-toast-store'; | ||
|
|
||
| const CreateEvaluationFormSchema = z.object({ | ||
| gradeCode: z.string().min(1, '평가 등급을 선택해주세요.'), | ||
| comment: z.string().min(1, '정성 코멘트를 입력해주세요.').max(1000), | ||
| }); | ||
|
|
||
| type CreateEvaluationFormValues = z.infer<typeof CreateEvaluationFormSchema>; | ||
|
|
||
| interface CreateEvaluationModalProps { | ||
| homeworkId: number; | ||
| } | ||
|
|
||
| export default function CreateEvaluationModal({ | ||
| homeworkId, | ||
| }: CreateEvaluationModalProps) { | ||
| const [open, setOpen] = useState<boolean>(false); | ||
|
|
||
| return ( | ||
| <Modal.Root open={open} onOpenChange={setOpen}> | ||
| <Modal.Trigger asChild> | ||
| <Button size="medium" className="font-designer-16r w-fit"> | ||
| 과제 평가하기 | ||
| </Button> | ||
| </Modal.Trigger> | ||
|
|
||
| <Modal.Portal> | ||
| <Modal.Overlay /> | ||
| <Modal.Content className="w-[840px]"> | ||
| <Modal.Header variant="form"> | ||
| <Modal.Title className="font-designer-20b text-text-strong"> | ||
| 평가하기 | ||
| </Modal.Title> | ||
| <Modal.CloseButton onClick={() => setOpen(false)} /> | ||
| </Modal.Header> | ||
|
|
||
| <CreateEvaluationForm | ||
| homeworkId={homeworkId} | ||
| onClose={() => setOpen(false)} | ||
| /> | ||
| </Modal.Content> | ||
| </Modal.Portal> | ||
| </Modal.Root> | ||
| ); | ||
| } | ||
|
|
||
| interface CreateEvaluationFormProps { | ||
| homeworkId: number; | ||
| onClose: () => void; | ||
| } | ||
|
|
||
| function CreateEvaluationForm({ | ||
| homeworkId, | ||
| onClose, | ||
| }: CreateEvaluationFormProps) { | ||
| const methods = useForm<CreateEvaluationFormValues>({ | ||
| resolver: zodResolver(CreateEvaluationFormSchema), | ||
| mode: 'onChange', | ||
| defaultValues: { | ||
| gradeCode: undefined, | ||
| comment: '', | ||
| }, | ||
| }); | ||
|
|
||
| const { handleSubmit, formState } = methods; | ||
|
|
||
| const { data: grades } = useGetMissionEvaluationGrades(); | ||
| const { mutate: createEvaluation } = useCreateEvaluation(); | ||
| const showToast = useToastStore((state) => state.showToast); | ||
|
|
||
| const onValidSubmit = (values: CreateEvaluationFormValues) => { | ||
| createEvaluation( | ||
| { | ||
| homeworkId, | ||
| request: values, | ||
| }, | ||
| { | ||
| onSuccess: () => { | ||
| showToast('평가가 성공적으로 제출되었습니다!'); | ||
| onClose(); | ||
| }, | ||
| onError: () => { | ||
| showToast('평가 제출에 실패했습니다. 다시 시도해주세요.', 'error'); | ||
| }, | ||
| }, | ||
| ); | ||
| }; | ||
|
|
||
| const gradeOptions = (grades ?? []) | ||
| .sort((a, b) => (a.orderNum ?? 0) - (b.orderNum ?? 0)) | ||
| .map((grade) => ({ | ||
| value: grade.code, | ||
| label: `${grade.label} (${grade.score === 0 ? '0' : (grade.score?.toFixed(1) ?? '-')})`, | ||
| })); | ||
|
|
||
| return ( | ||
| <FormProvider {...methods}> | ||
| <Modal.Body variant="form"> | ||
| <form | ||
| id="create-evaluation" | ||
| className="flex flex-col gap-300" | ||
| onSubmit={handleSubmit(onValidSubmit)} | ||
| > | ||
| <FormField<CreateEvaluationFormValues, 'gradeCode'> | ||
| name="gradeCode" | ||
| label="평가 점수 선택" | ||
| direction="vertical" | ||
| required | ||
| > | ||
| <GroupItems | ||
| variant="square" | ||
| options={gradeOptions} | ||
| multiple={false} | ||
| allowDeselect={false} | ||
| /> | ||
| </FormField> | ||
|
|
||
| <FormField<CreateEvaluationFormValues, 'comment'> | ||
| name="comment" | ||
| label="정성 코멘트" | ||
| direction="vertical" | ||
| required | ||
| > | ||
| <TextAreaInput | ||
| id="comment" | ||
| placeholder="정성 코멘트를 입력해 주세요." | ||
| className="min-h-[230px]" | ||
| maxLength={1000} | ||
| /> | ||
| </FormField> | ||
| </form> | ||
| </Modal.Body> | ||
|
|
||
| <Modal.Footer variant="form"> | ||
| <Modal.Close asChild> | ||
| <Button color="secondary" size="large" onClick={onClose}> | ||
| 취소 | ||
| </Button> | ||
| </Modal.Close> | ||
| <Button | ||
| color="primary" | ||
| size="large" | ||
| type="submit" | ||
| form="create-evaluation" | ||
| disabled={!formState.isValid || formState.isSubmitting} | ||
| > | ||
| 평가 완료 | ||
| </Button> | ||
| </Modal.Footer> | ||
| </FormProvider> | ||
| ); | ||
| } |
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.