import 'package:flutter/foundation.dart';
import 'package:injectable/injectable.dart';
import 'package:krow/features/notificatins/domain/notification_entity.dart';

import '../domain/notification_repository.dart';
import 'notifications_api_provider.dart';

@Singleton(as: NotificationsRepository)
class NotificationsRepositoryImpl implements NotificationsRepository {
  final NotificationsApiProvider apiProvider;

  NotificationsRepositoryImpl({required this.apiProvider});

  @override
  Future<List<NotificationEntity>> fetchNotifications() async {
    try {
      // final response = await apiProvider.fetchNotifications();
      // return response;
      if (!kDebugMode) {
        return [
          NotificationEntity(
            id: '1',
            title: 'Test Notification',
            body: 'This is a test notification',
            type: NotificationType.general,
            dateTime: DateTime.now(),
          ),
          NotificationEntity(
            id: '2',
            title: 'Invoice Notification',
            body: 'This is an invoice notification',
            type: NotificationType.invoice,
            dateTime: DateTime.now().subtract(Duration(days: 1)),
          ),
        ];
      } else {
        return [];
      }
    } catch (e) {
      debugPrint('Error fetching notifications: $e');
      rethrow;
    }
  }

  @override
  Future<void> readNotification(String id) async {}
}
