# ------------------------------------------------------------
# LIST ALL ORDERS
# ------------------------------------------------------------
query listOrders(
  $offset: Int
  $limit: Int
) @auth(level: USER) {
  orders(offset: $offset, limit: $limit) {
    id
    eventName

    vendorId
    businessId
    orderType
    location
    status
    date
    startDate
    endDate
    duration
    lunchBreak
    total
    assignedStaff
    shifts
    requested
    hub
    recurringDays
    permanentDays
    poReference
    detectedConflicts
    notes
    createdAt

    business {
      id
      businessName
      email
      contactName
    }

    vendor {
      id
      companyName
    }
  }
}

# ------------------------------------------------------------
# GET ORDER BY ID
# ------------------------------------------------------------
query getOrderById($id: UUID!) @auth(level: USER) {
  order(id: $id) {
    id
    eventName

    vendorId
    businessId
    orderType
    location
    status
    date
    startDate
    endDate
    duration
    lunchBreak
    total
    assignedStaff
    shifts
    requested
    hub
    recurringDays
    permanentDays
    poReference
    detectedConflicts
    notes
    createdAt

    business {
      id
      businessName
      email
      contactName
    }

    vendor {
      id
      companyName
    }
  }
}

# ------------------------------------------------------------
# GET ORDERS BY BUSINESS
# ------------------------------------------------------------
query getOrdersByBusinessId(
  $businessId: UUID!
  $offset: Int
  $limit: Int
) @auth(level: USER) {
  orders(
    where: { businessId: { eq: $businessId } }
    offset: $offset
    limit: $limit
  ) {
    id
    eventName

    vendorId
    businessId
    orderType
    location
    status
    date
    startDate
    endDate
    duration
    lunchBreak
    total
    assignedStaff
    shifts
    requested
    hub
    recurringDays
    permanentDays
    poReference
    detectedConflicts
    notes
    createdAt

    business {
      id
      businessName
      email
      contactName
    }

    vendor {
      id
      companyName
    }
  }
}

# ------------------------------------------------------------
# GET ORDERS BY VENDOR
# ------------------------------------------------------------
query getOrdersByVendorId(
  $vendorId: UUID!
  $offset: Int
  $limit: Int
) @auth(level: USER) {
  orders(
    where: { vendorId: { eq: $vendorId } }
    offset: $offset
    limit: $limit
  ) {
    id
    eventName

    vendorId
    businessId
    orderType
    location
    status
    date
    startDate
    endDate
    duration
    lunchBreak
    total
    assignedStaff
    shifts
    requested
    hub
    recurringDays
    permanentDays
    poReference
    detectedConflicts
    notes
    createdAt

    business {
      id
      businessName
      email
      contactName
    }

    vendor {
      id
      companyName
    }
  }
}

# ------------------------------------------------------------
# GET ORDERS BY STATUS
# ------------------------------------------------------------
query getOrdersByStatus(
  $status: OrderStatus!
  $offset: Int
  $limit: Int
) @auth(level: USER) {
  orders(
    where: { status: { eq: $status } }
    offset: $offset
    limit: $limit
  ) {
    id
    eventName

    vendorId
    businessId
    orderType
    location
    status
    date
    startDate
    endDate
    duration
    lunchBreak
    total
    assignedStaff
    shifts
    requested
    hub
    recurringDays
    permanentDays
    poReference
    detectedConflicts
    notes
    createdAt

    business {
      id
      businessName
      email
      contactName
    }

    vendor {
      id
      companyName
    }
  }
}

# ------------------------------------------------------------
# GET ORDERS BY DATE RANGE
# ------------------------------------------------------------
query getOrdersByDateRange(
  $start: Timestamp!
  $end: Timestamp!
  $offset: Int
  $limit: Int
) @auth(level: USER) {
  orders(
    where: {
      date: { ge: $start, le: $end }
    }
    offset: $offset
    limit: $limit
  ) {
    id
    eventName

    vendorId
    businessId
    orderType
    location
    status
    date
    startDate
    endDate
    duration
    lunchBreak
    total
    assignedStaff
    shifts
    requested
    hub
    recurringDays
    permanentDays
    poReference
    detectedConflicts
    notes
    createdAt

    business {
      id
      businessName
      email
      contactName
    }

    vendor {
      id
      companyName
    }
  }
}

# ------------------------------------------------------------
# GET RAPID ORDERS
# ------------------------------------------------------------
query getRapidOrders(
  $offset: Int
  $limit: Int
) @auth(level: USER) {
  orders(
    where: { orderType: { eq: RAPID } }
    offset: $offset
    limit: $limit
  ) {
    id
    eventName

    vendorId
    businessId
    orderType
    location
    status
    date
    startDate
    endDate
    duration
    lunchBreak
    total
    assignedStaff
    shifts
    requested
    hub
    recurringDays
    permanentDays
    poReference
    detectedConflicts
    notes
    createdAt

    business {
      id
      businessName
      email
      contactName
    }

    vendor {
      id
      companyName
    }
  }
}
