forked from GDSC-Hongik/gdsc-client
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'GDSC-Hongik:dev' into dev
- Loading branch information
Showing
9 changed files
with
78 additions
and
34 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
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
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
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