|
@@ -14,7 +14,7 @@ import {
|
|
|
REMOVE_CART_ITEM,
|
|
REMOVE_CART_ITEM,
|
|
|
UPDATE_CART_ITEM,
|
|
UPDATE_CART_ITEM,
|
|
|
} from "@/graphql";
|
|
} from "@/graphql";
|
|
|
-import { AddToCartData, RemoveCartItemData } from "@/types/cart/type";
|
|
|
|
|
|
|
+import { AddToCartData, RemoveCartItemData, UpdateCartItemData } from "@/types/cart/type";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -138,14 +138,26 @@ export const useAddProduct = () => {
|
|
|
};
|
|
};
|
|
|
|
|
|
|
|
//---------Update Cart Product Quantity--------//
|
|
//---------Update Cart Product Quantity--------//
|
|
|
- const [updateCartItem, { loading: isUpdateLoading }] = useMutation(
|
|
|
|
|
|
|
+ const [updateCartItem, { loading: isUpdateLoading }] = useMutation<UpdateCartItemData>(
|
|
|
UPDATE_CART_ITEM,
|
|
UPDATE_CART_ITEM,
|
|
|
{
|
|
{
|
|
|
- onCompleted: (response: any) => {
|
|
|
|
|
|
|
+ onCompleted: (response) => {
|
|
|
const responseData = response?.createUpdateCartItem?.updateCartItem;
|
|
const responseData = response?.createUpdateCartItem?.updateCartItem;
|
|
|
|
|
|
|
|
if (isObject(responseData)) {
|
|
if (isObject(responseData)) {
|
|
|
- dispatch(addItem(responseData as any));
|
|
|
|
|
|
|
+ let cartDetail = {
|
|
|
|
|
+ id: responseData.id,
|
|
|
|
|
+ itemsQty: responseData.itemsQty,
|
|
|
|
|
+ taxAmount: responseData.taxAmount,
|
|
|
|
|
+ shippingAmount: responseData.shippingAmount,
|
|
|
|
|
+ grandTotal: responseData.grandTotal,
|
|
|
|
|
+ items: responseData.items,
|
|
|
|
|
+ paymentMethod: responseData.paymentMethod || '',
|
|
|
|
|
+ paymentMethodTitle: responseData.paymentMethodTitle || '',
|
|
|
|
|
+ selectedShippingRate: responseData.selectedShippingRate || '',
|
|
|
|
|
+ selectedShippingRateTitle: responseData.selectedShippingRateTitle || '',
|
|
|
|
|
+ };
|
|
|
|
|
+ dispatch(addItem(cartDetail));
|
|
|
} else {
|
|
} else {
|
|
|
showToast("Something went wrong!", "warning");
|
|
showToast("Something went wrong!", "warning");
|
|
|
}
|
|
}
|