import '../../domain/entities/approval.dart';
import '../../domain/repositories/approvals_repository.dart';
import '../datasources/approvals_datasource.dart';

class ApprovalsRepositoryImpl implements ApprovalsRepository {
  final ApprovalsDatasource _datasource;

  ApprovalsRepositoryImpl(this._datasource);

  @override
  Future<List<Approval>> getAll({String? status}) async {
    final models = await _datasource.fetchAll(status: status);
    return models.map((m) => m.toEntity()).toList();
  }

  @override
  Future<Approval> approve(String id) async {
    final model = await _datasource.approve(id);
    return model.toEntity();
  }

  @override
  Future<Approval> reject(String id) async {
    final model = await _datasource.reject(id);
    return model.toEntity();
  }
}
