Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions src/features/study/group/ui/group-study-form-modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,23 @@ export default function GroupStudyFormModal({
const refineStudyDetail = (value: GroupStudyFullResponseDto) => {
if (isLoading) return;

const refinedClassification =
value.basicInfo?.classification ?? classification;
const originalType = value.basicInfo?.type;

let refinedType = originalType;
if (
refinedClassification === 'GROUP_STUDY' &&
originalType === 'MENTORING'
) {
refinedType = undefined;
}

return {
classification: value.basicInfo?.classification ?? classification,
classification: refinedClassification,
studyLeaderParticipation:
value.basicInfo.studyLeaderParticipation ?? false,
type: value.basicInfo?.type,
type: refinedType,
targetRoles: value.basicInfo?.targetRoles,
maxMembersCount: value.basicInfo?.maxMembersCount?.toString() ?? '',
experienceLevels: value.basicInfo?.experienceLevels,
Expand Down
43 changes: 10 additions & 33 deletions src/features/study/group/ui/step/step1-group.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
'use client';

import { addDays } from 'date-fns';
import { useEffect } from 'react';
import {
Controller,
useController,
useFormContext,
useWatch,
} from 'react-hook-form';
import Checkbox from '@/components/ui/checkbox';

import { SingleDropdown } from '@/components/ui/dropdown';
import FormField from '@/components/ui/form/form-field';
import { BaseInput } from '@/components/ui/input';
Expand Down Expand Up @@ -52,44 +53,20 @@ export default function Step1OpenGroupStudy() {
name: 'regularMeeting',
control,
});
const { field: studyLeaderParticipationField } = useController({
name: 'studyLeaderParticipation',
control,
});

const methodValue = useWatch({
name: 'method',
control,
});

const filteredStudyTypes =
classification === 'GROUP_STUDY'
? STUDY_TYPES.filter((type) => type !== 'MENTORING')
: STUDY_TYPES;

return (
<>
<div className="font-designer-20b text-text-default">기본 정보 설정</div>
<FormField<GroupStudyFormValues, 'studyLeaderParticipation'>
name="studyLeaderParticipation"
label="리더 참여 여부"
helper="스터디 리더가 직접 스터디에 참여하는지 선택해주세요."
direction="vertical"
size="medium"
required
>
<div className="flex items-center gap-100">
<Checkbox
id="studyLeaderParticipation"
checked={studyLeaderParticipationField.value}
onToggle={() =>
studyLeaderParticipationField.onChange(
!studyLeaderParticipationField.value,
)
}
/>
<label
htmlFor="studyLeaderParticipation"
className="font-designer-14m text-text-default cursor-pointer"
>
리더가 스터디에 참여합니다
</label>
</div>
</FormField>
<FormField<GroupStudyFormValues, 'type'>
name="type"
label="스터디 유형"
Expand All @@ -103,14 +80,14 @@ export default function Step1OpenGroupStudy() {
value={typeField.value}
onValueChange={typeField.onChange}
>
{STUDY_TYPES.map((type) => (
{filteredStudyTypes.map((type) => (
<div key={type} className="flex items-center gap-100">
<RadioGroupItem value={type} id={`study-type-${type}`} />
<label
htmlFor={`study-type-${type}`}
className="font-designer-14m text-text-default"
>
{STUDY_TYPE_LABELS[type]}
{STUDY_TYPE_LABELS[type as keyof typeof STUDY_TYPE_LABELS]}
</label>
</div>
))}
Expand Down
Loading