# import PaginatorParts from '../fragments/paginator.fragment.graphql'
# import PaymentIntentParts from '../fragments/payment_intent.fragment.graphql'
# import ReviewParts from './reviews.graphql'

fragment OrderParts on Order {
  id
  tracking_number
  customer_name
  customer_contact
  customer_name
  language
  customer {
    name
    email
  }
  order_status
  payment_status
  payment_intent {
    ...PaymentIntentParts
  }
  products {
    id
    name
    slug
    price
    sale_price
    created_at
    my_review {
      id
      variation_option_id
      rating
      comment
      photos {
        id
        thumbnail
        original
      }
    }
    image {
      id
      original
      thumbnail
    }
    variation_options {
      id
      title
    }
    pivot {
      variation_option_id
      order_quantity
      unit_price
      subtotal
    }
    shop_id
    quantity
    unit
  }
  amount
  sales_tax
  total
  paid_total
  payment_id
  payment_gateway
  altered_payment_gateway
  coupon {
    code
    amount
    type
  }
  discount
  delivery_fee
  delivery_time
  coupon {
    id
    code
  }
  billing_address {
    country
    city
    state
    zip
    street_address
  }
  shipping_address {
    country
    city
    state
    zip
    street_address
  }
  refund {
    id
    title
    amount
    status
  }
  wallet_point {
    id
    amount
  }
  created_at
  updated_at
  note
  reviews {
    ...ReviewParts
  }
}
query Orders(
  $tracking_number: String
  $orderBy: String
  $sortedBy: String
  $customer_id: ID
  $shop_id: ID
  $first: Int = 10
  $page: Int
) {
  orders(
    tracking_number: $tracking_number
    orderBy: $orderBy
    sortedBy: $sortedBy
    customer_id: $customer_id
    shop_id: $shop_id
    first: $first
    page: $page
  ) {
    data {
      ...OrderParts
    }
    paginatorInfo {
      ...PaginatorParts
    }
  }
}

query Order($tracking_number: String, $id: ID) {
  order(tracking_number: $tracking_number, id: $id) {
    ...OrderParts
    children {
      ...OrderParts
    }
  }
}

mutation VerifyCheckout($input: CheckoutVerificationInput!) {
  verifyCheckout(input: $input) {
    total_tax
    shipping_charge
    unavailable_products
    wallet_amount
    wallet_currency
  }
}

mutation CreateOrder($input: CreateOrderInput!) {
  createOrder(input: $input) {
    ...OrderParts
  }
}

mutation CreateOrderPayment($input: CreateOrderPaymentInput!) {
  createOrderPayment(input: $input)
}
