package com.sunzones.domain.usecase

import com.sunzones.data.repository.LocationRepository
import com.sunzones.domain.model.SunLocation
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.map
import javax.inject.Inject

class GetLocationsUseCase @Inject constructor(
    private val repository: LocationRepository,
    private val calculateSunTimes: CalculateSunTimesUseCase
) {
    operator fun invoke(): Flow<List<SunLocation>> =
        repository.getAllLocations().map { entities ->
            entities.map { entity -> calculateSunTimes(entity) }
        }
}
