From 7c4c357f1bc6dcf1be54b1f48787cbc42497cf78 Mon Sep 17 00:00:00 2001 From: NamgungJongMin Date: Wed, 24 Jan 2024 22:07:30 +0900 Subject: [PATCH 1/2] Hotfix: fix layout --- .../User/MypageList/MypageList.module.scss | 21 ++++++++++++------- src/pages/User/User.module.scss | 3 ++- 2 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/components/User/MypageList/MypageList.module.scss b/src/components/User/MypageList/MypageList.module.scss index cfe7c895..e45bbcc1 100644 --- a/src/components/User/MypageList/MypageList.module.scss +++ b/src/components/User/MypageList/MypageList.module.scss @@ -1,4 +1,4 @@ -@use "@/sass" as *; +@use '@/sass' as *; .container { & > li { @@ -34,15 +34,17 @@ .tooltipList { display: none; position: absolute; - left: -38px; - width: 20rem; - padding: 21px 8px 8px 16px; + left: -50px; + width: 23rem; + height: 12.8rem; + padding: 20px 8px 8px 20px; margin-top: 2px; border-radius: 8px; + word-break: keep-all; - background-image: url("@/assets/icons/tooltipFrame.svg"); + background-image: url('@/assets/icons/tooltipFrame.svg'); background-repeat: no-repeat; - background-size: auto; + background-size: 100% 100%; list-style-type: disc; list-style-position: inside; @@ -53,8 +55,11 @@ @include animate(showTooltip, 0.2s, ease-in, forwards); - & > li > span { - margin-left: -5px; + & > li { + margin-bottom: 4px; + & > span { + margin-left: -5px; + } } } diff --git a/src/pages/User/User.module.scss b/src/pages/User/User.module.scss index 3d326d9b..528c3eef 100644 --- a/src/pages/User/User.module.scss +++ b/src/pages/User/User.module.scss @@ -1,4 +1,4 @@ -@use "@/sass" as *; +@use '@/sass' as *; .container { width: 100%; @@ -6,6 +6,7 @@ flex-direction: column; gap: 24px; color: $neutral900; + margin-bottom: 120px; h1 { padding: 16px 20px; From 1e697d0ef933c1a32cf482aa49cdaefdadca8912 Mon Sep 17 00:00:00 2001 From: NamgungJongMin Date: Thu, 25 Jan 2024 05:16:57 +0900 Subject: [PATCH 2/2] Feat: add s3 api & apply presigned url --- src/api/s3.ts | 53 +++++++++++++++++++ src/components/Auth/Input/InputImage.tsx | 6 +-- src/components/Auth/Signup/SignupForm.tsx | 9 ++-- .../Auth/Signup/Step/StepProfile.tsx | 33 ++++++------ .../User/EditProfileForm/EditProfileForm.tsx | 39 +++++++------- src/types/auth.ts | 4 +- src/types/s3.ts | 4 ++ 7 files changed, 103 insertions(+), 45 deletions(-) create mode 100644 src/api/s3.ts create mode 100644 src/types/s3.ts diff --git a/src/api/s3.ts b/src/api/s3.ts new file mode 100644 index 00000000..e10718d7 --- /dev/null +++ b/src/api/s3.ts @@ -0,0 +1,53 @@ +import axios from 'axios'; + +import {PresignedUrlElement} from '@/types/s3'; + +export const s3Request = { + uploadImage: async (image: FileList) => { + try { + // presigned url 발급 + const res = await axios.post('/api/s3/presigned', [image[0].name]); + const presignedUrl = await res.data.data.elements[0].preSignedUrl; + console.log('api/s3/presigned response', res); + + // s3에 이미지 업로드 + const uploadRes = await axios.put(presignedUrl, image[0], { + headers: { + 'Content-Type': 'image/*', + }, + }); + console.log('s3 upload response: ', uploadRes); + + return presignedUrl; + } catch (error) { + console.log(error); + } + }, + + uploadImages: async (images: FileList[]) => { + try { + // 이미지 당 presigned url 발급 + const res = await axios.post( + '/api/s3/presigned', + images.map((image) => image[0].name), + ); + const presignedUrls = await res.data.data.elements.map((element: PresignedUrlElement) => element.preSignedUrl); + console.log('api/s3/presigned response', res); + + // s3에 이미지들 업로드 + const uploadRes = presignedUrls.map( + async (url: string, index: number) => + await axios.put(url, images[index], { + headers: { + 'Content-Type': 'image/*', + }, + }), + ); + console.log('s3 upload response: ', uploadRes); + + return presignedUrls; + } catch (error) { + console.log(error); + } + }, +}; diff --git a/src/components/Auth/Input/InputImage.tsx b/src/components/Auth/Input/InputImage.tsx index 9c2c0627..d37ebcd5 100644 --- a/src/components/Auth/Input/InputImage.tsx +++ b/src/components/Auth/Input/InputImage.tsx @@ -4,10 +4,10 @@ import Camera from '@/assets/icons/camera.svg?react'; import {InputImageProps} from '@/types/auth'; -function InputImage({register, imageBlob, setImageBlob}: InputImageProps) { +function InputImage({register, imageUrl, setImageUrl}: InputImageProps) { return (
-