package com.example.quiz.data.database;

import android.content.Context;

import androidx.room.Room;

import com.example.quiz.data.dao.UserActivityLogDao;

import javax.inject.Singleton;

import dagger.Module;
import dagger.Provides;
import dagger.hilt.InstallIn;
import dagger.hilt.android.qualifiers.ApplicationContext;
import dagger.hilt.components.SingletonComponent;

@Module
@InstallIn(SingletonComponent.class)
public class DatabaseModule {

    @Provides
    @Singleton
    public static AppDataBase provideDatabase(@ApplicationContext Context context) {
        return Room.databaseBuilder(context, AppDataBase.class, "QuizDB")
                .fallbackToDestructiveMigration()
                .build();
    }

    @Provides
    public static UserActivityLogDao provideUserActivityLogDao(AppDataBase db) {
        return db.logsDao(); // ton DAO
    }
}
