
# ==========================================================
# TEAM HUB - QUERIES (USE where, NOT filter)
# Include ALL fields in TeamHub
# ==========================================================

query listTeamHubs($offset: Int, $limit: Int) @auth(level: USER) {
  teamHubs(offset: $offset, limit: $limit, orderBy: { createdAt: DESC }) {
    id
    teamId
    hubName

    address
    placeId
    latitude
    longitude

    city
    state
    street
    country
    zipCode

    managerName
    isActive
    departments

  }
}

query getTeamHubById($id: UUID!) @auth(level: USER) {
  teamHub(id: $id) {
    id
    teamId
    hubName

    address
    placeId
    latitude
    longitude

    city
    state
    street
    country
    zipCode

    managerName
    isActive
    departments

  }
}

query getTeamHubsByTeamId(
  $teamId: UUID!
  $offset: Int
  $limit: Int
) @auth(level: USER) {
  teamHubs(
    where: { teamId: { eq: $teamId } }
    offset: $offset
    limit: $limit
    orderBy: { createdAt: DESC }
  ) {
    id
    teamId
    hubName

    address
    placeId
    latitude
    longitude

    city
    state
    street
    country
    zipCode

    managerName
    isActive
    departments

  }
}

# ------------------------------------------------------------
# LIST TEAM HUBS BY OWNER (Vendor/Business)
# ------------------------------------------------------------
query listTeamHubsByOwnerId(
  $ownerId: UUID!
  $offset: Int
  $limit: Int
) @auth(level: USER) {
  teamHubs(
    where: {
      team: {
        ownerId: { eq: $ownerId }
      }
    }
    offset: $offset
    limit: $limit
    orderBy: { createdAt: DESC }
  ) {
    id
    teamId
    hubName

    address
    placeId
    latitude
    longitude

    city
    state
    street
    country
    zipCode

    managerName
    isActive
    departments

  }
}
