From c212194d62d35f5d9a9fb3508c8eac82e2ede6e9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A7=80=EC=9B=90?= Date: Mon, 3 Feb 2025 16:36:52 +0900 Subject: [PATCH 01/12] =?UTF-8?q?feat:=20=ED=94=84=EB=A1=9C=ED=95=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20api=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libs/apis/updateUserProfile.api.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 src/libs/apis/updateUserProfile.api.ts diff --git a/src/libs/apis/updateUserProfile.api.ts b/src/libs/apis/updateUserProfile.api.ts new file mode 100644 index 0000000..54621cf --- /dev/null +++ b/src/libs/apis/updateUserProfile.api.ts @@ -0,0 +1,11 @@ +import client from './clients'; + +export const updateUserProfile = async (formData: FormData) => { + try { + const res = await client.patch('api/members/info', formData); + console.log(res.data); + return res.data; + } catch (error) { + console.log('프로필 업데이트 실패', error); + } +}; From 6583984840a4f2821b711c9dea091b2028b96082 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A7=80=EC=9B=90?= Date: Mon, 3 Feb 2025 16:37:19 +0900 Subject: [PATCH 02/12] =?UTF-8?q?fix:=20=EA=B3=84=EC=A2=8C=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20type=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libs/schemas/auth.ts | 8 ++++++++ src/types/auth.d.ts | 1 + 2 files changed, 9 insertions(+) diff --git a/src/libs/schemas/auth.ts b/src/libs/schemas/auth.ts index aeae1a1..9d56dd4 100644 --- a/src/libs/schemas/auth.ts +++ b/src/libs/schemas/auth.ts @@ -18,6 +18,13 @@ const realNameSchema = z.string().min(1, '본명을 입력해주세요!'); const genderSchema = z.enum(['MALE', 'FEMALE']).default('MALE'); +const accountNumberSchema = z + .string() + .min(10, '올바른 계좌번호를 입력해주세요!') + .refine((value) => !isNaN(Number(value)), { + message: '계좌번호는 숫자로만 입력해야 합니다!', + }); + const profileImageSchema = z.optional( z .union([ @@ -98,6 +105,7 @@ export const userInfoVerificationSchema = z.object({ realName: realNameSchema, studentNumber: studentIdSchema, gender: genderSchema, + accountNumber: accountNumberSchema.optional(), }); export const agreementsSchema = z.object({ diff --git a/src/types/auth.d.ts b/src/types/auth.d.ts index c8d003d..8a9df13 100644 --- a/src/types/auth.d.ts +++ b/src/types/auth.d.ts @@ -29,6 +29,7 @@ declare module 'gachTaxi-types' { realName: string; studentNumber: string; gender: 'MALE' | 'FEMALE'; + accountNumber?: string; } interface AgreementsTypes { From abcb7c060cfa6ba7d8a9b159aad0ed9bfb67719e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A7=80=EC=9B=90?= Date: Mon, 3 Feb 2025 16:37:49 +0900 Subject: [PATCH 03/12] =?UTF-8?q?fix:=20=EA=B3=84=EC=A2=8C=EB=B2=88?= =?UTF-8?q?=ED=98=B8=20input=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/my-page/EditProfilePage.tsx | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/pages/my-page/EditProfilePage.tsx b/src/pages/my-page/EditProfilePage.tsx index ed9bc82..b2919d4 100644 --- a/src/pages/my-page/EditProfilePage.tsx +++ b/src/pages/my-page/EditProfilePage.tsx @@ -18,6 +18,7 @@ const EditProfilePage = () => { studentNumber: '', gender: 'MALE', profilePicture: undefined, + accountNumber: '', }, mode: 'onSubmit', }); @@ -66,6 +67,14 @@ const EditProfilePage = () => { type="text" /> + + From 9adf749331c1df8fabee249aad355005f4cd7b5e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A7=80=EC=9B=90?= Date: Mon, 3 Feb 2025 16:38:09 +0900 Subject: [PATCH 04/12] =?UTF-8?q?fix:=20rounded=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/commons/Input.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/commons/Input.tsx b/src/components/commons/Input.tsx index 74ebded..8c6ff12 100644 --- a/src/components/commons/Input.tsx +++ b/src/components/commons/Input.tsx @@ -64,7 +64,7 @@ function Input({ id={name.toString()} type={type} placeholder={placeholder} - className={`border outline-none border-textDarkGray bg-transparent rounded-common p-3 pl-4 text-textDarkGray placeholder:text-body ${className ? className : ''}`} + className={`border outline-none border-textDarkGray bg-transparent rounded-modal p-3 pl-4 text-textDarkGray placeholder:text-body ${className ? className : ''}`} {...field} /> {fieldState.error && ( From 853c26b436f2d57c582e665d173ce8b4dc932d44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A7=80=EC=9B=90?= Date: Tue, 4 Feb 2025 10:58:06 +0900 Subject: [PATCH 05/12] =?UTF-8?q?fix:=20profileEditVerificationTypes=20?= =?UTF-8?q?=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/types/auth.d.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/types/auth.d.ts b/src/types/auth.d.ts index 8a9df13..6130d2b 100644 --- a/src/types/auth.d.ts +++ b/src/types/auth.d.ts @@ -29,6 +29,11 @@ declare module 'gachTaxi-types' { realName: string; studentNumber: string; gender: 'MALE' | 'FEMALE'; + } + + interface ProfileEditVerificationTypes { + profilePicture?: file | string | undefined; + nickName?: string; accountNumber?: string; } From 60ded25ec02c36f2600f513635c4e85a1763a01c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A7=80=EC=9B=90?= Date: Tue, 4 Feb 2025 10:59:59 +0900 Subject: [PATCH 06/12] =?UTF-8?q?fix:=20=ED=94=84=EB=A1=9C=ED=95=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EB=A1=9C=EC=A7=81=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/my-page/EditProfilePage.tsx | 62 +++++++++++++++++++-------- 1 file changed, 44 insertions(+), 18 deletions(-) diff --git a/src/pages/my-page/EditProfilePage.tsx b/src/pages/my-page/EditProfilePage.tsx index b2919d4..fd36565 100644 --- a/src/pages/my-page/EditProfilePage.tsx +++ b/src/pages/my-page/EditProfilePage.tsx @@ -2,21 +2,22 @@ import BackButton from '@/components/commons/BackButton'; import Button from '@/components/commons/Button'; import Input from '@/components/commons/Input'; import { z } from 'zod'; -import { userInfoVerificationSchema } from '@/libs/schemas/auth'; -import { UserInfoVerificationTypes } from 'gachTaxi-types'; +import { profileEditVerificationSchema } from '@/libs/schemas/auth'; +import { ProfileEditVerificationTypes } from 'gachTaxi-types'; import { zodResolver } from '@hookform/resolvers/zod'; import { useForm, SubmitHandler } from 'react-hook-form'; import ProfileImageUpload from '@/components/sign/userInfoVerification/ProfileImageUpload'; import useUploadImage from '@/hooks/useUploadImage'; +import { updateUserProfile } from '@/libs/apis/updateUserProfile.api'; +import { useToast } from '@/contexts/ToastContext'; +import useUserStore from '@/store/useUserStore'; +import handleAxiosError from '@/libs/apis/axiosError.api'; const EditProfilePage = () => { - const profileForm = useForm>({ - resolver: zodResolver(userInfoVerificationSchema), + const profileForm = useForm>({ + resolver: zodResolver(profileEditVerificationSchema), defaultValues: { - nickname: '', - realName: '', - studentNumber: '', - gender: 'MALE', + nickName: '', profilePicture: undefined, accountNumber: '', }, @@ -26,16 +27,41 @@ const EditProfilePage = () => { const currentImage = profileForm.watch('profilePicture'); const { imagePreview, uploadedImage, setImagePreview } = useUploadImage(currentImage); + const { setUser } = useUserStore(); + const { openToast } = useToast(); - const handleSubmitChange: SubmitHandler = ( - data, - ) => { + const handleSubmitChange: SubmitHandler< + ProfileEditVerificationTypes + > = async (data) => { try { - console.log(data); - console.log(uploadedImage); - profileForm.setValue('nickname', ''); - } catch (e) { - console.error(e); + console.log('제출 데이터:', data); + const updateData = profileForm.getValues(); + if ( + data.profilePicture !== uploadedImage && + typeof data.profilePicture !== 'string' + ) { + updateData.profilePicture = uploadedImage; + const res = await updateUserProfile(updateData); + if (res?.code === 200) { + const userData = res?.data; + setUser(userData); + openToast(res.message, 'success'); + } + } else { + console.log('제출 데이터2:', data); + const res = await updateUserProfile(data); + + if (res?.code === 200) { + if (res?.data) { + const userData = res.data; + setUser(userData); + } + openToast(res.message, 'success'); + } + } + } catch (error) { + const errorMessage = handleAxiosError(error); + openToast(errorMessage, 'error'); } }; @@ -49,7 +75,7 @@ const EditProfilePage = () => { className="flex flex-col gap-2 w-full" onSubmit={profileForm.handleSubmit( handleSubmitChange as SubmitHandler< - z.infer + z.infer >, )} > @@ -61,7 +87,7 @@ const EditProfilePage = () => { Date: Tue, 4 Feb 2025 11:00:28 +0900 Subject: [PATCH 07/12] =?UTF-8?q?feat:=20=EB=8B=89=EB=84=A4=EC=9E=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EC=8A=A4=ED=82=A4=EB=A7=88=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libs/schemas/auth.ts | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/libs/schemas/auth.ts b/src/libs/schemas/auth.ts index 9d56dd4..33ff1e0 100644 --- a/src/libs/schemas/auth.ts +++ b/src/libs/schemas/auth.ts @@ -23,7 +23,13 @@ const accountNumberSchema = z .min(10, '올바른 계좌번호를 입력해주세요!') .refine((value) => !isNaN(Number(value)), { message: '계좌번호는 숫자로만 입력해야 합니다!', - }); + }) + .optional(); + +const editNickNameSchema = z + .string() + .min(1, '닉네임을 입력해주세요!') + .optional(); const profileImageSchema = z.optional( z @@ -105,7 +111,12 @@ export const userInfoVerificationSchema = z.object({ realName: realNameSchema, studentNumber: studentIdSchema, gender: genderSchema, - accountNumber: accountNumberSchema.optional(), +}); + +export const profileEditVerificationSchema = z.object({ + profilePicture: profileImageSchema, + nickName: editNickNameSchema, + accountNumber: accountNumberSchema, }); export const agreementsSchema = z.object({ From 2b58841fa79306169cc00c93c2686238716f45dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A7=80=EC=9B=90?= Date: Tue, 4 Feb 2025 11:04:05 +0900 Subject: [PATCH 08/12] =?UTF-8?q?fix:=20profileImageUpload=20FieldValues?= =?UTF-8?q?=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../userInfoVerification/ProfileImageUpload.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/src/components/sign/userInfoVerification/ProfileImageUpload.tsx b/src/components/sign/userInfoVerification/ProfileImageUpload.tsx index a6809d8..4a6019f 100644 --- a/src/components/sign/userInfoVerification/ProfileImageUpload.tsx +++ b/src/components/sign/userInfoVerification/ProfileImageUpload.tsx @@ -1,26 +1,24 @@ -import { Control, Controller } from 'react-hook-form'; -import { userInfoVerificationSchema } from '@/libs/schemas/auth'; -import { z } from 'zod'; +import { Control, Controller, FieldValues, Path } from 'react-hook-form'; import BasicProfileIcon from '@/assets/icon/basicProfileIcon.svg?react'; import CameraIcon from '@/assets/icon/cameraIcon.svg?react'; import ImageCancelIcon from '@/assets/icon/imageCancelIcon.svg?react'; import Button from '@/components/commons/Button'; -interface ProfileImageUploadProps { - control: Control>; +interface ProfileImageUploadProps { + control: Control; imagePreview: string | undefined; setImagePreview: (value: string | undefined) => void; } -const ProfileImageUpload = ({ +const ProfileImageUpload = ({ control, imagePreview, setImagePreview, -}: ProfileImageUploadProps) => { +}: ProfileImageUploadProps) => { return ( } render={({ field: { onChange, ...field } }) => ( <>
From fc18c3170432f698addf0f4125222e385e501c8b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A7=80=EC=9B=90?= Date: Tue, 4 Feb 2025 11:04:31 +0900 Subject: [PATCH 09/12] =?UTF-8?q?feat:=20=ED=94=84=EB=A1=9C=ED=95=84=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20api=20=EC=97=B0=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libs/apis/updateUserProfile.api.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/libs/apis/updateUserProfile.api.ts b/src/libs/apis/updateUserProfile.api.ts index 54621cf..abcc46d 100644 --- a/src/libs/apis/updateUserProfile.api.ts +++ b/src/libs/apis/updateUserProfile.api.ts @@ -1,8 +1,10 @@ import client from './clients'; +import { ProfileEditVerificationTypes } from 'gachTaxi-types'; -export const updateUserProfile = async (formData: FormData) => { +export const updateUserProfile = async (data: ProfileEditVerificationTypes) => { try { - const res = await client.patch('api/members/info', formData); + console.log(data); + const res = await client.patch('/api/members/info', data); console.log(res.data); return res.data; } catch (error) { From 527fe350032923a20cd14f96438074be1f15c5e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A7=80=EC=9B=90?= Date: Tue, 4 Feb 2025 11:09:28 +0900 Subject: [PATCH 10/12] =?UTF-8?q?remove:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=A3=BC=EC=84=9D=20=EC=82=AD=EC=A0=9C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/libs/apis/updateUserProfile.api.ts | 2 -- src/pages/my-page/EditProfilePage.tsx | 2 -- 2 files changed, 4 deletions(-) diff --git a/src/libs/apis/updateUserProfile.api.ts b/src/libs/apis/updateUserProfile.api.ts index abcc46d..062e2d5 100644 --- a/src/libs/apis/updateUserProfile.api.ts +++ b/src/libs/apis/updateUserProfile.api.ts @@ -3,9 +3,7 @@ import { ProfileEditVerificationTypes } from 'gachTaxi-types'; export const updateUserProfile = async (data: ProfileEditVerificationTypes) => { try { - console.log(data); const res = await client.patch('/api/members/info', data); - console.log(res.data); return res.data; } catch (error) { console.log('프로필 업데이트 실패', error); diff --git a/src/pages/my-page/EditProfilePage.tsx b/src/pages/my-page/EditProfilePage.tsx index fd36565..acbf613 100644 --- a/src/pages/my-page/EditProfilePage.tsx +++ b/src/pages/my-page/EditProfilePage.tsx @@ -34,7 +34,6 @@ const EditProfilePage = () => { ProfileEditVerificationTypes > = async (data) => { try { - console.log('제출 데이터:', data); const updateData = profileForm.getValues(); if ( data.profilePicture !== uploadedImage && @@ -48,7 +47,6 @@ const EditProfilePage = () => { openToast(res.message, 'success'); } } else { - console.log('제출 데이터2:', data); const res = await updateUserProfile(data); if (res?.code === 200) { From 889369667a09db6c5cc287b8532e5f28937a09fd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A7=80=EC=9B=90?= Date: Tue, 4 Feb 2025 11:46:57 +0900 Subject: [PATCH 11/12] =?UTF-8?q?fix:=20=EC=B1=84=ED=8C=85=EB=B0=A9=20?= =?UTF-8?q?=EA=B3=84=EC=A2=8C=20=EC=84=A4=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/chat/bottomMenu/index.tsx | 21 ++++- .../chat/modal/sendAccountModal.tsx | 4 +- src/pages/mathcing/index.tsx | 78 +++++++++++++++++++ src/types/auth.d.ts | 1 + 4 files changed, 98 insertions(+), 6 deletions(-) create mode 100644 src/pages/mathcing/index.tsx diff --git a/src/components/chat/bottomMenu/index.tsx b/src/components/chat/bottomMenu/index.tsx index c5ca082..419f989 100644 --- a/src/components/chat/bottomMenu/index.tsx +++ b/src/components/chat/bottomMenu/index.tsx @@ -13,6 +13,7 @@ import useTimerStore from '@/store/useTimerStore'; import { getCloseMatching } from '@/libs/apis/getCloseMatching.api'; import getExitChatRoom from '@/libs/apis/getExitChatRoom'; import useSSEStore from '@/store/useSSEStore'; +import useUserStore from '@/store/useUserStore'; const BottomMenu = ({ onSendAccount, @@ -29,15 +30,27 @@ const BottomMenu = ({ const nav = useNavigate(); const { messages } = useSSEStore(); const [isOwner, setIsOwner] = useState(false); + const { user } = useUserStore(); + const accountNumber = user?.accountNumber || '계좌번호 없음'; messages.forEach((message) => { if (message.topic === 'match_room_created') { const userId = localStorage.getItem('userId'); - setIsOwner(userId === String(message.roomMasterId)); + console.log('🟢 현재 로그인된 사용자 ID:', userId); + console.log('🟡 방장 ID:', message.roomMasterId); + //setIsOwner(userId === String(message.roomMasterId)); + const isUserOwner = userId === String(message.roomMasterId); + console.log('🔵 isOwner 값:', isUserOwner); + + setIsOwner(isUserOwner); } }); const handleSendClick = () => { + if (!user?.accountNumber) { + openToast('등록된 계좌번호가 없습니다.', 'error'); + return; + } setShowAccountModal(true); }; @@ -87,7 +100,7 @@ const BottomMenu = ({ }; const clickHandlers: Record void> = { - '계좌 전송': isOwner ? handleSendClick : () => {}, + '계좌 전송': handleSendClick, '택시 호출': isOwner ? handleTaxiClick : () => {}, '매칭 마감': isOwner ? handleCloseMatching : () => {}, '매칭 취소': handleExitModal, @@ -100,7 +113,7 @@ const BottomMenu = ({ key={index} onClick={clickHandlers[item.label] || undefined} className={`${ - !isOwner && item.label !== '매칭 취소' + item.label !== '계좌 전송' && !isOwner && item.label !== '매칭 취소' ? 'cursor-not-allowed opacity-50' : 'cursor-pointer' }`} @@ -112,7 +125,7 @@ const BottomMenu = ({ {showAccountModal && ( setShowAccountModal(false)} - account="농협 302 XXXX XXXX XX" + account={accountNumber} onSend={(accountInfo) => { onSendAccount(accountInfo); setShowAccountModal(false); diff --git a/src/components/chat/modal/sendAccountModal.tsx b/src/components/chat/modal/sendAccountModal.tsx index e7e5c30..4a24026 100644 --- a/src/components/chat/modal/sendAccountModal.tsx +++ b/src/components/chat/modal/sendAccountModal.tsx @@ -14,8 +14,8 @@ const SendAccountModal: React.FC = ({ }) => { return ( -
-

{account}

+
+

{account}

+
+ )} + + ); +}; + +export default MatchingInfoPage; diff --git a/src/types/auth.d.ts b/src/types/auth.d.ts index 6130d2b..b4e0696 100644 --- a/src/types/auth.d.ts +++ b/src/types/auth.d.ts @@ -52,6 +52,7 @@ declare module 'gachTaxi-types' { email: string; role: string; gender: string; + accountNumber?: string; } // 회원가입 또는 로그인 시 반환되는 유저 정보 From 3b942cafddc31eecdc6cf4394b83014fb0b940f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=EA=B9=80=EC=A7=80=EC=9B=90?= Date: Tue, 4 Feb 2025 11:48:50 +0900 Subject: [PATCH 12/12] =?UTF-8?q?remove:=20=EB=B6=88=ED=95=84=EC=9A=94?= =?UTF-8?q?=ED=95=9C=20=EC=A3=BC=EC=84=9D=20=EC=A0=9C=EA=B1=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/chat/bottomMenu/index.tsx | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/components/chat/bottomMenu/index.tsx b/src/components/chat/bottomMenu/index.tsx index 419f989..cf30fd6 100644 --- a/src/components/chat/bottomMenu/index.tsx +++ b/src/components/chat/bottomMenu/index.tsx @@ -36,13 +36,7 @@ const BottomMenu = ({ messages.forEach((message) => { if (message.topic === 'match_room_created') { const userId = localStorage.getItem('userId'); - console.log('🟢 현재 로그인된 사용자 ID:', userId); - console.log('🟡 방장 ID:', message.roomMasterId); - //setIsOwner(userId === String(message.roomMasterId)); - const isUserOwner = userId === String(message.roomMasterId); - console.log('🔵 isOwner 값:', isUserOwner); - - setIsOwner(isUserOwner); + setIsOwner(userId === String(message.roomMasterId)); } });