
# ------------------------------------------------------------
# LIST SHIFTS (paginated)
# ------------------------------------------------------------
query listShifts(
  $offset: Int
  $limit: Int
) @auth(level: USER) {
  shifts(offset: $offset, limit: $limit) {
    id
    title

    orderId

    date
    startTime
    endTime
    hours
    cost

    location
    locationAddress
    latitude
    longitude
    description

    status
    workersNeeded
    filled
    filledAt

    managers
    durationDays

    createdAt
    updatedAt
    createdBy

    order {
      id
      eventName
      status
      orderType
      businessId
      vendorId
      business { id businessName email contactName }
      vendor { id companyName }
    }
  }
}

# ------------------------------------------------------------
# GET SHIFT BY ID
# ------------------------------------------------------------
query getShiftById($id: UUID!) @auth(level: USER) {
  shift(id: $id) {
    id
    title

    orderId

    date
    startTime
    endTime
    hours
    cost

    location
    locationAddress
    latitude
    longitude
    description

    status
    workersNeeded
    filled
    filledAt

    managers
    durationDays

    createdAt
    updatedAt
    createdBy

    order {
      id
      eventName
      status
      orderType
      businessId
      vendorId
      business { id businessName email contactName }
      vendor { id companyName }
    }
  }
}

# ------------------------------------------------------------
# FILTER SHIFTS (by status/orderId/date range)
# NOTE: Timestamp filters use ge/le (not gte/lte)
# ------------------------------------------------------------
query filterShifts(
  $status: ShiftStatus
  $orderId: UUID

  $dateFrom: Timestamp
  $dateTo: Timestamp

  $offset: Int
  $limit: Int
) @auth(level: USER) {
  shifts(
    where: {
      status: { eq: $status }
      orderId: { eq: $orderId }
      date: { ge: $dateFrom, le: $dateTo }
    }
    offset: $offset
    limit: $limit
  ) {
    id
    title

    orderId

    date
    startTime
    endTime
    hours
    cost

    location
    locationAddress
    latitude
    longitude
    description

    status
    workersNeeded
    filled
    filledAt

    managers
    durationDays

    createdAt
    updatedAt
    createdBy

    order {
      id
      eventName
      status
      orderType
      businessId
      vendorId
      business { id businessName email contactName }
      vendor { id companyName }
    }
  }
}

# ------------------------------------------------------------
# BUSINESS: GET SHIFTS FOR A BUSINESS (via order.businessId)
# ------------------------------------------------------------
query getShiftsByBusinessId(
  $businessId: UUID!
  $dateFrom: Timestamp
  $dateTo: Timestamp
  $offset: Int
  $limit: Int
) @auth(level: USER) {
  shifts(
    where: {
      order: { businessId: { eq: $businessId } }
      date: { ge: $dateFrom, le: $dateTo }
    }
    offset: $offset
    limit: $limit
  ) {
    id
    title

    orderId

    date
    startTime
    endTime
    hours
    cost

    location
    locationAddress
    latitude
    longitude
    description

    status
    workersNeeded
    filled
    filledAt

    managers
    durationDays

    createdAt
    updatedAt
    createdBy

    order {
      id
      eventName
      status
      orderType
      businessId
      vendorId
      business { id businessName email contactName }
      vendor { id companyName }
    }
  }
}

# ------------------------------------------------------------
# VENDOR: GET SHIFTS FOR A VENDOR (via order.vendorId)
# ------------------------------------------------------------
query getShiftsByVendorId(
  $vendorId: UUID!
  $dateFrom: Timestamp
  $dateTo: Timestamp
  $offset: Int
  $limit: Int
) @auth(level: USER) {
  shifts(
    where: {
      order: { vendorId: { eq: $vendorId } }
      date: { ge: $dateFrom, le: $dateTo }
    }
    offset: $offset
    limit: $limit
  ) {
    id
    title

    orderId

    date
    startTime
    endTime
    hours
    cost

    location
    locationAddress
    latitude
    longitude
    description

    status
    workersNeeded
    filled
    filledAt

    managers
    durationDays

    createdAt
    updatedAt
    createdBy

    order {
      id
      eventName
      status
      orderType
      businessId
      vendorId
      business { id businessName email contactName }
      vendor { id companyName }
    }
  }
}
