package com.prodhack.moscow2025.presentation.screens.editResume

import androidx.lifecycle.viewModelScope
import com.prodhack.moscow2025.domain.usecase.auth.ValidateFieldsUseCase
import com.prodhack.moscow2025.domain.usecase.resumes.GetResumeInfoUseCase
import com.prodhack.moscow2025.domain.usecase.resumes.PostResumeUseCase
import com.prodhack.moscow2025.domain.usecase.resumes.SuggestSkillsUseCase
import com.prodhack.moscow2025.presentation.screens.createResume.BaseCreateResumeViewModel
import kotlinx.coroutines.launch
import org.koin.android.annotation.KoinViewModel
import org.koin.core.annotation.Provided

@KoinViewModel
class EditResumeViewModel(
	private val getResumeInfoUseCase: GetResumeInfoUseCase,
	suggestSkillsUseCase: SuggestSkillsUseCase,
	validateDataUseCase: ValidateFieldsUseCase,
	postResumeUseCase: PostResumeUseCase,
	@Provided resumeId: String
) : BaseCreateResumeViewModel(
	suggestSkillsUseCase = suggestSkillsUseCase,
	validateDataUseCase = validateDataUseCase,
	postResumeUseCase = postResumeUseCase
) {
//	private val resumeId: String =
//		savedStateHandle.get<String>(AppDestination.ResumeEdit.ARG_ID)
//			?: savedStateHandle.get<String>("id") ?: ""

	init {
		viewModelScope.launch {
			getResumeInfoUseCase(resumeId).collect { result ->
				result.getOrNull()?.let { prefill(it) }
			}
		}
	}
}
