package com.example.quiz.viewModel;

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

import com.example.quiz.data.model.dtos.auth.ChangePin;
import com.example.quiz.data.model.dtos.auth.LoginPayload;
import com.example.quiz.data.model.dtos.auth.LoginResponse;
import com.example.quiz.data.model.dtos.auth.User;
import com.example.quiz.data.repository.LoginRepository;
import com.example.quiz.utils.Result;

import javax.inject.Inject;

import dagger.hilt.android.lifecycle.HiltViewModel;

@HiltViewModel
public class LoginViewModel extends ViewModel {
    LoginRepository loginRepository;

    LiveData<Result<User>> user = new   MutableLiveData<>();
    @Inject
    public LoginViewModel(LoginRepository loginRepository) {
        this.loginRepository = loginRepository;
    }

    public LiveData<Result<LoginResponse>> login(LoginPayload loginPayload){
        return loginRepository.login(loginPayload);
    }

    public LiveData<Result<User>> changePin(String oldPin, String newPin){
        user = loginRepository.changePin(oldPin, newPin);
        return user;
    }
}
