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

[Fix] Stopwatch bug fix and useMutatuinHandleErorr hook 추가 #471

Merged
merged 15 commits into from
Feb 5, 2024

Conversation

sumi-0011
Copy link
Member

🤔 해결하려는 문제가 무엇인가요?

  • 스톱워치를 백그라운드에서 돌아가게 하였는데, 잘 되지 않았던 이슈가 있어 해결했습니다.
  • 스톱워치 미션 진행중 체크를 오늘 날짜의 미션만 체크하도록 수정하였습니다.
  • useMutation 훅을 래핑해 서버 에러가 발생한 경우에 스낵바를 띄워주는 useMutationHandleError hook을 추가하였습니다. cc. wade

Copy link

vercel bot commented Feb 5, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
10mm-client-web ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 5, 2024 3:38pm

# Conflicts:
#	src/apis/record.ts
Comment on lines 84 to 89
onError: (error: any) => {
if (error.response.data.data.errorClassName === 'MISSION_RECORD_ALREADY_EXISTS_TODAY') {
removeProgressMissionData();
router.replace(ROUTER.HOME);
}
},
Copy link
Collaborator

Choose a reason for hiding this comment

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

isSeverError util 을 쓰면 sever 데이터 타입 추론되게 할 수 있을 것 같아요
(eslint-disable-next-line @typescript-eslint/no-explicit-any 사용하지 않을 수 있음)

Suggested change
onError: (error: any) => {
if (error.response.data.data.errorClassName === 'MISSION_RECORD_ALREADY_EXISTS_TODAY') {
removeProgressMissionData();
router.replace(ROUTER.HOME);
}
},
onError: (error) => {
if(!isSeverError(error)) {
return
}
if (error.response.data.data.errorClassName === 'MISSION_RECORD_ALREADY_EXISTS_TODAY') {
removeProgressMissionData();
router.replace(ROUTER.HOME);
}
},

import { useSnackBar } from '@/components/SnackBar/SnackBarProvider';
import { useMutation, type UseMutationOptions } from '@tanstack/react-query';

interface SnackBarOptions {
Copy link
Collaborator

Choose a reason for hiding this comment

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

마이너) 실제 스넥바의 interface와 같이 연결되면 좋을것 같아서 triggerSnackBar 의 argment 타입인 SnackBarWithoutId 라눈 타입에서 Omit 이나 Pick 을 이용해서 사용하면 좋을 것 같아요

const { triggerSnackBar } = useSnackBar();

// eslint-disable-next-line @typescript-eslint/no-explicit-any
const triggerServerErrorSnackBar = (error: any) => {
Copy link
Collaborator

Choose a reason for hiding this comment

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

여기 error 에 any 타입선언이 안필요하다고 생각되는데 꼭 필요한 걸까요?

Copy link
Member Author

Choose a reason for hiding this comment

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

unknwon으로 변경했습니당

}

function useMutationHandleError<T, _unknown, V>(
options?: UseMutationOptions<T, unknown, V>,
Copy link
Collaborator

Choose a reason for hiding this comment

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

제네릭 너무 좋습니다 굿굿

@sumi-0011 sumi-0011 requested review from wade3420 February 5, 2024 15:14
@sumi-0011 sumi-0011 merged commit 24c8726 into develop Feb 5, 2024
3 checks passed
@sumi-0011 sumi-0011 deleted the fix/stopwatch-background branch February 5, 2024 15:54
Copy link
Contributor

github-actions bot commented Feb 5, 2024

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

Successfully merging this pull request may close these issues.

2 participants