diff --git a/package.json b/package.json index c962cb80..b572eba0 100644 --- a/package.json +++ b/package.json @@ -33,6 +33,7 @@ "path": "^0.12.7", "react": "^18.2.0", "react-beautiful-dnd": "^13.1.1", + "react-device-detect": "^2.2.3", "react-dom": "^18.2.0", "react-hook-form": "^7.49.2", "react-icons": "^5.0.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index abcef86b..95225e8f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -74,6 +74,9 @@ dependencies: react-beautiful-dnd: specifier: ^13.1.1 version: 13.1.1(react-dom@18.2.0)(react@18.2.0) + react-device-detect: + specifier: ^2.2.3 + version: 2.2.3(react-dom@18.2.0)(react@18.2.0) react-dom: specifier: ^18.2.0 version: 18.2.0(react@18.2.0) @@ -5139,6 +5142,17 @@ packages: - react-native dev: false + /react-device-detect@2.2.3(react-dom@18.2.0)(react@18.2.0): + resolution: {integrity: sha512-buYY3qrCnQVlIFHrC5UcUoAj7iANs/+srdkwsnNjI7anr3Tt7UY6MqNxtMLlr0tMBied0O49UZVK8XKs3ZIiPw==} + peerDependencies: + react: '>= 0.14.0' + react-dom: '>= 0.14.0' + dependencies: + react: 18.2.0 + react-dom: 18.2.0(react@18.2.0) + ua-parser-js: 1.0.37 + dev: false + /react-dom@18.2.0(react@18.2.0): resolution: {integrity: sha512-6IMTriUmvsjHUjNtEDudZfuDQUoWXVxKHhlEGSk81n4YFS+r/Kl99wXiwlVXtPBtJenozv2P+hxDsw9eA7Xo6g==} peerDependencies: @@ -5900,6 +5914,10 @@ packages: engines: {node: '>=14.17'} hasBin: true + /ua-parser-js@1.0.37: + resolution: {integrity: sha512-bhTyI94tZofjo+Dn8SN6Zv8nBDvyXTymAdM3LDI/0IboIUwTu1rEhW7v2TfiVsoYWgkQ4kOVqnI8APUFbIQIFQ==} + dev: false + /undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} dev: false diff --git a/src/api/socket.ts b/src/api/socket.ts index 2f22446e..978ae336 100644 --- a/src/api/socket.ts +++ b/src/api/socket.ts @@ -125,6 +125,7 @@ export const pubUpdateTransportation = ( destination: `/pub/trips/${tripId}/updateTransportation`, body: JSON.stringify(pubUpdateTransportation), }); + console.log('펍실행'); }; // 여행 아이템 방문 날짜 변경 이벤트 발생시 diff --git a/src/components/Auth/AuthInput/AuthInputBox/AuthInputItem/AuthInput.tsx b/src/components/Auth/AuthInput/AuthInputBox/AuthInputItem/AuthInput.tsx index 6a6ea0f9..94943892 100644 --- a/src/components/Auth/AuthInput/AuthInputBox/AuthInputItem/AuthInput.tsx +++ b/src/components/Auth/AuthInput/AuthInputBox/AuthInputItem/AuthInput.tsx @@ -33,7 +33,7 @@ const AuthInput = ({ return (
-
diff --git a/src/components/DetailSectionBottom/ReviewItem.tsx b/src/components/DetailSectionBottom/ReviewItem.tsx index c11e040e..2ff1c349 100644 --- a/src/components/DetailSectionBottom/ReviewItem.tsx +++ b/src/components/DetailSectionBottom/ReviewItem.tsx @@ -151,51 +151,41 @@ const Item: React.FC = (props: ReviewInfoItemProps) => {
{!showMoreKeywords && - keywords.slice(0, 2).map((keyword, idx) => ( + keywords.slice(0, 1).map((keyword, idx) => (
{getEmoji(keyword.content)} {keyword.content}
))} - {keywords.length > 2 && !showMoreKeywords && ( + {keywords.length > 1 && !showMoreKeywords && (
{ handleClickPlusButton(e); }}> - +{keywords.length - 2} + +{keywords.length - 1}
)}
+
- {showMoreKeywords && - Array.from({ length: Math.ceil(keywords.length / 2) }).map( - (_, lineIdx) => ( + {showMoreKeywords && ( +
+ {keywords.map((keyword, idx) => (
- {keywords - .slice(lineIdx * 2, lineIdx * 2 + 2) - .map((keyword, idx) => ( -
- {getEmoji(keyword.content)} {keyword.content} -
- ))} + key={idx} + className="rounded-md bg-gray1 px-2 py-1 text-xs text-gray6"> + {getEmoji(keyword.content)} {keyword.content}
- ), - )} + ))} +
+ )}
-
+
-
{commentCount}
+
{commentCount}
diff --git a/src/components/DetailSectionTop/DetailAddSchedule.tsx b/src/components/DetailSectionTop/DetailAddSchedule.tsx index 0b39bba6..e976a48c 100644 --- a/src/components/DetailSectionTop/DetailAddSchedule.tsx +++ b/src/components/DetailSectionTop/DetailAddSchedule.tsx @@ -265,9 +265,9 @@ const DetailAddSchedule = () => { title={'로그인'} message={ <> - 새로운 여행 생성 시 로그인이 필요합니다. + 여정에 추가하려면 로그인이 필요해요.
- 로그인 하시겠습니까? + 로그인하러 가볼까요? } onConfirm={() => handleNavigate('/login')}> diff --git a/src/components/MyTrip/MyTrip.tsx b/src/components/MyTrip/MyTrip.tsx index c80f12fc..1062e245 100644 --- a/src/components/MyTrip/MyTrip.tsx +++ b/src/components/MyTrip/MyTrip.tsx @@ -30,9 +30,9 @@ const MyTrip = () => { const { ingTrips, beforeTrips, afterTrips } = classifyTrips(data); return ( -
-
-

나의 여정

+
+
+

나의 여정

{data.length > 0 ? ( <> diff --git a/src/components/MyTrip/MyTripAfterList.tsx b/src/components/MyTrip/MyTripAfterList.tsx index c5d65cb4..c7ddd74c 100644 --- a/src/components/MyTrip/MyTripAfterList.tsx +++ b/src/components/MyTrip/MyTripAfterList.tsx @@ -19,16 +19,16 @@ const MyTripAfterList: React.FC = ({ myTripsData }) => { if (sortedTrips.length > 0) { return ( - <> -
+
+

지난 여행

-
+
{sortedTrips.map((myTripList: MyTripType) => ( ))}
- +
); } else { return null; diff --git a/src/components/MyTrip/MyTripBeforeList.tsx b/src/components/MyTrip/MyTripBeforeList.tsx index 88dc770f..c6792597 100644 --- a/src/components/MyTrip/MyTripBeforeList.tsx +++ b/src/components/MyTrip/MyTripBeforeList.tsx @@ -12,18 +12,22 @@ const MyTripBeforeList: React.FC = ({ myTripsData }) => { return
데이터를 불러오는 중 오류가 발생했습니다.
; } - return ( - <> -
-

다가오는 여행

+ if (myTripsData.length > 0) { + return ( +
+
+

다가오는 여행

+
+
+ {myTripsData.map((myTripList: MyTripType) => ( + + ))} +
-
- {myTripsData.map((myTripList: MyTripType) => ( - - ))} -
- - ); + ); + } else { + return null; + } }; export default MyTripBeforeList; diff --git a/src/components/MyTrip/MyTripIngItem.tsx b/src/components/MyTrip/MyTripIngItem.tsx index e054b93f..328a80d0 100644 --- a/src/components/MyTrip/MyTripIngItem.tsx +++ b/src/components/MyTrip/MyTripIngItem.tsx @@ -16,7 +16,7 @@ const MyTripIngItem: React.FC = ({ myTripList }) => {
navigate(`/trip/${tripId}`)}> -
+
= ({ myTripList }) => { alt="여행지 이미지" />
-
+
{tripStatus}
-
+
{tripName}
-
+
{startDate.replace(/-/g, '.')} -{' '} {endDate.replace(/-/g, '.').split('2024.')}{' '} {tripDuration === '0박 1일' ? null : ` (${tripDuration})`} diff --git a/src/components/MyTrip/MyTripIngList.tsx b/src/components/MyTrip/MyTripIngList.tsx index 758a4f71..01cf3210 100644 --- a/src/components/MyTrip/MyTripIngList.tsx +++ b/src/components/MyTrip/MyTripIngList.tsx @@ -14,7 +14,7 @@ const MyTripIngList: React.FC = ({ myTripsData }) => { return ( <> -
+
{myTripsData.map((myTripList: MyTripType) => ( ))} diff --git a/src/components/MyTrip/MyTripItem.tsx b/src/components/MyTrip/MyTripItem.tsx index 7776541d..4fe80cce 100644 --- a/src/components/MyTrip/MyTripItem.tsx +++ b/src/components/MyTrip/MyTripItem.tsx @@ -54,7 +54,7 @@ const MyTripItem: React.FC = ({ myTripList }) => {
navigate(`/trip/${tripId}`)}>
@@ -64,8 +64,8 @@ const MyTripItem: React.FC = ({ myTripList }) => { alt="여행지 이미지" />
-
-
+
+
{tripName}
@@ -76,7 +76,7 @@ const MyTripItem: React.FC = ({ myTripList }) => {
-
+
{numberOfTripMember}명과 공유중
diff --git a/src/components/Mypage/UserInfoForm.tsx b/src/components/Mypage/UserInfoForm.tsx index 6126a244..8cedc7e4 100644 --- a/src/components/Mypage/UserInfoForm.tsx +++ b/src/components/Mypage/UserInfoForm.tsx @@ -4,11 +4,12 @@ import { Link, useNavigate } from 'react-router-dom'; import { useRecoilValue } from 'recoil'; import { UserInfoState } from '@recoil/Auth.atom'; import { useEffect } from 'react'; -import SubmitBtn from '@components/common/button/SubmitBtn'; import UserInfoImg from '@components/Auth/SignupInfo/UserInfoImg'; import AuthNicknameInputBox from '@components/Auth/AuthInput/AuthInputBox/AuthNicknameInputBox'; import AuthDropDown from '@components/Auth/SignupInfo/AuthDropDown/AuthDropDown'; import { ageArr, genderArr } from '@utils/authSelectOptions'; +import { BackBox } from '@components/common'; +import DeleteMemberButton from './DeleteMemberButton'; const UserInfoForm = () => { const { @@ -53,52 +54,66 @@ const UserInfoForm = () => { }; return ( -
-
-
- -
-
-
- {userInfo?.email} + <> + { + navigate('/mypage'); + }} + showSave + isSaveValid={isValid} + saveHandler={handleSubmit(onInfoSubmit)}> + 회원정보 수정 + +
+ +
+
+ +
+
+
+ {userInfo?.email} +
+ + 비밀번호 변경 + +
+ +
+ + +
- - 비밀번호 변경 - -
- -
- - -
+ +
-
- 완료 -
- + ); }; diff --git a/src/components/Plan/PlanEditItemBox.tsx b/src/components/Plan/PlanEditItemBox.tsx index c1a3fa98..a52064b0 100644 --- a/src/components/Plan/PlanEditItemBox.tsx +++ b/src/components/Plan/PlanEditItemBox.tsx @@ -6,7 +6,7 @@ import { Draggable, DropResult, } from 'react-beautiful-dnd'; -import { useState, useEffect } from 'react'; +import { useState, useEffect, useCallback } from 'react'; import { pubUpdateTripItem, pubDeleteItem } from '@api/socket'; import { pubUpdateTripItemReq } from '@/@types/service'; import Alert from '@components/common/alert/Alert'; @@ -35,7 +35,6 @@ const PlanEditItemBox = ({ const [, setIsEdit] = useRecoilState(isEditState); const [items, setItems] = useState(item); - const [newData, setNewData] = useState(null); const [selectedItemId, setSelectedItemId] = useState(null); const [toastPopUp, setToastPopUp] = useState({ isPopUp: false, @@ -43,6 +42,13 @@ const PlanEditItemBox = ({ verb: '', }); + const debouncedPubUpdateTripItem = useCallback( + debounce((newData: pubUpdateTripItemReq, tripId: string) => { + pubUpdateTripItem(newData, tripId); + }, 3000), + [], + ); + const onDragEnd = (result: DropResult) => { if (!result.destination) return; const reorderedItems = Array.from(items); @@ -55,22 +61,9 @@ const PlanEditItemBox = ({ seqNum: index + 1, })); - setNewData({ - visitDate: visitDate, - tripItemOrder, - }); + debouncedPubUpdateTripItem({ visitDate: visitDate, tripItemOrder }, tripId); }; - const debouncedPubUpdateTripItem = debounce((newData, tripId) => { - pubUpdateTripItem(newData, tripId); - }, 1000); - - useEffect(() => { - if (newData && tripId) { - debouncedPubUpdateTripItem(newData, tripId); - } - }, [newData]); - const handleConfirm = () => { if (tripId && visitDate && selectedItemId) { pubDeleteItem({ tripId: tripId, visitDate: visitDate }, selectedItemId); diff --git a/src/components/Plan/PlanItem.tsx b/src/components/Plan/PlanItem.tsx index 5ce5b3bb..ebe35ae5 100644 --- a/src/components/Plan/PlanItem.tsx +++ b/src/components/Plan/PlanItem.tsx @@ -4,13 +4,14 @@ import { useNavigate } from 'react-router-dom'; import TripMap from './TripMap'; import PlanItemBox from './PlanItemBox'; import PlanEditItemBox from './PlanEditItemBox'; -import { useContext, useEffect } from 'react'; +import { useContext, useEffect, useCallback } from 'react'; import { socketContext } from '@hooks/useSocket'; import { useRecoilState, useRecoilValue } from 'recoil'; import { visitDateState, isEditState } from '@recoil/socket'; import { pubGetPathAndItems, pubUpdateTransportation } from '@api/socket'; import { tapState } from '@recoil/plan'; import { useGetTripsAuthority } from '@hooks/useGetTripsAuthority'; +import { debounce } from 'lodash'; type PlanItemProps = { date: string; @@ -40,24 +41,23 @@ const PlanItem: React.FC = ({ date, day }) => { setIsEdit((prev) => !prev); }; - const handleTranspo = ( - transportation: 'CAR' | 'PUBLIC_TRANSPORTATION', - date: string, - tripId: string, - ) => { - if (transportation !== transpo) { - pubUpdateTransportation( - { - visitDate: date, - transportation: transportation, - }, - tripId, - ); - } - }; - const transpo = tripItem?.data?.transportation || ''; + const debouncedHandleTranspo = useCallback( + debounce((transportation, date, tripId) => { + if (transportation !== transpo) { + pubUpdateTransportation( + { + visitDate: date, + transportation: transportation, + }, + tripId, + ); + } + }, 1000), + [transpo], + ); + return ( <> {tripPath && } @@ -67,7 +67,9 @@ const PlanItem: React.FC = ({ date, day }) => { ) : (
handleTranspo('CAR', date || '', tripId || '')} + onClick={() => + debouncedHandleTranspo('CAR', date || '', tripId || '') + } className="flex h-[32px] w-[32px] cursor-pointer items-center justify-center rounded-l-md border border-solid border-gray3"> = ({ date, day }) => {
- handleTranspo('PUBLIC_TRANSPORTATION', date || '', tripId || '') + debouncedHandleTranspo( + 'PUBLIC_TRANSPORTATION', + date || '', + tripId || '', + ) } className="pointer-cursor -ml-[1px] flex h-[32px] w-[32px] cursor-pointer items-center justify-center rounded-r-md border border-solid border-gray3"> { const navigate = useNavigate(); @@ -82,7 +83,11 @@ const PlanSectionTop = () => { }, [isEnter]); return (
- + {!isMobile && ( + <> + + + )} = (props: CommentItemProps) => { }; return ( -
+
{!( diff --git a/src/components/Review/ReviewComments.tsx b/src/components/Review/ReviewComments.tsx index 05dd0244..fbf4858b 100644 --- a/src/components/Review/ReviewComments.tsx +++ b/src/components/Review/ReviewComments.tsx @@ -85,7 +85,7 @@ export default function ReviewComments() { 댓글 {commentDataLength}
-
+
{commentDataLength == 0 && (
diff --git a/src/components/Review/ReviewKeyword.tsx b/src/components/Review/ReviewKeyword.tsx index d6c24780..c33d7323 100644 --- a/src/components/Review/ReviewKeyword.tsx +++ b/src/components/Review/ReviewKeyword.tsx @@ -45,38 +45,29 @@ export default function ReviewKeyword() { } }; - // 5x2 형태로 배치하기 위해 행(row)과 열(column)을 계산 - // const rows = 5; - const columns = 2; - return ( <>
어떤 점이 좋았나요?
-
- {reviewKeywords?.data?.data?.keywords?.map( - (keyword: Keyword, index: number) => { - const row = Math.floor(index / columns) + 1; - const col = (index % columns) + 1; - - const isSelected = selectedKeywords.some( - (selectedKeyword) => - selectedKeyword.keywordId === keyword.keywordId, - ); +
+ {reviewKeywords?.data?.data?.keywords?.map((keyword: Keyword) => { + const isSelected = selectedKeywords.some( + (selectedKeyword) => + selectedKeyword.keywordId === keyword.keywordId, + ); - return ( - - ); - }, - )} + return ( + + ); + })}
); diff --git a/src/components/Trip/LikedToursList.tsx b/src/components/Trip/LikedToursList.tsx index 9fa49f59..fcca4483 100644 --- a/src/components/Trip/LikedToursList.tsx +++ b/src/components/Trip/LikedToursList.tsx @@ -68,7 +68,7 @@ export const LikedToursList = () => { }, []); return ( -
+
{data?.pages[0].data.content.length > 0 ? ( diff --git a/src/components/Trip/LikedToursLists/LikedToursListBox.tsx b/src/components/Trip/LikedToursLists/LikedToursListBox.tsx index 39ef3aae..45bba12d 100644 --- a/src/components/Trip/LikedToursLists/LikedToursListBox.tsx +++ b/src/components/Trip/LikedToursLists/LikedToursListBox.tsx @@ -48,7 +48,7 @@ const LikedToursListBox: React.FC = ({ {/* */}
}> -
+
{isLoading ? Array.from({ length: 10 }, (_, index) => ( diff --git a/src/components/Trip/LikedToursLists/LikedToursListCategory.tsx b/src/components/Trip/LikedToursLists/LikedToursListCategory.tsx index 8e78be04..1ffe97d4 100644 --- a/src/components/Trip/LikedToursLists/LikedToursListCategory.tsx +++ b/src/components/Trip/LikedToursLists/LikedToursListCategory.tsx @@ -27,7 +27,7 @@ const LikedToursListCategory: React.FC = ({ }; return ( -
+
{categories.map((category) => { return ( + className={`body4 mr-[5px] flex items-center justify-center whitespace-nowrap rounded-[30px] border border-solid bg-[#28D8FF] px-[16px] py-[7px] leading-normal ${buttonStyle}`}> {category.name} ); diff --git a/src/components/Trip/LikedToursLists/LikedToursListItem.tsx b/src/components/Trip/LikedToursLists/LikedToursListItem.tsx index f72641fa..f01607b4 100644 --- a/src/components/Trip/LikedToursLists/LikedToursListItem.tsx +++ b/src/components/Trip/LikedToursLists/LikedToursListItem.tsx @@ -83,7 +83,7 @@ const LikedToursListItem: React.FC = ({ />
-
+

{title} @@ -105,7 +105,7 @@ const LikedToursListItem: React.FC = ({

-
+

{tourAddress ? tourAddress : '주소를 제공하지 않고 있어요'}

diff --git a/src/components/Wish/Wish.tsx b/src/components/Wish/Wish.tsx index 560a700a..296c4a77 100644 --- a/src/components/Wish/Wish.tsx +++ b/src/components/Wish/Wish.tsx @@ -44,9 +44,11 @@ const Wish = () => { } return ( -
-
-

나의 관심 목록

+
+
+

+ 나의 관심 목록 +

diff --git a/src/components/Wish/WishCategoryItem.tsx b/src/components/Wish/WishCategoryItem.tsx index 8704adff..4fcf3516 100644 --- a/src/components/Wish/WishCategoryItem.tsx +++ b/src/components/Wish/WishCategoryItem.tsx @@ -27,7 +27,7 @@ const WishCategoryItem: React.FC = ({ return ( ); diff --git a/src/components/Wish/WishItem.tsx b/src/components/Wish/WishItem.tsx index 75928caa..cc7a4edd 100644 --- a/src/components/Wish/WishItem.tsx +++ b/src/components/Wish/WishItem.tsx @@ -32,7 +32,7 @@ const WishItem: React.FC = ({ wishList }) => { return (
navigate(`/detail/${id}`)}>
@@ -46,12 +46,12 @@ const WishItem: React.FC = ({ wishList }) => {
-
-
-

+

+
+

{title}

-
+

{isMetroIncluded && tourAddress ? (tourAddress.match(/(.*?[시군구])/)?.[0] || '') + @@ -63,25 +63,25 @@ const WishItem: React.FC = ({ wishList }) => {

-
+
-
- +
+
-
- +
+ {(Math.ceil(ratingAverage * 100) / 100).toFixed(1)} - + ({reviewCount ? reviewCount.toLocaleString() : reviewCount})
-
-
- +
+
+
- + {likedCount ? likedCount.toLocaleString() : likedCount}
diff --git a/src/components/Wish/WishList.tsx b/src/components/Wish/WishList.tsx index c4fbb68d..3889d820 100644 --- a/src/components/Wish/WishList.tsx +++ b/src/components/Wish/WishList.tsx @@ -45,7 +45,7 @@ const WishList: React.FC = ({
}> -
+
{isLoading ? Array.from({ length: 10 }, (_, index) => ( diff --git a/src/components/common/BackBox/BackBox.tsx b/src/components/common/BackBox/BackBox.tsx index 0d29c96f..6e51e9c9 100644 --- a/src/components/common/BackBox/BackBox.tsx +++ b/src/components/common/BackBox/BackBox.tsx @@ -8,6 +8,7 @@ interface Props { showSkip?: boolean; skipHandler?: VoidFunction; showSave?: boolean; + isSaveValid?: boolean; saveHandler?: VoidFunction; showShare?: boolean; shareHandler?: VoidFunction; @@ -20,6 +21,7 @@ const BackBox = ({ showSkip, skipHandler, showSave, + isSaveValid, saveHandler, showShare, shareHandler, @@ -51,7 +53,8 @@ const BackBox = ({ )} {showSave && ( diff --git a/src/components/common/icons/Icons.tsx b/src/components/common/icons/Icons.tsx index ec00f17e..5676e760 100644 --- a/src/components/common/icons/Icons.tsx +++ b/src/components/common/icons/Icons.tsx @@ -305,36 +305,19 @@ export const CheckIcon = ({ ); }; -interface LeftIconProps { - width?: number; - height?: number; - fill?: string; - onClick?: VoidFunction; - cursor?: string; -} - -export const LeftIcon = ({ - width = 8, - height = 15, - fill = '#1E1E1E', - onClick, - cursor = 'pointer', -}: LeftIconProps) => { +export const LeftIcon = () => { return ( + xmlns="http://www.w3.org/2000/svg" + width="9" + height="16" + viewBox="0 0 9 16" + fill="none"> ); @@ -1806,3 +1789,21 @@ export const GrayCalendarIcon: React.FC = ({}) => { ); }; + +export const AuthDropDownIcon = () => { + return ( + + + + ); +}; diff --git a/src/components/common/nav/InputComment.tsx b/src/components/common/nav/InputComment.tsx index 00a343dc..ebaad8f5 100644 --- a/src/components/common/nav/InputComment.tsx +++ b/src/components/common/nav/InputComment.tsx @@ -106,12 +106,11 @@ export const InputComment: React.FC = () => { }; return ( -
-
+
+
{ )}

- 일정 + 여정

) : ( @@ -84,7 +84,7 @@ const Nav = () => { />

- 일정 + 여정

diff --git a/src/pages/mypage/editUserInfo.page.tsx b/src/pages/mypage/editUserInfo.page.tsx index aab9743d..4932b44c 100644 --- a/src/pages/mypage/editUserInfo.page.tsx +++ b/src/pages/mypage/editUserInfo.page.tsx @@ -1,28 +1,7 @@ -import DeleteMemberButton from '@components/Mypage/DeleteMemberButton'; import UserInfoForm from '@components/Mypage/UserInfoForm'; -import { BackBox } from '@components/common'; -import { useNavigate } from 'react-router-dom'; const EditUserInfo = () => { - const navigate = useNavigate(); - return ( - <> - { - navigate('/mypage'); - }} - // showSave - // saveHandler={() => {}} - > - 회원정보 수정 - -
- - -
- - ); + return ; }; export default EditUserInfo; diff --git a/src/pages/mypage/editUserSurvey.page.tsx b/src/pages/mypage/editUserSurvey.page.tsx index adf0f324..12124c49 100644 --- a/src/pages/mypage/editUserSurvey.page.tsx +++ b/src/pages/mypage/editUserSurvey.page.tsx @@ -1,21 +1,47 @@ +import { putMemberSurvey } from '@api/member'; import AuthSurvey from '@components/Auth/AuthSurvey/AuthSurvey'; import { BackBox } from '@components/common'; +import { SubmitHandler, useForm } from 'react-hook-form'; import { useNavigate } from 'react-router-dom'; const EditUserSurvey = () => { const navigate = useNavigate(); + const { + register, + handleSubmit, + setValue, + formState: { isValid }, + } = useForm(); + + const onSaveSubmit: SubmitHandler = async (data) => { + try { + const res = await putMemberSurvey({ survey: data }); + if (res.data.status === 200) { + navigate(-1); + } + } catch (err) { + console.error(err); + alert('오류가 발생했습니다. 다시 시도해주세요'); + } + }; + + console.log(isValid); + return ( <> { navigate(-1); - }}> + }} + showSave + isSaveValid={isValid} + saveHandler={handleSubmit(onSaveSubmit)}> 나의 여행 취향 설정
- +
); diff --git a/src/pages/signup/signup.page.tsx b/src/pages/signup/signup.page.tsx index def45d2d..7ee023b0 100644 --- a/src/pages/signup/signup.page.tsx +++ b/src/pages/signup/signup.page.tsx @@ -9,10 +9,12 @@ import { import { BackBox } from '@components/common'; import SubmitBtn from '@components/common/button/SubmitBtn'; import { CheckboxIcon } from '@components/common/icons/Icons'; +import { UserInfoState } from '@recoil/Auth.atom'; import { setItem } from '@utils/localStorageFun'; import { useEffect } from 'react'; import { SubmitHandler, useForm } from 'react-hook-form'; import { useNavigate } from 'react-router-dom'; +import { useSetRecoilState } from 'recoil'; const Signup = () => { const { @@ -39,6 +41,8 @@ const Signup = () => { } }, [password, trigger]); + const setUserInfo = useSetRecoilState(UserInfoState); + const onSignupSubmit: SubmitHandler = async (data) => { const { email, password } = data; @@ -48,6 +52,14 @@ const Signup = () => { password, }); if (res.status === 200) { + setUserInfo({ + nickname: res.data.data.nickName!, + email: res.data.data.email!, + profileImageUrl: null, + ageType: null, + genderType: null, + survey: null, + }); setItem('accessToken', res.data.data.tokenInfo.accessToken); navigate('/signup/success'); } diff --git a/src/pages/signup/signupSuccess.page.tsx b/src/pages/signup/signupSuccess.page.tsx index 82eeb663..9a8fa527 100644 --- a/src/pages/signup/signupSuccess.page.tsx +++ b/src/pages/signup/signupSuccess.page.tsx @@ -5,7 +5,7 @@ import { useNavigate } from 'react-router-dom'; const SignupSuccess = () => { const navigate = useNavigate(); return ( -
+
diff --git a/src/pages/signup/signupSurvey.page.tsx b/src/pages/signup/signupSurvey.page.tsx index a00fe2e2..f3a73cf7 100644 --- a/src/pages/signup/signupSurvey.page.tsx +++ b/src/pages/signup/signupSurvey.page.tsx @@ -3,9 +3,32 @@ import { BackBox } from '@components/common'; import AuthSurvey from '@components/Auth/AuthSurvey/AuthSurvey'; import { useNavigate } from 'react-router-dom'; import { ProgressBarIcon } from '@components/common/icons/Icons'; +import { SubmitHandler, useForm } from 'react-hook-form'; +import SubmitBtn from '@components/common/button/SubmitBtn'; +import { putMemberSurvey } from '@api/member'; const SignupSurvey = () => { const navigate = useNavigate(); + + const { + register, + handleSubmit, + setValue, + formState: { isDirty, isValid }, + } = useForm(); + + const onSaveSubmit: SubmitHandler = async (data) => { + try { + const res = await putMemberSurvey({ survey: data }); + if (res.data.status === 200) { + navigate('/signup/info'); + } + } catch (err) { + console.error(err); + alert('오류가 발생했습니다. 다시 시도해주세요'); + } + }; + return (
{ title={'어떤 여행을 좋아하세요?'} subTitle="여행 취향을 골라주세요." /> - + + + 완료 +
); }; diff --git a/src/utils/authSelectOptions.ts b/src/utils/authSelectOptions.ts index d16d0a59..576bbc79 100644 --- a/src/utils/authSelectOptions.ts +++ b/src/utils/authSelectOptions.ts @@ -1,12 +1,10 @@ export const genderArr: SelectOption[] = [ - { id: '', value: '성별을 선택해주세요.' }, { id: 'FEMALE', value: '여' }, { id: 'MALE', value: '남' }, { id: 'NON_BINARY', value: '기타' }, ]; export const ageArr: SelectOption[] = [ - { id: '', value: '연령대를 설정해주세요.' }, { id: 'TEENAGER', value: '10대' }, { id: 'TWENTIES', value: '20대' }, { id: 'THIRTIES', value: '30대' },