import 'package:dio/dio.dart';
import '../../../../core/error/exceptions.dart';
import '../../domain/repositories/dashboard_repository.dart';
import '../datasources/dashboard_remote_datasource.dart';
import '../models/user_stats_model.dart';

class DashboardRepositoryImpl implements DashboardRepository {
  final DashboardRemoteDatasource remote;

  DashboardRepositoryImpl({required this.remote});

  @override
  Future<UserStatsModel> getStats() async {
    try {
      return await remote.getStats();
    } on DioException catch (e) {
      final error = e.error;
      if (error is Exception) throw error;
      throw ServerException(e.message ?? 'Failed to load stats');
    }
  }
}