Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] - 프로필 이미지 수정 기능 및 여행기 등록 시 여행 장소마다 국가 코드 주도록 구현 #535

Merged
merged 24 commits into from
Oct 21, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
004644c
refactor(Drawer): 기존 헤드와 높이 달라 선 위치가 다른 문제 개선
simorimi Oct 10, 2024
cef7429
feat: 장소 필터링을 위하여 장소 등록시 countryCode를 보내도록 기능 구현
simorimi Oct 13, 2024
7912136
refactor(AvatarCircle): props $네이밍 수정
simorimi Oct 14, 2024
0aa2cfc
Merge branch 'develop/fe' of https://github.com/woowacourse-teams/202…
simorimi Oct 14, 2024
dde854e
refactor(MyTravelogue):$ 제거에 따른 수정
simorimi Oct 15, 2024
932e318
refactor(usePostUploadImages): resize 와 convert 처리 내부에서 하도록 수정
simorimi Oct 15, 2024
aa16247
refactor(MainPage): div semantic 태그인 button으로 수정
simorimi Oct 15, 2024
2eb4464
feat(ProfileImageEditModalBottomSheet): 기능 구현
simorimi Oct 15, 2024
537c3e8
feat(usePutProfile): api 명세 변경에 따라 patch를 put으로, imageUrl body 값에 부여
simorimi Oct 15, 2024
98076f6
refactor(AvatarCircle): props 유연하게 수정
simorimi Oct 16, 2024
fbc78f4
feat(useMyPage): 훅 구현
simorimi Oct 16, 2024
9321263
feat(MyPage): 프로필 이미지 수정 기능 구현
simorimi Oct 16, 2024
3f702c4
refactor(MyPage): 기능 단위로 pr 분리하기 위한 수정
simorimi Oct 16, 2024
ae9be47
refactor(SearchPage): 기능 단위로 pr 분리하기 위한 수정
simorimi Oct 16, 2024
01b6786
refactor(useMyPage): useToggle 사용하도록 수정
simorimi Oct 16, 2024
c7561fd
refactor(common): 반복되는 타입PlaceInfo 타입으로 선언 및 수정
simorimi Oct 20, 2024
b889315
refactor(constants): 상수들 파일로 분리
simorimi Oct 20, 2024
cac5077
refactor(useMyPage): 책임에 따라 각각 커스텀 훅으로 분리
simorimi Oct 20, 2024
7e6ca5e
refactor(constants): 상수 파일로 분리
simorimi Oct 20, 2024
f318d32
refactor(usePostUploadImages): max width, height 값 받을 수 있도록 수정
simorimi Oct 20, 2024
c810327
refactor(usePostUploadImages): max width, height 값 받을 수 있도록 수정
simorimi Oct 20, 2024
0ec73d3
Merge branch 'feature/fe/#519' of https://github.com/woowacourse-team…
simorimi Oct 20, 2024
3f18f98
refactor(useProfileInitialization): 의존성 배열 추가
simorimi Oct 21, 2024
211c7d6
refactor: useCallback으로 update 함수 감싸주도록 수정
simorimi Oct 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import { MAX_IMAGE_UPLOAD_COUNT } from "@components/pages/travelogueRegister/Tra

import { ERROR_MESSAGE_MAP } from "@constants/errorMessage";

import resizeAndConvertImage from "@utils/resizeAndConvertImage";

interface ImageState {
url: string;
isLoading: boolean;
Expand Down Expand Up @@ -88,12 +86,9 @@ export const useTravelogueMultiImageUpload = ({
try {
addLoadingImageStates(files);

const processedFiles = await Promise.all(files.map((file) => resizeAndConvertImage(file)));

const newImageUrls = await mutateAddImage(processedFiles);
const newImageUrls = await mutateAddImage(files);
handleUploadSuccess(newImageUrls);
} catch (error) {
if (error instanceof Error) alert(error.message);
} catch {
revertImageStates(files.length);
} finally {
resetFileInput();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,16 @@ import { useCallback, useState } from "react";

import { usePostUploadImages } from "@queries/usePostUploadImages";

import resizeAndConvertImage from "@utils/resizeAndConvertImage";

const useTravelogueThumbnail = () => {
const { mutateAsync: mutateAddImage } = usePostUploadImages();

const [thumbnail, setThumbnail] = useState("");

const handleChangeThumbnail = async (files: FileList | null) => {
try {
const newFiles = Array.from(files as FileList);
const processedFiles = await Promise.all(newFiles.map((file) => resizeAndConvertImage(file)));
const thumbnail = await mutateAddImage(processedFiles);

setThumbnail(thumbnail[0]);
} catch (error) {
if (error instanceof Error) {
alert(error.message);
}
}
const newFiles = Array.from(files as FileList);
const thumbnail = await mutateAddImage(newFiles);

setThumbnail(thumbnail[0]);
};

const handleInitializeThumbnail = useCallback((thumbnailUrl: string) => {
Expand Down
8 changes: 7 additions & 1 deletion frontend/src/queries/usePostUploadImages.ts
Copy link

@0jenn0 0jenn0 Oct 18, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usePostUpload에서 한번에 처리하도록 리팩토링하셨군요!
이미지가 사용되는 컴포넌트에 따라서 최대로 렌더링되는 크기가 달라서
이 부분에서 이미지 resize에 대한 max width, max height를 받게하면 좋을 것 같습니다!

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

오 내부에 이러한 사항이 있는 줄 몰랐군요! 해당 부분 수정했습니다 고마워요!

Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,16 @@ import { authClient } from "@apis/client";
import { API_ENDPOINT_MAP } from "@constants/endpoint";
import { ERROR_MESSAGE_MAP } from "@constants/errorMessage";

import resizeAndConvertImage from "@utils/resizeAndConvertImage";

export const usePostUploadImages = () => {
const { isPaused, ...rest } = useMutation<string[], ApiError | AxiosError<ErrorResponse>, File[]>(
{
mutationFn: async (files: File[]) => {
const processedFiles = await Promise.all(files.map((file) => resizeAndConvertImage(file)));
const formData = new FormData();

files.forEach((file) => {
processedFiles.forEach((file) => {
formData.append("files", file);
});

Expand All @@ -28,6 +31,9 @@ export const usePostUploadImages = () => {

return response.data;
},
onError: (error) => {
alert(error.message);
},
},
);

Expand Down