package com.zaojiao.app.data.repo.impl

import com.zaojiao.app.core.common.remote.di.ApplicationScope
import com.zaojiao.app.core.common.state.DataState
import com.zaojiao.app.data.local.baby.LocalBabyData
import com.zaojiao.app.data.model.BabyModel
import com.zaojiao.app.data.remote.RemoteBabyData
import com.zaojiao.app.data.repo.BabyRepository
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
import javax.inject.Inject

class BabyRepositoryImpl @Inject constructor(
    private val localBabyData: LocalBabyData,
    private val remoteBabyData: RemoteBabyData,
    @ApplicationScope private val coroutineScope: CoroutineScope,
) : BabyRepository {

    override val current: Flow<BabyModel?> get() = localBabyData.current

    override val babyList: Flow<List<BabyModel>> get() = localBabyData.list
    override suspend fun getBaby() {
        remoteBabyData.getBabyList().apply {
            when (this) {
                is DataState.Failure -> {

                }

                is DataState.Success -> {
                    localBabyData.updateList(data ?: emptyList())
                }
            }
        }
    }

    override suspend fun deleteBaby() {
        TODO("Not yet implemented")
    }

    override suspend fun deleteAllBaby() {
        TODO("Not yet implemented")
    }
}