import { ConsoleLogger } from '@adapters/logging/ConsoleLogger';
import { GetAllNotificationsUseCase } from '@core/notifications/application/use-cases/GetAllNotificationsUseCase';
import { GetUnreadNotificationsUseCase } from '@core/notifications/application/use-cases/GetUnreadNotificationsUseCase';
import { MarkNotificationReadUseCase } from '@core/notifications/application/use-cases/MarkNotificationReadUseCase';
import { NotificationRepository } from '@core/notifications/domain/repositories/NotificationRepository';
import type { Logger } from '@core/shared/domain/Logger';
import { Provider } from '@nestjs/common';
import { NOTIFICATION_REPOSITORY_TOKEN } from '../../persistence/notifications/NotificationsPersistenceTokens';
import {
    GET_ALL_NOTIFICATIONS_USE_CASE_TOKEN,
    GET_UNREAD_NOTIFICATIONS_USE_CASE_TOKEN,
    LOGGER_TOKEN,
    MARK_NOTIFICATION_READ_USE_CASE_TOKEN,
} from './NotificationsTokens';

export const NotificationsProviders: Provider[] = [
  {
    provide: LOGGER_TOKEN,
    useClass: ConsoleLogger,
  },
  {
    provide: GET_UNREAD_NOTIFICATIONS_USE_CASE_TOKEN,
    useFactory: (repo: NotificationRepository, logger: Logger) => new GetUnreadNotificationsUseCase(repo, logger),
    inject: [NOTIFICATION_REPOSITORY_TOKEN, LOGGER_TOKEN],
  },
  {
    provide: GET_ALL_NOTIFICATIONS_USE_CASE_TOKEN,
    useFactory: (repo: NotificationRepository, logger: Logger) => new GetAllNotificationsUseCase(repo, logger),
    inject: [NOTIFICATION_REPOSITORY_TOKEN, LOGGER_TOKEN],
  },
  {
    provide: MARK_NOTIFICATION_READ_USE_CASE_TOKEN,
    useFactory: (repo: NotificationRepository, logger: Logger) => new MarkNotificationReadUseCase(repo, logger),
    inject: [NOTIFICATION_REPOSITORY_TOKEN, LOGGER_TOKEN],
  },
];
