package ru.fincode.core.database.impl.di

import android.content.Context
import dagger.Module
import dagger.Provides
import dagger.hilt.InstallIn
import dagger.hilt.android.qualifiers.ApplicationContext
import dagger.hilt.components.SingletonComponent
import ru.fincode.core.database.impl.AppDatabase
import ru.fincode.core.database.impl.builder.AppDatabaseBuilder
import ru.fincode.tsudesk.core.database.api.schedule.ScheduleDao
import javax.inject.Singleton

@Module
@InstallIn(SingletonComponent::class)
object DatabaseModule {

    @Provides
    @Singleton
    fun provideAppDatabase(@ApplicationContext context: Context): AppDatabase =
        AppDatabaseBuilder.build(context)

    @Provides
    fun provideScheduleDao(db: AppDatabase): ScheduleDao =
        db.scheduleCacheDao()
}
