import 'package:dartz/dartz.dart';
import 'package:injectable/injectable.dart';
import 'package:superport/core/errors/failures.dart';
import 'package:superport/data/datasources/remote/dashboard_remote_datasource.dart';
import 'package:superport/data/models/dashboard/equipment_status_distribution.dart';
import 'package:superport/data/models/dashboard/expiring_license.dart';
import 'package:superport/data/models/dashboard/license_expiry_summary.dart';
import 'package:superport/data/models/dashboard/overview_stats.dart';
import 'package:superport/data/models/dashboard/recent_activity.dart';

abstract class DashboardService {
  Future<Either<Failure, OverviewStats>> getOverviewStats();
  Future<Either<Failure, List<RecentActivity>>> getRecentActivities();
  Future<Either<Failure, EquipmentStatusDistribution>> getEquipmentStatusDistribution();
  Future<Either<Failure, List<ExpiringLicense>>> getExpiringLicenses({int days = 30});
  Future<Either<Failure, LicenseExpirySummary>> getLicenseExpirySummary();
}

@LazySingleton(as: DashboardService)
class DashboardServiceImpl implements DashboardService {
  final DashboardRemoteDataSource _remoteDataSource;

  DashboardServiceImpl(this._remoteDataSource);

  @override
  Future<Either<Failure, OverviewStats>> getOverviewStats() async {
    return await _remoteDataSource.getOverviewStats();
  }

  @override
  Future<Either<Failure, List<RecentActivity>>> getRecentActivities() async {
    return await _remoteDataSource.getRecentActivities();
  }

  @override
  Future<Either<Failure, EquipmentStatusDistribution>> getEquipmentStatusDistribution() async {
    return await _remoteDataSource.getEquipmentStatusDistribution();
  }

  @override
  Future<Either<Failure, List<ExpiringLicense>>> getExpiringLicenses({int days = 30}) async {
    return await _remoteDataSource.getExpiringLicenses(days: days);
  }

  @override
  Future<Either<Failure, LicenseExpirySummary>> getLicenseExpirySummary() async {
    return await _remoteDataSource.getLicenseExpirySummary();
  }
}