-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* feat: 총 금액이 0원 이하일 때와 아닐 때의 로직 분리 * fix: 로직 수정 및 에러 토스트 메시지로 변환 * fix: 톤매너 정립 --------- Co-authored-by: Eugene Kim <[email protected]>
- Loading branch information
Showing
4 changed files
with
58 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { useNavigate } from 'react-router-dom'; | ||
import { useMutation } from '@tanstack/react-query'; | ||
import ordersApi from '@/apis/orders/ordersApi'; | ||
import RoutePath from '@/routes/routePath'; | ||
import { toast } from 'react-toastify'; | ||
|
||
const usePostFreeOrder = (amount: number) => { | ||
const navigate = useNavigate(); | ||
|
||
const { mutate: postFreeOrder, ...rest } = useMutation({ | ||
onMutate: () => { | ||
if (amount) toast('결제를 실패했어요. 문제가 지속되면 문의해주세요.'); | ||
}, | ||
mutationFn: ordersApi.POST_PREV_FREE_ORDER, | ||
onError: () => navigate(RoutePath.PaymentsCheckout), | ||
onSuccess: () => navigate(RoutePath.Dashboard) | ||
}); | ||
|
||
return { postFreeOrder, ...rest }; | ||
}; | ||
|
||
export default usePostFreeOrder; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters