-
Notifications
You must be signed in to change notification settings - Fork 4
Feat/markup/create meeting/DEVING-40 모임생성 및 수정 페이지 구현 #38
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
33 commits
Select commit
Hold shift + click to select a range
bb814b2
test(DEVING-40): 임시 메인페이지 구현
clyde-yoonjae 7e6d5b1
Merge branch 'dev' of https://github.com/MoimService/Moim-FE into fea…
clyde-yoonjae 168f256
chore(DEVING-40): 데이트피커 추가
clyde-yoonjae 764c7d2
chore(DEVING-40): 리엑트쿼리 데브툴 추가
clyde-yoonjae 6d92b47
Merge branch 'dev' of https://github.com/MoimService/Moim-FE into fea…
clyde-yoonjae 62e840c
fix(DEVING-51): 기술스택버튼 기본타입 button 추가
clyde-yoonjae 1220499
feat(DEVING-40): 모임생성 및 수정Form 타입선언
clyde-yoonjae 12d0937
feat(DEVING-40): 미팅생성API 구현
clyde-yoonjae 4d321d9
feat(DEVING-40): 미팅생성Mutation 구현
clyde-yoonjae 4d60de8
feat(DEVING-40): 미팅Form 상수관리 파일 생성 및 구현
clyde-yoonjae 455cfb4
feat(DEVING-40): 미팅Form validation관리 파일 생성 및 구현
clyde-yoonjae aaae9fd
feat(DEVING-40): base64 인코딩 변환 유틸 함수 생성
clyde-yoonjae d136b73
feat(DEVING-40): 달력 컴포넌트 구현
clyde-yoonjae 905b65a
feat(DEVING-40): 달력 form-filed 구현
clyde-yoonjae b90d265
feat(DEVING-40): 제목 from-filed 구현
clyde-yoonjae 0908578
feat(DEVING-40): 카테고리 from-filed 구현
clyde-yoonjae 0e4d01e
feat(DEVING-40): 최대정원 from-filed 구현
clyde-yoonjae 9aced32
feat(DEVING-40): 모임장소 from-filed 구현
clyde-yoonjae b10c9e1
feat(DEVING-40): 기술스택 from-filed 구현
clyde-yoonjae 1447ee5
feat(DEVING-40): 모임설명 from-filed 구현
clyde-yoonjae 0daa7a5
feat(DEVING-40): 이미지업로드 from-filed 구현
clyde-yoonjae ee42b65
feat(DEVING-40): 모임공개 여부 from-filed 구현
clyde-yoonjae 3ec94dd
feat(DEVING-40): 가입승인 여부 from-filed 구현
clyde-yoonjae 8db61bd
feat(DEVING-40): form 내부 infoMessage 구현
clyde-yoonjae 95dc4ac
feat(DEVING-40):미팅 form submit button 구현
clyde-yoonjae 48365b2
feat(DEVING-40):미팅 form-filed 인덱스파일 생성
clyde-yoonjae 08edd96
feat(DEVING-40):미팅생성 및 수정form 공용 client컴포넌트 구현
clyde-yoonjae 1955267
feat(DEVING-40):미팅생성 및 수정페이지 server컴포넌트 생성
clyde-yoonjae eb6620a
fix(DEVING-40): edit-page 템플릿코드 추가로 빌드 오류 해결
clyde-yoonjae 696f895
chore(DEVING-40): form생성후 res에 맞는 객체구조로 수정
clyde-yoonjae 3603efb
chore(DEVING-40): memberList한글 입력오류 수정
clyde-yoonjae 30d66f3
chore(DEVING-40): 데이트피커 의존성 삭제
clyde-yoonjae 755b9e3
Merge branch 'dev' into feat/markup/create-meeting/DEVING-40
dbswl701 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,126 @@ | ||
| 'use client'; | ||
|
|
||
| import { | ||
| CategoryField, | ||
| DateField, | ||
| DescriptionField, | ||
| ImageField, | ||
| InfoMessage, | ||
| LocationField, | ||
| MemberLimitField, | ||
| PrivacyField, | ||
| RequireApprovalField, | ||
| SubmitButton, | ||
| TechStackField, | ||
| TitleField, | ||
| } from '@/app/meeting/components/form/form-filed'; | ||
| import useMeetingFormMutation from '@/hooks/mutations/useMeetingFormMutation'; | ||
| import { convertImageToBase64 } from '@/util/base64'; | ||
| import { useRouter } from 'next/navigation'; | ||
| import React from 'react'; | ||
| import { FormProvider, useForm } from 'react-hook-form'; | ||
| import { CreateMeetingPayload } from 'types/meetingForm'; | ||
|
|
||
| import { MEETING_TYPES } from '../../constants/meeting-form/meetingConstants'; | ||
|
|
||
| interface MeetingFormProps { | ||
| mode: 'create' | 'edit'; | ||
| initialData?: Partial<CreateMeetingPayload>; | ||
| meetingId?: string; | ||
| } | ||
|
|
||
| export default function MeetingForm({ | ||
| mode, | ||
| initialData = {}, | ||
| meetingId, | ||
| }: MeetingFormProps) { | ||
| const router = useRouter(); | ||
| const { createMeeting, isLoading } = useMeetingFormMutation(); | ||
|
|
||
| // 날짜 YYYY-MM-DD 형식으로 변환 | ||
| const today = new Date(); | ||
| const formattedToday = `${today.getFullYear()}-${String(today.getMonth() + 1).padStart(2, '0')}-${String(today.getDate()).padStart(2, '0')}`; | ||
|
|
||
| // 카테고리 라벨에서 ID 찾기 (URL 용) | ||
| const getCategoryId = (label: string) => { | ||
| const category = MEETING_TYPES.find((type) => type.label === label); | ||
| return category ? category.id : ''; | ||
| }; | ||
|
|
||
| const defaultValues: CreateMeetingPayload = { | ||
| meetingTitle: '', | ||
| categoryTitle: '', | ||
| imageName: '', | ||
| imageEncodedBase64: '', | ||
| content: '', | ||
| location: '', | ||
| maxMember: 0, | ||
| startDate: formattedToday, | ||
| isPublic: true, | ||
| requireApproval: false, | ||
| skillArray: [], | ||
| ...initialData, | ||
| }; | ||
|
|
||
| const methods = useForm<CreateMeetingPayload>({ | ||
| defaultValues, | ||
| }); | ||
|
|
||
| const { handleSubmit } = methods; | ||
|
|
||
| const onSubmit = async (data: CreateMeetingPayload) => { | ||
| try { | ||
| // 이미지 처리 | ||
| const fileInput = document.getElementById('image') as HTMLInputElement; | ||
| if (fileInput?.files && fileInput.files.length > 0) { | ||
| const imageData = await convertImageToBase64(fileInput.files[0]); | ||
| data.imageName = imageData.name; | ||
| data.imageEncodedBase64 = imageData.base64; | ||
| } | ||
|
|
||
| if (mode === 'create') { | ||
| // 모임 생성 | ||
| const result = await createMeeting.mutateAsync(data); | ||
|
|
||
| // 성공 시 상세 페이지로 이동 | ||
| const categoryId = getCategoryId(data.categoryTitle); | ||
| router.push(`/meeting/${categoryId}/${result.data.meetingId}`); | ||
| } else if (mode === 'edit' && meetingId) { | ||
| // 모임 수정 (TODO: API 구현 시 수정) | ||
| // const result = await updateMeeting.mutateAsync({ id: meetingId, data }); | ||
|
|
||
| // 수정 성공 시 상세 페이지로 이동 | ||
| const categoryId = getCategoryId(data.categoryTitle); | ||
| router.push(`/meeting/${categoryId}/${meetingId}`); | ||
| } | ||
| } catch (error) {} | ||
| }; | ||
|
|
||
| return ( | ||
| <FormProvider {...methods}> | ||
| <div className="mx-auto w-full max-w-3xl p-6"> | ||
| <h1 className="typo-heading1 mb-8 text-center"> | ||
| {mode === 'create' ? '모임 생성하기' : '모임 수정하기'} | ||
| </h1> | ||
|
|
||
| <form onSubmit={handleSubmit(onSubmit)} className="space-y-6"> | ||
| <TitleField required /> | ||
| <CategoryField required /> | ||
| <LocationField required /> | ||
| <DateField required /> | ||
| <MemberLimitField required /> | ||
| <TechStackField maxSelections={5} /> | ||
| <ImageField required={true} /> | ||
| <DescriptionField required /> | ||
| <RequireApprovalField /> | ||
| <PrivacyField /> | ||
| <InfoMessage /> | ||
| <SubmitButton | ||
| text={mode === 'create' ? '모임 생성하기' : '모임 수정하기'} | ||
| isLoading={isLoading} | ||
| /> | ||
| </form> | ||
| </div> | ||
| </FormProvider> | ||
| ); | ||
| } | ||
84 changes: 84 additions & 0 deletions
84
src/app/meeting/components/form/form-filed/CategoryField.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,84 @@ | ||
| import { MEETING_TYPES } from '@/app/meeting/constants/meeting-form/meetingConstants'; | ||
| import { cn } from '@/util/cn'; | ||
| import { Check } from 'lucide-react'; | ||
| import { Controller, useFormContext } from 'react-hook-form'; | ||
| import { CreateMeetingPayload } from 'types/meetingForm'; | ||
|
|
||
| import { meetingTypeValidation } from '../validation'; | ||
|
|
||
| interface CategoryFieldProps { | ||
| required?: boolean; | ||
| } | ||
|
|
||
| const CategoryField = ({ required = true }: CategoryFieldProps) => { | ||
| const { | ||
| control, | ||
| formState: { errors }, | ||
| } = useFormContext<CreateMeetingPayload>(); | ||
|
|
||
| const validation = required | ||
| ? meetingTypeValidation | ||
| : { ...meetingTypeValidation, required: false }; | ||
|
|
||
| return ( | ||
| <div className="space-y-2"> | ||
| <label | ||
| htmlFor="meeting-type-group" | ||
| className="typo-body1 font-medium text-Cgray700" | ||
| > | ||
| 모임 유형 | ||
| </label> | ||
| <Controller | ||
| name="categoryTitle" | ||
| control={control} | ||
| rules={validation} | ||
| render={({ field }) => ( | ||
| <div> | ||
| <div | ||
| className="grid grid-cols-2 gap-3" | ||
| id="meeting-type-group" | ||
| role="radiogroup" | ||
| > | ||
| {MEETING_TYPES.map((type) => ( | ||
| <div | ||
| key={type.id} | ||
| className={cn( | ||
| 'flex cursor-pointer items-center gap-2 rounded-md border p-3 transition-all', | ||
| field.value === type.label | ||
| ? 'border-main bg-default text-main' | ||
| : 'border-Cgray300 text-Cgray500', | ||
| )} | ||
| onClick={() => field.onChange(type.label)} | ||
| onKeyDown={(e) => { | ||
| if (e.key === 'Enter' || e.key === ' ') { | ||
| e.preventDefault(); | ||
| field.onChange(type.label); | ||
| } | ||
| }} | ||
| tabIndex={0} | ||
| role="radio" | ||
| aria-checked={field.value === type.label} | ||
| > | ||
| <div className="flex flex-1 items-center gap-2"> | ||
| {type.icon} | ||
| <span className="typo-body1">{type.label}</span> | ||
| </div> | ||
| {field.value === type.label && ( | ||
| <Check className="ml-auto h-5 w-5 text-main" /> | ||
| )} | ||
| </div> | ||
| ))} | ||
| </div> | ||
| {errors.categoryTitle && ( | ||
| <p className="typo-caption1 mt-[10px] px-[10px] text-warning"> | ||
| {errors.categoryTitle.message} | ||
| </p> | ||
| )} | ||
| </div> | ||
| )} | ||
| /> | ||
| </div> | ||
| ); | ||
| }; | ||
|
|
||
| export default CategoryField; |
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,33 @@ | ||
| import { DatePicker } from '@/components/ui/form/DatePicker'; | ||
| import { useFormContext } from 'react-hook-form'; | ||
| import { CreateMeetingPayload } from 'types/meetingForm'; | ||
|
|
||
| import { startDateValidation } from '../validation'; | ||
|
|
||
| interface DateFieldProps { | ||
| required?: boolean; | ||
| } | ||
|
|
||
| const DateField = ({ required = true }: DateFieldProps) => { | ||
| const { | ||
| formState: { errors }, | ||
| } = useFormContext<CreateMeetingPayload>(); | ||
|
|
||
| const validation = required | ||
| ? startDateValidation | ||
| : { ...startDateValidation, required: false }; | ||
|
|
||
| return ( | ||
| <DatePicker | ||
| id="startDate" | ||
| name="startDate" | ||
| label="시작 날짜" | ||
| placeholder="시작 날짜를 선택해주세요" | ||
| errorMessage={errors.startDate?.message as string} | ||
| required={required} | ||
| validationRules={validation} | ||
| /> | ||
| ); | ||
| }; | ||
|
|
||
| export default DateField; |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
요 부분은 util/date.ts에 같이 정리하면 좋을 것 같아요!
참고
https://discord.com/channels/1326085919555588139/1326085921501614120/1343815718965215252