package com.example.wabi.view.screens.signIn

import androidx.compose.runtime.mutableStateOf
import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import androidx.navigation.NavHostController
import com.example.wabi.domain.network.SupabaseServiceImpl
import com.example.wabi.model.screens.SignInState
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.launch

@HiltViewModel
class SignInViewModel @Inject constructor(private val sup: SupabaseServiceImpl) : ViewModel() {
    private val _data = mutableStateOf(SignInState())
    val data: SignInState get() = _data.value

    fun UpdateData(newData: SignInState) {
        _data.value = newData
    }

    fun signIn(navController: NavHostController) {
        viewModelScope.launch {
            sup.signIn(_data.value.email, _data.value.password)
        }
    }
}