import { gql, TypedDocumentNode } from "@apollo/client";
import { AddToCartData } from "@/types/cart/type";

export const CREATE_ADD_PRODUCT_IN_CART: TypedDocumentNode<AddToCartData> = gql`
  mutation createAddProductInCart(
    $cartId: Int
    $productId: Int!
    $quantity: Int!
    $variantId: Int
  ) {
    createAddProductInCart(
      input: {
        cartId: $cartId
        productId: $productId
        quantity: $quantity
        variantId: $variantId
      }
    ) {
      addProductInCart {
        id
        cartToken
        sessionToken
        appliedTaxes
        itemsQty
        isGuest
        itemsCount
        items {
          edges {
            node {
              id
              cartId
              productId
              name
              price
              baseImage
              sku
              quantity
              type
              productUrlKey
              canChangeQty
            }
          }
        }
        subtotal
        subTotalInclTax
        discountAmount
        taxAmount
        taxTotal
        shippingAmount
        shippingAmountInclTax
        grandTotal
        formattedSubtotal
        formattedSubTotalInclTax
        formattedDiscountAmount
        formattedTaxAmount
        formattedTaxTotal
        formattedShippingAmount
        formattedShippingAmountInclTax
        formattedGrandTotal
        couponCode
        selectedShippingRate
        selectedShippingRateTitle
        paymentMethod
        paymentMethodTitle
        haveStockableItems
        billingAddress
        shippingAddress
        success
        message
      }
    }
  }
`;
