Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
zestlee1106 committed Nov 29, 2023
2 parents ac035a7 + f23398c commit f51f6ca
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion pages/userInfo/editProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 (
<div className="flex justify-center items-center h-[90px] mt-[20px] mb-[36px]" onClick={onClick}>
Expand Down Expand Up @@ -117,9 +124,20 @@ export default function EditProfile({ _imageSrc, userInfo }: ProfileProps) {
<Upload
InitImageComponent={ProfileImage}
multiImage={false}
callbackImageFn={(imageList) => {
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"
Expand Down

0 comments on commit f51f6ca

Please sign in to comment.