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

[BugFix] label 및 sprint 이름 중복시 예외처리 추가 및 toast 추가 #152

Merged
merged 16 commits into from
Nov 26, 2024

Conversation

PMtHk
Copy link
Collaborator

@PMtHk PMtHk commented Nov 26, 2024

관련 이슈 번호

close #149

작업 내용

  • shadcn/ui sonner 추가 및 useToast 유틸리티 작성
  • 개별 useMutation 에 제너릭 타입 추가
  • 라벨 밀 스프린트 생성 및 수정 시 중복 예외 처리
  • toast 로 사용자에게 피드백 전달
  • 좌측 헤더에 프로젝트 title 아닌 id 뜨는 문제 수정
  • sprint date-picker 라벨 이슈 해결

고민과 학습내용

useMutation 의 제너릭 타입 설정에 대해 다시 배웠습니다.
매번 인자에 넘겨주고 있었는데, 제너릭 타입을 설정해두니, 그럴 필요가 없어졌습니다.

역시, 공식문서가 최곱니다.

스크린샷

2024-11-26.3.31.00.mov

(현재 라벨 및 스프린트의 API 에서 409 Conflict 가 보내지지 않아 폼 영역 이슈로 뜨지 않습니다.
다만, 그 부분 수정되면 바르게 동작할 것입니다)

@PMtHk PMtHk added BugFix 문제 상황/오류 수정 FE 클라이언트 작업 labels Nov 26, 2024
@PMtHk PMtHk self-assigned this Nov 26, 2024
@PMtHk PMtHk changed the title 라벨 및 스프린트 이름 중복시 예외처리 추가 및 토스트 추가 label 및 sprint 이름 중복시 예외처리 추가 및 toast 추가 Nov 26, 2024
@@ -0,0 +1,27 @@
import { useTheme } from 'next-themes';
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이 부분은 shadcn/ui 의 sonner 를 사용한 부분입니다.
리뷰 대상이 아닙니다.


interface CreateLabelProps {
onCreate: (data: LabelFormValues) => void;
createMutation: UseMutationResult<BaseResponse, AxiosError, CreateLabelDto>;
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

외부에서 한번 mutation 을 wrapping 해서 사용했었는데,
onSuccess, onError 등을 내부에서 사용하는 편이 보기 좋아보여서, 이렇게 수정했습니다.

const onError = (error: AxiosError) => {
if (error?.response?.status === 409) {
setError('name', {
message: 'Label with this name already exists',
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이 에러 메세지들은 나중에 하나의 객체로 분리하면 더 좋을 것 같습니다.

create: useMutation({
mutationFn: (createLabelDto: CreateLabelDto) =>
projectAPI.createLabel(projectId, createLabelDto),
create: useMutation<BaseResponse, AxiosError, CreateLabelDto>({
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

useMutation 에 제너릭 타입을 추가하니,
개별 인자에 타입을 설정하지 않는 것이 좋더라고요!

@@ -132,6 +137,7 @@ function AuthLayout() {
}
/>
<Outlet />
<Toaster position="bottom-left" />
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

planning-poker 기능과 겹칠 것을 대비해서,
좌측 하단으로 설정해뒀습니다.

<div className="flex items-center gap-2">
<h2>{params.project ?? 'My Account'}</h2>
<h2>{(params.project && currentProject?.title) ?? 'My Account'}</h2>
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

이 레이아웃에서 이미 프로젝트 정보를 가지고 있어서, 해당 정보를 이용해 title 정보를 가져왔습니다.

createMutation: UseMutationResult<BaseResponse, AxiosError, CreateSprintDto>;
}

const 일주일 = 7 * 24 * 60 * 60 * 1000;
Copy link
Collaborator

@yangchef1 yangchef1 Nov 26, 2024

Choose a reason for hiding this comment

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


이것만 한글 변수 명을 사용한 이유가 있나요 ?!

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

마스터 클래스 때, week aweek 이런 변수명은 잘 안읽힌다. 라는 이야기를 해주신 적이 있어서
한번 적용해봤습니다.

@PMtHk PMtHk changed the title label 및 sprint 이름 중복시 예외처리 추가 및 toast 추가 [Fix] label 및 sprint 이름 중복시 예외처리 추가 및 toast 추가 Nov 26, 2024
@iam454
Copy link
Collaborator

iam454 commented Nov 26, 2024

근데 로고 옆에 / 이거 없는게 더 괜찮은 것 같아요!!

@PMtHk
Copy link
Collaborator Author

PMtHk commented Nov 26, 2024

근데 로고 옆에 / 이거 없는게 더 괜찮은 것 같아요!!

vercel 을 최대한 따라했습니다. 너무 딱 붙는 느낌이라 연한톤으로 바꿔보겠습니다.

@PMtHk PMtHk merged commit ea3d7e7 into dev Nov 26, 2024
1 check passed
@PMtHk PMtHk deleted the fix/#149 branch November 26, 2024 08:24
@PMtHk PMtHk changed the title [Fix] label 및 sprint 이름 중복시 예외처리 추가 및 toast 추가 [BugFix] label 및 sprint 이름 중복시 예외처리 추가 및 toast 추가 Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BugFix 문제 상황/오류 수정 FE 클라이언트 작업
Projects
None yet
Development

Successfully merging this pull request may close these issues.

라벨 및 스프린트 이름 중복시 예외처리 되지 않는 오류 수정
4 participants