File tree 1 file changed +15
-16
lines changed 1 file changed +15
-16
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,8 @@ const useMakeOrder = () => {
7
7
const { auth, logout } = useAuth ( ) ;
8
8
const queryClient = useQueryClient ( ) ;
9
9
10
- return useMutation (
11
- async ( customerInfo ) => {
10
+ return useMutation ( {
11
+ mutationFn : async ( customerInfo ) => {
12
12
const response = await privateAxios . post ( "/orders/" , customerInfo , {
13
13
headers : {
14
14
"Content-Type" : "application/json" ,
@@ -17,20 +17,19 @@ const useMakeOrder = () => {
17
17
} ) ;
18
18
return response . data ;
19
19
} ,
20
- {
21
- onSuccess : ( data ) => {
22
- console . log ( "Added to cart: " , data ) ;
23
- queryClient . invalidateQueries ( [ "productsInCart" ] ) ;
24
- } ,
25
- onError : ( error ) => {
26
- // eslint-disable-next-line no-console
27
- console . error ( "Unable to add availability" ) ;
28
- if ( error . response . status === 401 ) {
29
- logout ( ) ;
30
- }
31
- } ,
32
- }
33
- ) ;
20
+
21
+ onSuccess : ( data ) => {
22
+ console . log ( "Added to cart: " , data ) ;
23
+ queryClient . invalidateQueries ( { queryKey : [ "productsInCart" ] } ) ;
24
+ } ,
25
+ onError : ( error ) => {
26
+ // eslint-disable-next-line no-console
27
+ console . error ( "Unable to add availability" ) ;
28
+ if ( error . response . status === 401 ) {
29
+ logout ( ) ;
30
+ }
31
+ } ,
32
+ } ) ;
34
33
} ;
35
34
36
35
export default useMakeOrder ;
You can’t perform that action at this time.
0 commit comments