package com.example.elva.ui.sos

import androidx.lifecycle.ViewModel
import androidx.lifecycle.viewModelScope
import com.example.elva.data.remote.model.CreateAlertRequest
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject
import kotlinx.coroutines.launch

@HiltViewModel
class SosViewModel @Inject constructor() : ViewModel() {

    fun sendAlert(
        type: String,
        latitude: String,
        longitude: String,
        address: String,
        message: String
    ) {
        viewModelScope.launch {
            // TODO connect to EmergencyRepository
            val request = CreateAlertRequest(
                alertType = type,
                latitude = latitude.toDoubleOrNull() ?: 0.0,
                longitude = longitude.toDoubleOrNull() ?: 0.0,
                address = address,
                message = message
            )
        }
    }
}

