package com.example.quiz.viewModel;

import androidx.lifecycle.LiveData;
import androidx.lifecycle.ViewModel;

import com.example.quiz.data.model.Course;
import com.example.quiz.data.model.Restriction;
import com.example.quiz.data.model.dtos.auth.User;
import com.example.quiz.data.repository.AgentRepository;
import com.example.quiz.utils.Result;

import java.util.List;

import javax.inject.Inject;

import dagger.hilt.android.lifecycle.HiltViewModel;

@HiltViewModel
public class AgentViewModel extends ViewModel {
    private final AgentRepository agentRepository;

    private LiveData<Result<List<User>>> agents;

    private LiveData<Result<User>> agentDetails;

    private LiveData<Result<List<Course.TypeParis>>> availableBets;


    @Inject
    public AgentViewModel(AgentRepository agentRepository) {
        this.agentRepository = agentRepository;
    }

    public LiveData<Result<List<User>>> getAgents(String agentId) {
        agents = agentRepository.getAgents(agentId);
        return agents;
    }

    public LiveData<Result<User>> getAgentById(String agentId) {
        agentDetails = agentRepository.getAgentById(agentId);
        return agentDetails;
    }

    public LiveData<Result<List<Course.TypeParis>>> getAvailableBets(String agentId) {
        availableBets = agentRepository.getAvailableBets(agentId);
        return availableBets;
    }

    public LiveData<Result<Void>> setAccess(String masterId, String slaveId, boolean access) {
        return agentRepository.setAccess(masterId, slaveId, access);
    };

    public LiveData<Result<Void>> setRestrictions(String masterId, String slaveId, Restriction restrictions) {
        return agentRepository.setRestrictions(masterId, slaveId, restrictions);
    }
}
