// =============================================================================
// 🛠️ ЗАПРОСЫ ДЛЯ УСЛУГ ФУЛФИЛМЕНТА V2
// =============================================================================

import { gql } from '@apollo/client'

// Мои услуги (для фулфилмента)
export const GET_MY_FULFILLMENT_SERVICES_V2 = gql`
  query GetMyFulfillmentServicesV2 {
    myFulfillmentServices {
      id
      fulfillmentId
      name
      description
      price
      unit
      isActive
      imageUrl
      sortOrder
      createdAt
      updatedAt
      fulfillment {
        id
        name
      }
    }
  }
`

// Мои расходники (для фулфилмента)
export const GET_MY_FULFILLMENT_CONSUMABLES_V2 = gql`
  query GetMyFulfillmentConsumablesV2 {
    myFulfillmentConsumables {
      id
      fulfillmentId
      inventoryId
      name
      nameForSeller
      article
      pricePerUnit
      unit
      minStock
      currentStock
      isAvailable
      imageUrl
      sortOrder
      createdAt
      updatedAt
      fulfillment {
        id
        name
      }
      inventory {
        id
        currentStock
        product {
          name
        }
      }
    }
  }
`

// Моя логистика (для фулфилмента)
export const GET_MY_FULFILLMENT_LOGISTICS_V2 = gql`
  query GetMyFulfillmentLogisticsV2 {
    myFulfillmentLogistics {
      id
      fulfillmentId
      fromLocation
      toLocation
      fromAddress
      toAddress
      priceUnder1m3
      priceOver1m3
      estimatedDays
      description
      isActive
      sortOrder
      createdAt
      updatedAt
      fulfillment {
        id
        name
      }
    }
  }
`

// Услуги конкретного фулфилмента (для селлеров при создании поставки)
export const GET_FULFILLMENT_SERVICES_BY_ID = gql`
  query GetFulfillmentServicesById($fulfillmentId: ID!) {
    fulfillmentServicesById(fulfillmentId: $fulfillmentId) {
      id
      name
      description
      price
      unit
      isActive
      imageUrl
      sortOrder
    }
  }
`

// Расходники конкретного фулфилмента (для селлеров при создании поставки)
export const GET_FULFILLMENT_CONSUMABLES_BY_ID = gql`
  query GetFulfillmentConsumablesById($fulfillmentId: ID!) {
    fulfillmentConsumablesById(fulfillmentId: $fulfillmentId) {
      id
      name
      nameForSeller
      article
      pricePerUnit
      unit
      minStock
      currentStock
      isAvailable
      imageUrl
      sortOrder
    }
  }
`

// =============================================================================
// 🔧 V2 МУТАЦИИ ДЛЯ УСЛУГ ФУЛФИЛМЕНТА
// =============================================================================

// Создание услуги
export const CREATE_FULFILLMENT_SERVICE = gql`
  mutation CreateFulfillmentService($input: CreateFulfillmentServiceInput!) {
    createFulfillmentService(input: $input) {
      success
      message
      service {
        id
        fulfillmentId
        name
        nameForSeller
        price
        unit
        isActive
        imageUrl
        sortOrder
        createdAt
        updatedAt
        fulfillment {
          id
          name
        }
      }
    }
  }
`

// Обновление услуги
export const UPDATE_FULFILLMENT_SERVICE = gql`
  mutation UpdateFulfillmentService($input: UpdateFulfillmentServiceInput!) {
    updateFulfillmentService(input: $input) {
      success
      message
      service {
        id
        fulfillmentId
        name
        nameForSeller
        price
        unit
        isActive
        imageUrl
        sortOrder
        createdAt
        updatedAt
        fulfillment {
          id
          name
        }
      }
    }
  }
`

// Удаление услуги
export const DELETE_FULFILLMENT_SERVICE = gql`
  mutation DeleteFulfillmentService($id: ID!) {
    deleteFulfillmentService(id: $id)
  }
`

// =============================================================================
// 📦 V2 МУТАЦИИ ДЛЯ РАСХОДНИКОВ ФУЛФИЛМЕНТА
// =============================================================================

// Создание расходника
export const CREATE_FULFILLMENT_CONSUMABLE = gql`
  mutation CreateFulfillmentConsumable($input: CreateFulfillmentConsumableInput!) {
    createFulfillmentConsumable(input: $input) {
      success
      message
      consumable {
        id
        fulfillmentId
        inventoryId
        name
        nameForSeller
        article
        pricePerUnit
        unit
        minStock
        currentStock
        isAvailable
        imageUrl
        sortOrder
        createdAt
        updatedAt
        fulfillment {
          id
          name
        }
        inventory {
          id
          currentStock
          product {
            name
          }
        }
      }
    }
  }
`

// Обновление расходника
export const UPDATE_FULFILLMENT_CONSUMABLE = gql`
  mutation UpdateFulfillmentConsumable($input: UpdateFulfillmentConsumableInput!) {
    updateFulfillmentConsumable(input: $input) {
      success
      message
      consumable {
        id
        fulfillmentId
        inventoryId
        name
        nameForSeller
        article
        pricePerUnit
        unit
        minStock
        currentStock
        isAvailable
        imageUrl
        sortOrder
        createdAt
        updatedAt
        fulfillment {
          id
          name
        }
        inventory {
          id
          currentStock
          product {
            name
          }
        }
      }
    }
  }
`

// Удаление расходника
export const DELETE_FULFILLMENT_CONSUMABLE = gql`
  mutation DeleteFulfillmentConsumable($id: ID!) {
    deleteFulfillmentConsumable(id: $id)
  }
`

// =============================================================================
// 🚚 V2 МУТАЦИИ ДЛЯ ЛОГИСТИКИ ФУЛФИЛМЕНТА
// =============================================================================

// Создание логистического маршрута
export const CREATE_FULFILLMENT_LOGISTICS = gql`
  mutation CreateFulfillmentLogistics($input: CreateFulfillmentLogisticsInput!) {
    createFulfillmentLogistics(input: $input) {
      success
      message
      logistics {
        id
        fulfillmentId
        fromLocation
        toLocation
        fromAddress
        toAddress
        priceUnder1m3
        priceOver1m3
        estimatedDays
        nameForSeller
        isActive
        sortOrder
        createdAt
        updatedAt
        fulfillment {
          id
          name
        }
      }
    }
  }
`

// Обновление логистического маршрута
export const UPDATE_FULFILLMENT_LOGISTICS = gql`
  mutation UpdateFulfillmentLogistics($input: UpdateFulfillmentLogisticsInput!) {
    updateFulfillmentLogistics(input: $input) {
      success
      message
      logistics {
        id
        fulfillmentId
        fromLocation
        toLocation
        fromAddress
        toAddress
        priceUnder1m3
        priceOver1m3
        estimatedDays
        nameForSeller
        isActive
        sortOrder
        createdAt
        updatedAt
        fulfillment {
          id
          name
        }
      }
    }
  }
`

// Удаление логистического маршрута
export const DELETE_FULFILLMENT_LOGISTICS = gql`
  mutation DeleteFulfillmentLogistics($id: ID!) {
    deleteFulfillmentLogistics(id: $id)
  }
`