diff --git a/mock.json b/mock.json index 21fac936..69462e12 100644 --- a/mock.json +++ b/mock.json @@ -17,6 +17,153 @@ "email": "asdf@gmail.coms", "password": "asdfasdf", "id": 7 + }, + { + "nickname": "ㅁㄴㅇㄹ", + "email": "bomaru83@naver.com", + "password": "asdfasdf", + "confirmPassword": "asdfasdf", + "id": 8 + }, + { + "nickname": "ㅁㄴㅇㄹ", + "email": "bomaru83@naver.com", + "password": "asdfasdf", + "confirmPassword": "asdfasdf", + "id": 9 + }, + { + "nickname": "율율", + "email": "asdf@gmail.com", + "password": "asdfasdf", + "confirmPassword": "asdfasdf", + "id": 10 + }, + { + "nickname": "율율", + "email": "asdf@gmail.com", + "password": "asdfasdf", + "confirmPassword": "asdfasdf", + "id": 11 + }, + { + "nickname": "율율", + "email": "asdf@gmail.com", + "password": "asdfasdf", + "confirmPassword": "asdfasdf", + "id": 12 + }, + { + "nickname": "율율", + "email": "asdf@gmail.com", + "password": "asdfasdf", + "confirmPassword": "asdfasdf", + "id": 13 + }, + { + "nickname": "호호", + "email": "hoho@hoho.com", + "password": "hohohoho1", + "confirmPassword": "hohohoho1", + "id": 14 + }, + { + "nickname": "minha", + "email": "minha@test.com", + "password": "test1234", + "confirmPassword": "test1234", + "id": 15 + }, + { + "nickname": "lemon", + "email": "lemon@gmail.com", + "password": "password1234!", + "confirmPassword": "password1234!", + "id": 16 + }, + { + "nickname": "dddd", + "email": "aaa@naver.com", + "password": "@@a1a2a3", + "confirmPassword": "@@a1a2a3", + "id": 17 + }, + { + "nickname": "dddd", + "email": "aaa@naver.com", + "password": "@@a1a2a3", + "confirmPassword": "@@a1a2a3", + "id": 18 + }, + { + "nickname": "dddd", + "email": "aaa@naver.com", + "password": "@@a1a2a3", + "confirmPassword": "@@a1a2a3", + "id": 19 + }, + { + "nickname": "dddd", + "email": "aaa@naver.com", + "password": "@@a1a2a3", + "confirmPassword": "@@a1a2a3", + "id": 20 + }, + { + "nickname": "dddd", + "email": "aaa@naver.com", + "password": "@@a1a2a3", + "confirmPassword": "@@a1a2a3", + "id": 21 + }, + { + "nickname": "dddd", + "email": "aaa@naver.com", + "password": "@@a1a2a3", + "confirmPassword": "@@a1a2a3", + "id": 22 + }, + { + "nickname": "dddd", + "email": "aaa@naver.com", + "password": "@@a1a2a3", + "confirmPassword": "@@a1a2a3", + "id": 23 + }, + { + "nickname": "dddd", + "email": "aaa@naver.com", + "password": "@@a1a2a3", + "confirmPassword": "@@a1a2a3", + "id": 24 + }, + { + "nickname": "dddd", + "email": "aaa@naver.com", + "password": "@@a1a2a3", + "confirmPassword": "@@a1a2a3", + "id": 25 + }, + { + "nickname": "dddd", + "email": "aaa@naver.com", + "password": "@@a1a2a3", + "confirmPassword": "@@a1a2a3", + "id": 26 + }, + { + "nickname": "dddd", + "email": "aaa@naver.com", + "password": "@@a1a2a3", + "confirmPassword": "@@a1a2a3", + "id": 27 + }, + { + "nickname": "dddd", + "email": "aaa@naver.com", + "password": "@@a1a2a3", + "confirmPassword": "@@a1a2a3", + "id": 28 } ], "login": [ @@ -24,6 +171,181 @@ "id": 1, "email": "asdf@gmail.com", "password": "asdfasdf" + }, + { + "email": "asdf@gmail.com", + "password": "asdfasdf", + "id": 2 + }, + { + "email": "sample1@sample.com", + "password": "qwerty1234", + "id": 3 + }, + { + "email": "sample@sample.com", + "password": "qwerty1234", + "id": 4 + }, + { + "email": "abc@abc.com", + "password": "asdf123456", + "id": 5 + }, + { + "email": "asdf@asdf.com", + "password": "asdf123456", + "id": 6 + }, + { + "email": "bomaru83@naver.com", + "password": "ㅁㄴdfasdf", + "id": 7 + }, + { + "email": "bomaru83@naver.co", + "password": "asdfasdf", + "id": 8 + }, + { + "email": "bomaru83@naver.com", + "password": "asdfasdf", + "id": 9 + }, + { + "email": "asdf@asdf.com", + "password": "asdf12345", + "id": 10 + }, + { + "email": "abc@gmail.co", + "password": "asdfggjk", + "id": 11 + }, + { + "email": "sample@sample.com", + "password": "qwerty1234", + "id": 12 + }, + { + "email": "sample@sample.com", + "password": "qwerty1234", + "id": 13 + }, + { + "email": "Asdf@asdf.com", + "password": "asdf123456", + "id": 14 + }, + { + "email": "bomaru83@naver.com", + "password": "asdfasdf", + "id": 15 + }, + { + "email": "spfesi0401@codeit.com", + "password": "asdfasdf", + "id": 16 + }, + { + "email": "asdf@gmail.com", + "password": "asdfasdf", + "id": 17 + }, + { + "email": "asdf@gmail.com", + "password": "asdfasdf", + "id": 18 + }, + { + "email": "asdf@gmail.com", + "password": "password", + "id": 19 + }, + { + "email": "asdf@gmail.com", + "password": "asdfasdf", + "id": 20 + }, + { + "email": "asdf@gmail.com", + "password": "asdfasdf", + "id": 21 + }, + { + "email": "asdf@gmail.com", + "password": "asdfasdf", + "id": 22 + }, + { + "email": "asdf@gmail.com", + "password": "asdfasdf", + "id": 23 + }, + { + "email": "sample@sample.com", + "password": "qwerty1234", + "id": 24 + }, + { + "email": "sample@sample.com", + "password": "qwerty1234", + "id": 25 + }, + { + "email": "juepark42@gmail.com", + "password": "fakepassword^^", + "id": 26 + }, + { + "email": "bomaru83@naver.com", + "password": "asdfasdf", + "id": 27 + }, + { + "email": "abc@abc.com", + "password": "asdf12345", + "id": 28 + }, + { + "email": "bomaru83@naver.co", + "password": "asdfasdf", + "id": 29 + }, + { + "email": "juepark42@gmail.com", + "password": "fakepassword^^", + "id": 30 + }, + { + "email": "asdf@gmail.com", + "password": "asdfasdf", + "id": 31 + }, + { + "email": "asdf@gmail.com", + "password": "asdfasdf", + "id": 32 + }, + { + "email": "aaa@naver.com", + "password": "@@a1a2a3", + "id": 33 + }, + { + "email": "aaa@naver.com", + "password": "@@a1a2a3", + "id": 34 + }, + { + "email": "asdfasd@afasd.sddafc", + "password": "asdfasdfasdfsd", + "id": 35 + }, + { + "email": "sdaf@asdf.asdf", + "password": "asdfafsd", + "id": 36 } ], "user": [ @@ -37,8 +359,8 @@ "crews": [ { "id": 1, - "type": "유산소", - "subType": "달리기", + "type": "유산소/근력", + "subType": "러닝", "name": "매일 달릴사람!", "location": "서울특별시", "detailedLocation": "강남구", @@ -50,188 +372,188 @@ } ], "createdBy": 1, - "createdDate": "2024-11-04T00:00:00.000Z", - "updatedDate": "2024-11-05T00:00:00.000Z", + "createdDate": "2024-11-04T10:09:12.306+09:00", + "updatedDate": "2024-11-05T10:09:12.306+09:00", "isConfirmed": true, "gatheringCount": 4 }, { "id": 2, - "type": "유산소", - "subType": "달리기", - "name": "2같이 달릴사람 구함", - "location": "광주", - "detailedLocation": "어디구 어디로", + "type": "유산소/근력", + "subType": "러닝", + "name": "광교호수공원 러닝크루 구합니다", + "location": "경기도", + "detailedLocation": "수원시", "participantCount": 10, "capacity": 20, "images": [ { - "imagePath": "https://i.pinimg.com/564x/f8/8d/c5/f88dc5b857caf6c303ae5ef9dd12e7fb.jpg" + "imagePath": "https://img.hankyung.com/photo/202209/f8b44f8bbe2a703573e176387b1296a0.jpg" } ], "createdBy": 1, - "createdDate": "2024-11-04T00:00:00.000Z", - "updatedDate": "2024-11-05T00:00:00.000Z", + "createdDate": "2024-11-04T10:09:12.306+09:00", + "updatedDate": "2024-11-05T10:09:12.306+09:00", "isConfirmed": true, "gatheringCount": 3 }, { "id": 3, - "type": "유산소", - "subType": "달리기", - "name": "3같이 달릴사람 구함", - "location": "부산", - "detailedLocation": "어디구 어디로", + "type": "유연성", + "subType": "요가", + "name": "힐링 요가 크루입니다", + "location": "부산광역시", + "detailedLocation": "남구", "participantCount": 1, "capacity": 5, "images": [ { - "imagePath": "https://i.pinimg.com/564x/f8/8d/c5/f88dc5b857caf6c303ae5ef9dd12e7fb.jpg" + "imagePath": "https://cdn.imweb.me/thumbnail/20230607/82966d0f2d0e1.png" } ], "createdBy": 2, - "createdDate": "2024-11-04T00:00:00.000Z", - "updatedDate": "2024-11-05T00:00:00.000Z", + "createdDate": "2024-11-04T10:09:12.306+09:00", + "updatedDate": "2024-11-05T10:09:12.306+09:00", "isConfirmed": false, "gatheringCount": 3 }, { "id": 4, - "type": "유산소", - "subType": "달리기", - "name": "4같이 달릴사람 구함", - "location": "부산", - "detailedLocation": "어디구 어디로", + "type": "유산소/근력", + "subType": "등산", + "name": "30대 인천 등산모임", + "location": "인천광역시", + "detailedLocation": "부평구", "participantCount": 1, "capacity": 20, "images": [ { - "imagePath": "https://i.pinimg.com/564x/f8/8d/c5/f88dc5b857caf6c303ae5ef9dd12e7fb.jpg" + "imagePath": "https://i.namu.wiki/i/z4SlzF00Hi7dzXpkkj_mdNnXyY2WTHD6hmxzCks5e6PxQ7KwHosVlzQatl42tPiui_EICYUhL-iEBxxbRQUN7w.webp" } ], "createdBy": 2, - "createdDate": "2024-11-04T00:00:00.000Z", - "updatedDate": "2024-11-05T00:00:00.000Z", + "createdDate": "2024-11-04T10:09:12.306+09:00", + "updatedDate": "2024-11-05T10:09:12.306+09:00", "isConfirmed": false, "gatheringCount": 3 }, { "id": 5, - "type": "유산소", - "subType": "달리기", - "name": "5같이 달릴사람 구함", - "location": "부산", - "detailedLocation": "어디구 어디로", + "type": "구기종목", + "subType": "축구", + "name": "축구할사람 모집합니다", + "location": "서울특별시", + "detailedLocation": "마포구", "participantCount": 1, "capacity": 20, "images": [ { - "imagePath": "https://i.pinimg.com/564x/f8/8d/c5/f88dc5b857caf6c303ae5ef9dd12e7fb.jpg" + "imagePath": "https://www.ksponco.or.kr/sports/img/olparksoccer/know_3.png" } ], "createdBy": 2, - "createdDate": "2024-11-04T00:00:00.000Z", - "updatedDate": "2024-11-05T00:00:00.000Z", + "createdDate": "2024-11-04T10:09:12.306+09:00", + "updatedDate": "2024-11-05T10:09:12.306+09:00", "isConfirmed": false, "gatheringCount": 5 }, { "id": 6, - "type": "유산소", - "subType": "달리기", - "name": "6같이 달릴사람 구함", - "location": "광주", - "detailedLocation": "어디구 어디로", + "type": "유산소/근력", + "subType": "클라이밍", + "name": "한계에 도전하는 클라이밍 모임", + "location": "경기도", + "detailedLocation": "수원시", "participantCount": 10, "capacity": 20, "images": [ { - "imagePath": "https://i.pinimg.com/564x/f8/8d/c5/f88dc5b857caf6c303ae5ef9dd12e7fb.jpg" + "imagePath": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQ33qODhVM0rvTqrzWHaeLe3ESODcSHNiYrsg&s" } ], "createdBy": 1, - "createdDate": "2024-11-04T00:00:00.000Z", - "updatedDate": "2024-11-05T00:00:00.000Z", + "createdDate": "2024-11-04T10:09:12.306+09:00", + "updatedDate": "2024-11-05T10:09:12.306+09:00", "isConfirmed": true, "gatheringCount": 5 }, { "id": 7, - "type": "유산소", - "subType": "수영", - "name": "7엄청긴크루이름엄청긴크루이름엄청긴크루이름엄청긴크루이름", + "type": "유연성", + "subType": "폴댄스", + "name": "폴킴 아닙니다 폴댄스", "location": "경기도", - "detailedLocation": "어디구 어디로", + "detailedLocation": "고양시", "participantCount": 20, "capacity": 24, "images": [ { - "imagePath": "https://i.pinimg.com/564x/f8/8d/c5/f88dc5b857caf6c303ae5ef9dd12e7fb.jpg" + "imagePath": "https://i.pinimg.com/474x/59/55/b0/5955b0be1eb8c9bd8204f339db1befac.jpg" } ], "createdBy": 1, - "createdDate": "2024-11-04T00:00:00.000Z", - "updatedDate": "2024-11-05T00:00:00.000Z", + "createdDate": "2024-11-04T10:09:12.306+09:00", + "updatedDate": "2024-11-05T10:09:12.306+09:00", "isConfirmed": true, "gatheringCount": 5 }, { "id": 8, - "type": "유산소", - "subType": "달리기", - "name": "8같이 달릴사람 구함", - "location": "광주", - "detailedLocation": "어디구 어디로", + "type": "기타", + "subType": "서핑", + "name": "같이 서핑하실분", + "location": "부산광역시", + "detailedLocation": "해운대구", "participantCount": 10, "capacity": 20, "images": [ { - "imagePath": "https://i.pinimg.com/564x/f8/8d/c5/f88dc5b857caf6c303ae5ef9dd12e7fb.jpg" + "imagePath": "https://i.pinimg.com/736x/84/aa/da/84aada701c873c7451b38ec44b725dad.jpg" } ], "createdBy": 1, - "createdDate": "2024-11-04T00:00:00.000Z", - "updatedDate": "2024-11-05T00:00:00.000Z", + "createdDate": "2024-11-04T10:09:12.306+09:00", + "updatedDate": "2024-11-05T10:09:12.306+09:00", "isConfirmed": true, "gatheringCount": 5 }, { "id": 9, - "type": "유산소", - "subType": "달리기", - "name": "9같이 달릴사람 구함", - "location": "부산", - "detailedLocation": "어디구 어디로", + "type": "기타", + "subType": "아이스스케이트", + "name": "빙글빙글 스케이트", + "location": "경기도", + "detailedLocation": "수원시", "participantCount": 1, "capacity": 5, "images": [ { - "imagePath": "https://i.pinimg.com/564x/f8/8d/c5/f88dc5b857caf6c303ae5ef9dd12e7fb.jpg" + "imagePath": "https://img.freepik.com/free-photo/portrait-person-ice-skating-outdoors-winter-time_23-2151396912.jpg" } ], "createdBy": 2, - "createdDate": "2024-11-04T00:00:00.000Z", - "updatedDate": "2024-11-05T00:00:00.000Z", + "createdDate": "2024-11-04T10:09:12.306+09:00", + "updatedDate": "2024-11-05T10:09:12.306+09:00", "isConfirmed": false, "gatheringCount": 5 }, { "id": 10, - "type": "유산소", - "subType": "수영", - "name": "10엄청긴크루이름엄청긴크루이름엄청긴크루이름엄청긴크루이름", - "location": "경기도", - "detailedLocation": "어디구 어디로", + "type": "유산소/근력", + "subType": "헬스", + "name": "건강한 신체에 건강한 정신", + "location": "서울특별시", + "detailedLocation": "강북구", "participantCount": 20, "capacity": 24, "images": [ { - "imagePath": "https://i.pinimg.com/564x/f8/8d/c5/f88dc5b857caf6c303ae5ef9dd12e7fb.jpg" + "imagePath": "https://img.freepik.com/free-photo/gym-with-indoor-cycling-equipment_23-2149270210.jpg" } ], "createdBy": 1, - "createdDate": "2024-11-04T00:00:00.000Z", - "updatedDate": "2024-11-05T00:00:00.000Z", + "createdDate": "2024-11-04T10:09:12.306+09:00", + "updatedDate": "2024-11-05T10:09:12.306+09:00", "isConfirmed": true, "gatheringCount": 3 } @@ -250,7 +572,10 @@ "isCaptain": true, "isCrew": true, "CrewMembers": [ - { "id": 1, "nickname": "이름1" }, + { + "id": 1, + "nickname": "이름1" + }, { "id": 2, "nickname": "이름2", @@ -278,7 +603,7 @@ { "id": 101, "title": "신나는 운동...즐거운..코딩..", - "dateTime": "2024-11-29T00:32:12.306Z", + "dateTime": "2024-11-09T10:30:12.306+09:00", "location": "서울시 강남구 역삼동 오피스타워 3층", "currentCount": 3, "totalCount": 10, @@ -288,7 +613,7 @@ { "id": 102, "title": "등산 모임", - "dateTime": "2024-11-12T09:00", + "dateTime": "2024-11-12T10:30:12.306+09:00", "location": "서울 강남구 개포동 대모산", "currentCount": 5, "totalCount": 10, @@ -298,7 +623,7 @@ { "id": 103, "title": "등산 모임", - "dateTime": "2024-11-15T09:00", + "dateTime": "2024-11-15T10:30:12.306+09:00", "location": "경기 과천시 중앙동 관악산", "currentCount": 10, "totalCount": 10, @@ -308,7 +633,7 @@ { "id": 104, "title": "등산 모임", - "dateTime": "2024-11-12T09:00", + "dateTime": "2024-11-17T10:30:12.306+09:00", "location": "아차산", "currentCount": 2, "totalCount": 4, @@ -318,7 +643,7 @@ { "id": 105, "title": "러닝", - "dateTime": "2024-11-12T09:00", + "dateTime": "2024-11-18T10:30:12.306+09:00", "location": "서울 영등포구 여의동로 330 한강사업본부 여의도안내센터", "currentCount": 0, "totalCount": 20, @@ -331,7 +656,7 @@ "id": 1, "title": "신나는 운동...즐거운..코딩..", "introduce": "공지사항입니다. 다들 이번 약속 잊지 않으셨죠? 꼭 참여 부탁드립니다~", - "dateTime": "2024-10-29T00:32:12.306Z", + "dateTime": "2024-11-09T10:30:12.306+09:00", "location": "서울시 강남구 역삼동 오피스타워 3층", "currentCount": 3, "totalCount": 10, @@ -367,7 +692,7 @@ "id": 1, "rate": 5, "comment": "글이 길어질 경우 글이 길어질 경우 확인 글이 길어질 경우 글이 길어질 경우 글이 길어질 경우 글이 길어질 경우 글이 길어질 경우 글이 길어질 경우 글이 길어질 경우 글이 길어질 경우 글이 길어질 경우 글이 길어질 경우 글이 길어질 경우 글이 길어질 경우 글이 길어질 경우 글이 길어질 경우 글이 길어질 경우 글이 길어질 경우 글이 길어질 경우 글이 길어질 경우 최고의 모임~", - "createdAt": "2024-10-30T00:30", + "createdAt": "2024-11-09T10:30:12.306+09:00", "reviewer": { "id": 1, "nickname": "샘플1", @@ -379,7 +704,7 @@ "id": 2, "rate": 2, "comment": "솔직히 좀 별로..", - "createdAt": "2024-10-30T00:34", + "createdAt": "2024-11-15T10:30:12.306+09:00", "reviewer": { "id": 2, "nickname": "샘플2", @@ -391,7 +716,7 @@ "id": 3, "rate": 5, "comment": "진짜 좋은 모임이었다.. 굿", - "createdAt": "2024-10-30T00:50", + "createdAt": "2024-11-20T10:30:12.306+09:00", "reviewer": { "id": 3, "nickname": "샘플3", @@ -403,7 +728,7 @@ "id": 4, "rate": 5, "comment": "모임계를 뒤집어 엎으셨다", - "createdAt": "2024-10-30T00:52", + "createdAt": "2024-11-29T10:30:12.306+09:00", "reviewer": { "id": 4, "nickname": "샘플4", @@ -415,7 +740,7 @@ "id": 5, "rate": 4, "comment": "좋아용", - "createdAt": "2024-10-31T00:52", + "createdAt": "2024-11-29T10:30:12.306+09:00", "reviewer": { "id": 5, "nickname": "샘플5", @@ -427,7 +752,7 @@ "id": 6, "rate": 1, "comment": "별로였음", - "createdAt": "2024-10-31T00:52", + "createdAt": "2024-11-29T10:30:12.306+09:00", "reviewer": { "id": 6, "nickname": "샘플6", @@ -439,7 +764,7 @@ "id": 7, "rate": 4, "comment": "나만 좋았냐", - "createdAt": "2024-10-31T00:54", + "createdAt": "2024-11-30T10:30:12.306+09:00", "reviewer": { "id": 7, "nickname": "샘플7", @@ -447,4 +772,4 @@ } } ] -} +} \ No newline at end of file diff --git a/next.config.mjs b/next.config.mjs index f74fc3b6..efd2c845 100644 --- a/next.config.mjs +++ b/next.config.mjs @@ -17,7 +17,7 @@ const nextConfig = { { key: 'Access-Control-Allow-Origin', value: - process.env.NEXT_PUBLIC_API_URL || 'https://foggy-sideways-saltasaurus.glitch.me/', + process.env.NEXT_PUBLIC_API_BASE_URL || 'https://foggy-sideways-saltasaurus.glitch.me/', }, { key: 'Access-Control-Allow-Methods', value: 'GET,OPTIONS,PATCH,DELETE,POST,PUT' }, diff --git a/src/app/(crew)/crew/_components/create-crew-form/index.tsx b/src/app/(crew)/crew/_components/create-crew-form/index.tsx index 9c1827d9..f197b632 100644 --- a/src/app/(crew)/crew/_components/create-crew-form/index.tsx +++ b/src/app/(crew)/crew/_components/create-crew-form/index.tsx @@ -31,9 +31,9 @@ export default function CreateCrewForm({ control, handleSubmit, setValue, - getValues, + trigger, clearErrors, - formState: { errors, isValid }, + formState: { errors, isValid, isSubmitting }, } = useForm({ defaultValues: data, mode: 'onBlur', @@ -89,6 +89,10 @@ export default function CreateCrewForm({ {...field} id="crew-title" variant="filled" + onChange={(e) => { + field.onChange(e); + if (errors.title) trigger('title'); // 입력 중일 때 유효성 검사 트리거 + }} error={errors.title?.message} placeholder="크루명을 20자 이내로 입력해주세요." maxLength={20} @@ -125,6 +129,7 @@ export default function CreateCrewForm({ field.onChange(value); handleMainCategoryChange(value); }} + error={errors.mainCategory?.message} /> )} /> @@ -139,11 +144,11 @@ export default function CreateCrewForm({ placeholder="세부 카테고리" data={categoryData[categoryIndex]?.items || []} className="flex-1" + error={errors.subCategory?.message} /> )} /> - {errors.mainCategory &&

{errors.mainCategory.message}

}
@@ -153,12 +158,29 @@ export default function CreateCrewForm({ + file && file instanceof File && file.size <= 5242880 + ? true + : '파일 크기는 5MB 이하여야 합니다.', + fileType: (file) => + file && + file instanceof File && + ['image/jpeg', 'image/jpg', 'image/png'].includes(file.type) + ? true + : 'JPG, PNG 파일만 업로드 가능합니다.', + }, + }} render={({ field }) => ( field.onChange(newValue)} + onChange={(newValue) => { + field.onChange(newValue); + if (newValue instanceof File) trigger('imageUrl'); + }} /> )} /> @@ -189,12 +211,14 @@ export default function CreateCrewForm({ field.onChange(value); handleMainLocationChange(value); }} + error={errors.mainLocation?.message} /> )} /> ( )} />
- {errors.mainLocation &&

{errors.mainLocation.message}

}
@@ -230,6 +254,7 @@ export default function CreateCrewForm({ variant="filled" min={4} max={20} + error={errors.totalCount?.message} classNames={{ input: 'h-11 py-2.5 px-4 bg-gray-100 placeholder:text-gray-400 font-pretendard text-base font-medium rounded-xl', @@ -238,13 +263,12 @@ export default function CreateCrewForm({ /> )} /> - {errors.totalCount &&

{errors.totalCount.message}

}
- trigger('title'), - }), - }} - error={errors.title?.message?.toString()} - onChange={(e) => - setValues((prevValues) => { - if (e.target.value.length <= 20) { - return { ...prevValues, title: e.target.value }; - } - return prevValues; - }) - } - placeholder="약속 이름을 20자 이내로 입력해주세요." - maxLength={20} - classNames={{ - input: - 'h-11 py-2.5 px-4 bg-gray-100 placeholder:text-gray-400 font-pretendard text-base font-medium rounded-xl aria-[invalid=true]:border-none', + ( + { + field.onChange(e); + if (errors.title) trigger('title'); // 입력 중일 때 유효성 검사 트리거 + }} + error={errors.title?.message} + placeholder="약속명을 20자 이내로 입력해주세요." + maxLength={20} + classNames={{ + input: + 'h-11 py-2.5 px-4 bg-gray-100 placeholder:text-gray-400 font-pretendard text-base font-medium rounded-xl aria-[invalid=true]:border-none', + }} + /> + )} />
@@ -89,14 +81,37 @@ export default function CreateGatheringForm({ 이미지 선택/첨부
- - setValues((prevValues) => ({ ...prevValues, imageUrl: newValue })) - } + + file && file instanceof File && file.size <= 5242880 + ? true + : '파일 크기는 5MB 이하여야 합니다.', + fileType: (file) => + file && + file instanceof File && + ['image/jpeg', 'image/jpg', 'image/png'].includes(file.type) + ? true + : 'JPG, PNG 파일만 업로드 가능합니다.', + }, + }} + render={({ field }) => ( + { + field.onChange(newValue); + if (newValue instanceof File) trigger('imageUrl'); + }} + /> + )} />
+ {errors.imageUrl &&

{errors.imageUrl.message}

}
@@ -104,35 +119,33 @@ export default function CreateGatheringForm({ 장소 - {values.location.length}/20 + {location.length}/20
- trigger('location'), - }), - }} - error={errors.location?.message?.toString()} - onChange={(e) => - setValues((prevValues) => { - if (e.target.value.length <= 20) { - return { ...prevValues, location: e.target.value }; - } - return prevValues; - }) - } - placeholder="자세한 주소를 입력해주세요." - maxLength={20} - classNames={{ - input: - 'h-11 py-2.5 px-4 bg-gray-100 placeholder:text-gray-400 font-pretendard text-base font-medium rounded-xl aria-[invalid=true]:border-none', + ( + { + field.onChange(e); + if (errors.location) trigger('location'); // 입력 중일 때 유효성 검사 트리거 + }} + error={errors.location?.message} + placeholder="약속명을 20자 이내로 입력해주세요." + maxLength={20} + classNames={{ + input: + 'h-11 py-2.5 px-4 bg-gray-100 placeholder:text-gray-400 font-pretendard text-base font-medium rounded-xl aria-[invalid=true]:border-none', + }} + /> + )} />
@@ -141,46 +154,49 @@ export default function CreateGatheringForm({ 날짜
- - setValues((prevValues) => ({ - ...prevValues, - dateTime: date.toLocaleString(), - })) - } + ( + { + const formattedDate = date.toLocaleString(); + onChange(formattedDate); + trigger('dateTime'); // 유효성 검사 실행 + }} + /> + )} />
- trigger('totalCount'), - })} + - setValues((prevValues) => ({ ...prevValues, totalCount: Number(newValue) })) - } - placeholder="자세한 모집 정원을 입력해주세요." - min={4} - max={20} - classNames={{ - input: - 'h-11 py-2.5 px-4 bg-gray-100 placeholder:text-gray-400 font-pretendard text-base font-medium rounded-xl', + control={control} + rules={{ + required: '모집 정원을 입력해주세요.', }} + render={({ field }) => ( + + )} /> - {errors.totalCount && ( -

- 4명 이상 20명 이하로 입력해주세요. -

- )}
@@ -188,23 +204,26 @@ export default function CreateGatheringForm({ 모집 설명/공지 - {values.introduce.length}/100 + {introduce.length}/100
-