From ccb2eeebdc06096743a77d08de9179f261adf696 Mon Sep 17 00:00:00 2001 From: JAEMOON Date: Wed, 29 Nov 2023 20:48:28 +0900 Subject: [PATCH] =?UTF-8?q?[feat]=20Profile=20=EC=97=90=EC=84=9C=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20=EC=97=85=EB=A1=9C=EB=93=9C=20?= =?UTF-8?q?=EC=95=88=EB=90=98=EB=8A=94=20=EB=B6=80=EB=B6=84=20=EC=88=98?= =?UTF-8?q?=EC=A0=95!?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/userInfo/editProfile.tsx | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/pages/userInfo/editProfile.tsx b/pages/userInfo/editProfile.tsx index 7706576..a7312af 100644 --- a/pages/userInfo/editProfile.tsx +++ b/pages/userInfo/editProfile.tsx @@ -13,6 +13,8 @@ import { Profile } from '@/public/types/user'; import { modifyProfile } from '@/api/userInfo'; import { UserInfoProps } from '@/context/UserInfoProvider.tsx'; import useModal from '@/hooks/useModal.ts'; +import { uploadFile } from '@/api/room'; +import { ImageListType } from 'react-images-uploading'; interface ProfileProps { _imageSrc: string; @@ -84,6 +86,11 @@ export default function EditProfile({ _imageSrc, userInfo }: ProfileProps) { const genderButtons = [{ label: 'Male' }, { label: 'Female' }, { label: 'Others' }]; + const uploadPhoto = async (photo: File) => { + const result = await uploadFile(photo); + return result; + }; + const ProfileImage = ({ onClick }: ImageComponentClickProps) => { return (
@@ -117,9 +124,20 @@ export default function EditProfile({ _imageSrc, userInfo }: ProfileProps) { { + callbackImageFn={(imageList: ImageListType) => { if (imageList && imageList[0] && imageList[0].dataURL) { setImageSrc(imageList[0].dataURL); + const image = imageList[0]; + const file = { + lastModified: image?.lastModified, + lastModifiedDate: image?.lastModifiedDate, + size: image?.size, + type: image?.type, + webkitRelativePath: image?.webkitRelativePath, + name: image?.name, + } as unknown as File; + // API 추가 + uploadPhoto(file); } }} style="center"