From 309a68073015eb0466dc06c833810d52506433d5 Mon Sep 17 00:00:00 2001 From: xxinzzi <156905845+xxinzzi@users.noreply.github.com> Date: Fri, 29 Nov 2024 10:15:32 +0900 Subject: [PATCH 1/5] =?UTF-8?q?Fix:=20=EA=B2=8C=EC=8B=9C=EB=AC=BC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EC=8B=9C=20toBlob=20=EC=97=90=EB=9F=AC=20?= =?UTF-8?q?=ED=95=B4=EA=B2=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/BottomSheet/OptionsBottomSheet/index.tsx | 2 +- src/components/PostBase/styles.tsx | 1 - src/pages/PostUpload/index.tsx | 4 +--- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/components/BottomSheet/OptionsBottomSheet/index.tsx b/src/components/BottomSheet/OptionsBottomSheet/index.tsx index 1e871913..cb73ba36 100644 --- a/src/components/BottomSheet/OptionsBottomSheet/index.tsx +++ b/src/components/BottomSheet/OptionsBottomSheet/index.tsx @@ -52,7 +52,7 @@ const OptionsBottomSheet: React.FC = ({ action: 'block', }; const response = await postUserBlockApi(blockRequest); - + if (response.isSuccess) { setModalContent('정상적으로 처리되었습니다.'); } diff --git a/src/components/PostBase/styles.tsx b/src/components/PostBase/styles.tsx index cefabe7c..688187ba 100644 --- a/src/components/PostBase/styles.tsx +++ b/src/components/PostBase/styles.tsx @@ -114,7 +114,6 @@ export const Content = styled(StyledText)<{ $showFullText: boolean }>` export const ShowMoreButton = styled(StyledText)` cursor: pointer; color: ${({ theme }) => theme.colors.gray3}; - margin-top: 8px; `; export const ImageSkeleton = styled(LoadingSkeleton)` diff --git a/src/pages/PostUpload/index.tsx b/src/pages/PostUpload/index.tsx index 35eba7c7..a1db7ea8 100644 --- a/src/pages/PostUpload/index.tsx +++ b/src/pages/PostUpload/index.tsx @@ -205,12 +205,10 @@ const PostUpload: React.FC = () => { }; const uploadImageToFirebase = async (imageUrl: string) => { - // Firebase URL 형식인지 확인 - /* + //Firebase URL 형식인지 확인 if (imageUrl.startsWith('https://firebasestorage.googleapis.com/')) { return imageUrl; // 이미 업로드된 경우, URL을 그대로 반환 } - */ // 새로 업로드해야 하는 경우 const croppedBlob = await cropImage(imageUrl); From 86431e9334007eac71ba852aac9342214e588e8a Mon Sep 17 00:00:00 2001 From: xxinzzi <156905845+xxinzzi@users.noreply.github.com> Date: Fri, 29 Nov 2024 10:23:15 +0900 Subject: [PATCH 2/5] =?UTF-8?q?Feat:=20=EC=8A=A4=ED=83=80=EC=9D=BC=20?= =?UTF-8?q?=ED=83=9C=EA=B7=B8=20=EB=AF=B8=EC=A7=80=EC=A0=95=20=EC=8B=9C=20?= =?UTF-8?q?=EC=97=85=EB=A1=9C=EB=93=9C=20=EC=98=A4=EB=A5=98=20=EB=AA=A8?= =?UTF-8?q?=EB=8B=AC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/PostUpload/index.tsx | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/pages/PostUpload/index.tsx b/src/pages/PostUpload/index.tsx index a1db7ea8..60a0924c 100644 --- a/src/pages/PostUpload/index.tsx +++ b/src/pages/PostUpload/index.tsx @@ -33,6 +33,7 @@ import ClothingInfoItem from '../../components/ClothingInfoItem'; import ImageSwiper from './ImageSwiper'; import SearchBottomSheetContent from './SearchBottomSheetContent'; import ToggleSwitch from './ToggleSwitch'; +import Modal from '../../components/Modal'; import Left from '../../assets/arrow/left.svg'; import Right from '../../assets/arrow/right.svg'; @@ -42,6 +43,7 @@ import StyleTag from '../../assets/default/style-tag.svg'; import Pin from '../../assets/default/pin.svg'; import { ClothingInfo } from '../../components/ClothingInfoItem/dto'; +import { ModalProps } from '../../components/Modal/dto'; import { PostUploadModalProps } from './dto'; import { PostBase } from '../../apis/post/dto'; @@ -59,6 +61,8 @@ const PostUpload: React.FC = () => { const [isSearchBottomSheetOpen, setIsSearchBottomSheetOpen] = useState(false); const [isStyletagListOpen, setIsStyletagListOpen] = useState(false); const [isLoading, setIsLoading] = useState(false); + const [isStatusModalOpen, setIsStatusModalOpen] = useState(false); + const [modalContent, setModalContent] = useState('알 수 없는 오류입니다.\n관리자에게 문의해 주세요.'); const location = useLocation(); const navigate = useNavigate(); @@ -226,8 +230,9 @@ const PostUpload: React.FC = () => { }; const handleSubmit = async () => { - if (!selectedStyletag) { - alert('스타일 태그를 지정해주세요.'); + if (selectedStyletag.length === 0) { + setModalContent('*스타일 태그를 지정해주세요*'); + setIsStatusModalOpen(true); return; } @@ -277,6 +282,14 @@ const PostUpload: React.FC = () => { } }; + // api 처리 상태 모달 (성공/실패) + const statusModalProps: ModalProps = { + content: modalContent, + onClose: () => { + setIsStatusModalOpen(false); + }, + }; + return ( @@ -365,6 +378,7 @@ const PostUpload: React.FC = () => { + {isStatusModalOpen && } ); }; From cf55d97766622c7c2e93aceb5a869d875691964b Mon Sep 17 00:00:00 2001 From: xxinzzi <156905845+xxinzzi@users.noreply.github.com> Date: Fri, 29 Nov 2024 10:28:39 +0900 Subject: [PATCH 3/5] =?UTF-8?q?Feat:=20=EA=B2=8C=EC=8B=9C=EB=AC=BC=20?= =?UTF-8?q?=EC=97=85=EB=A1=9C=EB=93=9C=20=EC=8B=A4=ED=8C=A8=20=EB=AA=A8?= =?UTF-8?q?=EB=8B=AC=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/PostUpload/index.tsx | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pages/PostUpload/index.tsx b/src/pages/PostUpload/index.tsx index 60a0924c..96013ca9 100644 --- a/src/pages/PostUpload/index.tsx +++ b/src/pages/PostUpload/index.tsx @@ -50,6 +50,7 @@ import { PostBase } from '../../apis/post/dto'; import { ref, uploadBytes, getDownloadURL } from 'firebase/storage'; import { storage } from '../../config/firebaseConfig'; import { getPostDetailApi, createPostApi, modifyPostApi } from '../../apis/post'; +import { handleError } from '../../apis/util/handleError'; const PostUpload: React.FC = () => { const [selectedImages, setSelectedImages] = useRecoilState(postImagesAtom); @@ -276,7 +277,9 @@ const PostUpload: React.FC = () => { navigate('/mypage'); } catch (error) { - console.error(error); + const errorMessage = handleError(error, 'post'); + setModalContent(errorMessage); + setIsStatusModalOpen(true); } finally { setIsLoading(false); } From db810adab5a691f8885c6f0bc90a6c33fbe8a935 Mon Sep 17 00:00:00 2001 From: xxinzzi <156905845+xxinzzi@users.noreply.github.com> Date: Fri, 29 Nov 2024 11:17:49 +0900 Subject: [PATCH 4/5] =?UTF-8?q?Fix:=20=EA=B2=8C=EC=8B=9C=EB=AC=BC=20?= =?UTF-8?q?=EC=97=85=EB=A1=9C=EB=93=9C=20=EC=8B=9C=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=EA=B0=80=20orderNum=201=EB=B6=80=ED=84=B0=20=EC=8B=9C?= =?UTF-8?q?=EC=9E=91=ED=95=98=EB=8F=84=EB=A1=9D=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/PostUpload/index.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pages/PostUpload/index.tsx b/src/pages/PostUpload/index.tsx index 96013ca9..19a8e92d 100644 --- a/src/pages/PostUpload/index.tsx +++ b/src/pages/PostUpload/index.tsx @@ -244,7 +244,7 @@ const PostUpload: React.FC = () => { const uploadedImages = await Promise.all( selectedImages.map(async (image, index) => { const imageUrl = await uploadImageToFirebase(image.imageUrl); - return { imageUrl: imageUrl, orderNum: index }; // orderNum 추가 + return { imageUrl: imageUrl, orderNum: index + 1 }; // orderNum 추가 }), ); From 2b9f7b5fc94b3936cac83cbd4d42c1e4ae8ffcc9 Mon Sep 17 00:00:00 2001 From: xxinzzi <156905845+xxinzzi@users.noreply.github.com> Date: Fri, 29 Nov 2024 12:06:51 +0900 Subject: [PATCH 5/5] =?UTF-8?q?Fix:=20=EA=B2=8C=EC=8B=9C=EB=AC=BC=20?= =?UTF-8?q?=EC=88=98=EC=A0=95=20=EC=8B=9C=20=EC=9D=B4=EB=AF=B8=EC=A7=80=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80/=EC=88=98=EC=A0=95=20=EC=95=88=EB=90=98?= =?UTF-8?q?=EB=8A=94=20=EC=98=A4=EB=A5=98=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/Post/dto.ts | 0 src/pages/PostUpload/index.tsx | 41 +++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 15 deletions(-) create mode 100644 src/pages/Post/dto.ts diff --git a/src/pages/Post/dto.ts b/src/pages/Post/dto.ts new file mode 100644 index 00000000..e69de29b diff --git a/src/pages/PostUpload/index.tsx b/src/pages/PostUpload/index.tsx index 19a8e92d..931b6d4a 100644 --- a/src/pages/PostUpload/index.tsx +++ b/src/pages/PostUpload/index.tsx @@ -80,21 +80,20 @@ const PostUpload: React.FC = () => { 'luxury', ]; + // 게시물 업로드인지 수정인지 모드 확인 useEffect(() => { - const state = location.state as { mode?: string; postId?: number }; - if (state?.mode) { - setMode(state.mode); // 모드 상태를 설정 - } - handleInitialModalState(); - }, []); - - const handleInitialModalState = async () => { - const state = location.state as { mode?: string; postId?: number }; + const handleMode = async () => { + const state = location.state as { mode?: string; postId?: number }; + if (state?.mode) { + setMode(state.mode); // 모드 상태를 설정 + } + if (state.mode === 'edit' && state?.postId && selectedImages.length === 0) { + await getPost(state.postId); + } + }; - if (state.mode === 'edit' && state?.postId) { - await getPost(state.postId); - } - }; + handleMode(); + }, []); const handlePrev = () => { const state = location.state as { mode?: string; postId?: number }; @@ -118,7 +117,9 @@ const PostUpload: React.FC = () => { setSelectedStyletag(postStyletags); setIsRepresentative(isRepresentative); } catch (error) { - console.error(error); + const errorMessage = handleError(error, 'post'); + setModalContent(errorMessage); + setIsStatusModalOpen(true); } finally { setIsLoading(false); } @@ -133,7 +134,17 @@ const PostUpload: React.FC = () => { }; const handleAddClothingInfo = (newClothingInfo: ClothingInfo) => { - setClothingInfos((clothingInfos) => [...clothingInfos, newClothingInfo]); + setClothingInfos((clothingInfos) => { + // 중복 확인 (새로운 의류 정보가 이미 존재하지 않을 경우 추가) + const isDuplicate = clothingInfos.some( + (info) => info.modelName === newClothingInfo.modelName && info.brandName === newClothingInfo.brandName, + ); + if (!isDuplicate) { + return [...clothingInfos, newClothingInfo]; + } else { + return clothingInfos; // 중복이면 기존 리스트 그대로 반환 + } + }); }; const handleDeleteClothingInfo = (deleteClothingInfo: ClothingInfo) => {