import { gql } from '@apollo/client'

export const GET_MY_FULFILLMENT_CONSUMABLE_SUPPLIES = gql`
  query GetMyFulfillmentConsumableSupplies {
    myFulfillmentConsumableSupplies {
      id
      status
      fulfillmentCenterId
      fulfillmentCenter {
        id
        name
        inn
      }
      requestedDeliveryDate
      resalePricePerUnit
      minStockLevel
      notes
      
      supplierId
      supplier {
        id
        name
        inn
      }
      supplierApprovedAt
      packagesCount
      estimatedVolume
      supplierContractId
      supplierNotes
      
      logisticsPartnerId
      logisticsPartner {
        id
        name
        inn
      }
      estimatedDeliveryDate
      routeId
      logisticsCost
      logisticsNotes
      
      shippedAt
      trackingNumber
      
      receivedAt
      receivedById
      receivedBy {
        id
        managerName
        phone
      }
      actualQuantity
      defectQuantity
      receiptNotes
      
      items {
        id
        productId
        product {
          id
          name
          article
          price
          quantity
          mainImage
        }
        requestedQuantity
        approvedQuantity
        shippedQuantity
        receivedQuantity
        defectQuantity
        unitPrice
        totalPrice
      }
      
      createdAt
      updatedAt
    }
  }
`

export const GET_FULFILLMENT_CONSUMABLE_SUPPLY = gql`
  query GetFulfillmentConsumableSupply($id: ID!) {
    fulfillmentConsumableSupply(id: $id) {
      id
      status
      fulfillmentCenterId
      fulfillmentCenter {
        id
        name
        inn
      }
      requestedDeliveryDate
      resalePricePerUnit
      minStockLevel
      notes
      
      supplierId
      supplier {
        id
        name
        inn
      }
      supplierApprovedAt
      packagesCount
      estimatedVolume
      supplierContractId
      supplierNotes
      
      logisticsPartnerId
      logisticsPartner {
        id
        name
        inn
      }
      estimatedDeliveryDate
      routeId
      logisticsCost
      logisticsNotes
      
      shippedAt
      trackingNumber
      
      receivedAt
      receivedById
      receivedBy {
        id
        managerName
        phone
      }
      actualQuantity
      defectQuantity
      receiptNotes
      
      items {
        id
        productId
        product {
          id
          name
          article
          price
          quantity
          mainImage
        }
        requestedQuantity
        approvedQuantity
        shippedQuantity
        receivedQuantity
        defectQuantity
        unitPrice
        totalPrice
      }
      
      createdAt
      updatedAt
    }
  }
`

export const GET_MY_SUPPLIER_CONSUMABLE_SUPPLIES = gql`
  query GetMySupplierConsumableSupplies {
    mySupplierConsumableSupplies {
      id
      status
      fulfillmentCenterId
      fulfillmentCenter {
        id
        name
        inn
      }
      requestedDeliveryDate
      resalePricePerUnit
      minStockLevel
      notes
      
      supplierId
      supplier {
        id
        name
        inn
      }
      supplierApprovedAt
      packagesCount
      estimatedVolume
      supplierContractId
      supplierNotes
      
      logisticsPartnerId
      logisticsPartner {
        id
        name
        inn
      }
      estimatedDeliveryDate
      routeId
      logisticsCost
      logisticsNotes
      
      shippedAt
      trackingNumber
      
      receivedAt
      receivedById
      receivedBy {
        id
        managerName
        phone
      }
      actualQuantity
      defectQuantity
      receiptNotes
      
      items {
        id
        productId
        product {
          id
          name
          article
          price
          quantity
          mainImage
        }
        requestedQuantity
        approvedQuantity
        shippedQuantity
        receivedQuantity
        defectQuantity
        unitPrice
        totalPrice
      }
      
      createdAt
      updatedAt
    }
  }
`

export const CREATE_FULFILLMENT_CONSUMABLE_SUPPLY = gql`
  mutation CreateFulfillmentConsumableSupply($input: CreateFulfillmentConsumableSupplyInput!) {
    createFulfillmentConsumableSupply(input: $input) {
      success
      message
      supplyOrder {
        id
        status
        createdAt
      }
    }
  }
`