From d74f5e22e3734d0c2ffa915862210aca5dbf669e Mon Sep 17 00:00:00 2001 From: Jeong Ha Seung <88266129+HA-SEUNG-JEONG@users.noreply.github.com> Date: Thu, 16 Apr 2026 16:36:30 +0900 Subject: [PATCH] =?UTF-8?q?[study-edit]=20fix=20:=20=EC=8A=A4=ED=84=B0?= =?UTF-8?q?=EB=94=94=20=EC=88=98=EC=A0=95=20=EC=8B=9C=20=EC=8D=B8=EB=84=A4?= =?UTF-8?q?=EC=9D=BC=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=9C=A0=EC=A7=80=20?= =?UTF-8?q?=EB=B0=8F=20=EC=9C=A0=ED=9A=A8=EC=84=B1=20=EA=B2=80=EC=A6=9D=20?= =?UTF-8?q?=EB=A1=9C=EC=A7=81=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../group-study/forms/group-study-form.tsx | 13 +++++- .../modals/group-study-form-modal.tsx | 43 ++++++++++++------- 2 files changed, 39 insertions(+), 17 deletions(-) diff --git a/src/components/group-study/forms/group-study-form.tsx b/src/components/group-study/forms/group-study-form.tsx index a07f22969..3c0f06f04 100644 --- a/src/components/group-study/forms/group-study-form.tsx +++ b/src/components/group-study/forms/group-study-form.tsx @@ -126,6 +126,10 @@ export default function GroupStudyForm({ return typeof value !== 'string' || value.trim() === ''; } if (field === 'thumbnailExtension') { + if (mode === 'edit') { + const existingUrl = methods.getValues('thumbnailUrl'); + return (!value || value === 'DEFAULT') && !existingUrl; + } return !value || value === 'DEFAULT'; } if (field === 'interviewPost') { @@ -139,7 +143,14 @@ export default function GroupStudyForm({ return false; }); - }, [currentStepFields, currentStepValues, formState.errors, classification]); + }, [ + currentStepFields, + currentStepValues, + formState.errors, + classification, + methods, + mode, + ]); return ( diff --git a/src/components/group-study/modals/group-study-form-modal.tsx b/src/components/group-study/modals/group-study-form-modal.tsx index e6c9430fb..35a57e735 100644 --- a/src/components/group-study/modals/group-study-form-modal.tsx +++ b/src/components/group-study/modals/group-study-form-modal.tsx @@ -95,9 +95,12 @@ function resolveStudyType( function resolveThumbnailExtension( imageUrl: string | undefined, ): GroupStudyFormValues['thumbnailExtension'] { - const ext = imageUrl?.split('.').pop()?.toUpperCase(); + if (!imageUrl) return 'DEFAULT'; + const cleanUrl = imageUrl.split('?')[0]; + const ext = cleanUrl.split('.').pop()?.toUpperCase(); + const isValid = ext && isOneOf(THUMBNAIL_EXTENSION, ext) && ext !== 'DEFAULT'; - return ext && isOneOf(THUMBNAIL_EXTENSION, ext) ? ext : 'DEFAULT'; + return isValid ? ext : 'JPG'; } function prepareDescription( @@ -159,6 +162,7 @@ export default function GroupStudyFormModal({ const [isVerificationModalOpen, setIsVerificationModalOpen] = useState(false); const originalStartDateRef = useRef(undefined); + const isFormInitializedRef = useRef(false); const createMethods = useForm({ resolver: zodResolver(GroupStudyFormSchema), @@ -224,27 +228,29 @@ export default function GroupStudyFormModal({ return { classification: resolvedClassification, - type: resolveStudyType(value.basicInfo?.type, resolvedClassification), + type: + resolveStudyType(value.basicInfo?.type, resolvedClassification) ?? + 'PROJECT', thumbnailExtension: resolveThumbnailExtension(thumbnailUrl), - thumbnailUrl, + thumbnailUrl: thumbnailUrl ?? null, studyLeaderParticipation: value.basicInfo?.studyLeaderParticipation ?? false, - targetRoles: value.basicInfo?.targetRoles, + targetRoles: value.basicInfo?.targetRoles ?? [], maxMembersCount: value.basicInfo?.maxMembersCount?.toString() ?? '', - experienceLevels: value.basicInfo?.experienceLevels, - method: value.basicInfo?.method, - location: value.basicInfo?.location, - regularMeeting: value.basicInfo?.regularMeeting, - startDate: value.basicInfo?.startDate, - endDate: value.basicInfo?.endDate, + experienceLevels: value.basicInfo?.experienceLevels ?? [], + method: value.basicInfo?.method ?? 'ONLINE', + location: value.basicInfo?.location ?? '', + regularMeeting: value.basicInfo?.regularMeeting ?? 'NONE', + startDate: value.basicInfo?.startDate ?? '', + endDate: value.basicInfo?.endDate ?? '', price: value.basicInfo?.price?.toString() ?? '', - title: value.detailInfo?.title, - description: value.detailInfo?.description, - summary: value.detailInfo?.summary, + title: value.detailInfo?.title ?? '', + description: value.detailInfo?.description ?? '', + summary: value.detailInfo?.summary ?? '', descriptionPendingImages: [], interviewPost: value.interviewPost?.interviewPost ?.map((q) => q.question) - .filter((q): q is string => Boolean(q)), + .filter((q): q is string => Boolean(q)) ?? [''], } satisfies GroupStudyFormValues; }, [classification], @@ -413,9 +419,14 @@ export default function GroupStudyFormModal({ }, [open, mode]); useEffect(() => { - if (mode === 'edit' && controlledOpen && groupStudyInfo) { + if (!controlledOpen) { + isFormInitializedRef.current = false; + return; + } + if (mode === 'edit' && groupStudyInfo && !isFormInitializedRef.current) { originalStartDateRef.current = groupStudyInfo.basicInfo?.startDate; editMethods.reset(refineStudyDetail(groupStudyInfo)); + isFormInitializedRef.current = true; } }, [controlledOpen, groupStudyInfo, editMethods, mode, refineStudyDetail]);