Skip to content

Conversation

@heonq
Copy link
Collaborator

@heonq heonq commented Feb 23, 2025

요구사항

기본

프론트엔드 배포

  • AWS Amplify 혹은 Vercel을 활용해 배포합니다.
  • AWS에 배포된 백엔드의 주소에 맞게 API 주소를 변경합니다.

주요 변경사항

  • 이미지 업로드 API 변경에 따른 프론트엔드 API호출 방식 및 상품 업로드 방식 업데이트

@heonq heonq requested a review from pers0n4 February 23, 2025 04:38
@heonq heonq self-assigned this Feb 23, 2025
@heonq heonq added 매운맛🔥 뒤는 없습니다. 그냥 필터 없이 말해주세요. 책임은 제가 집니다. 최종 제출 스프린트미션 최종 제출본입니다. labels Feb 23, 2025
Comment on lines +69 to +85
onSuccess: () => {
if (initialValue) {
const changedFields: Partial<CreateProductRequest> = {};
if (data.name !== initialValue.name) changedFields.name = data.name;
if (data.description !== initialValue.description)
changedFields.description = data.description;
if (data.price !== initialValue.price)
changedFields.price = data.price;
if (Object.keys(changedFields).length > 0)
return (mutation as EditMutation).mutate(changedFields);
}
return (mutation as CreateMutation).mutate({
...data,
images: [`https://${imageUrl}`],
});
},
});
Copy link
Contributor

Choose a reason for hiding this comment

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

함수 구현체가 길어지면 인라인 콜백으로 사용하는 대신 함수를 따로 정의해보면 가시성을 높일 수 있을 것 같다는 면에서 좋아 보여요.

Comment on lines +72 to +76
if (data.name !== initialValue.name) changedFields.name = data.name;
if (data.description !== initialValue.description)
changedFields.description = data.description;
if (data.price !== initialValue.price)
changedFields.price = data.price;
Copy link
Contributor

Choose a reason for hiding this comment

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

비슷한 모양의 코드가 반복되는데 반복문이나 함수형 프로그래밍적으로 접근해보면 어떨까요?

async (error) => {
const originalRequest = error.config;

if (originalRequest.url === 'auth/refresh-token') {
Copy link
Contributor

Choose a reason for hiding this comment

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

직관적으로 파악하기 힘든 조건의 경우는 변수 또는 함수로 추상화해주면 파악하기 쉬워질 것 같아요.

e.g.

const hasRefreshTokenRequestFailed = originalRequest.url === 'auth/refresh-token'
if (hasRefreshTokenRequestFailed) {}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

매운맛🔥 뒤는 없습니다. 그냥 필터 없이 말해주세요. 책임은 제가 집니다. 최종 제출 스프린트미션 최종 제출본입니다.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants