//
//  NavigationViewModel.swift
//  PadelClub
//
//  Created by Razmig Sarkissian on 03/04/2024.
//

import SwiftUI

@Observable
class NavigationViewModel {
    var path = NavigationPath()
    var toolboxPath = NavigationPath()
    var umpirePath = NavigationPath()
    var ongoingPath = NavigationPath()
    var selectedTab: TabDestination?
    var agendaDestination: AgendaDestination? = .activity
    var organizerTournament: Tournament?
    
    func isTournamentAlreadyOpenInOrganizer(_ tournament: Tournament) -> Bool {
        organizerTournament?.id == tournament.id
    }
    
    func closeTournamentFromOrganizer(_ tournament: Tournament) {
        tournament.navigationPath.removeAll()
        organizerTournament = nil
    }
    
    func openTournamentInOrganizer(_ tournament: Tournament) {
        organizerTournament = tournament
        if selectedTab != .tournamentOrganizer {
            selectedTab = .tournamentOrganizer
        }
    }
}
