/// Use case: Approuver une transaction
library approve_transaction;

import 'package:dartz/dartz.dart';
import 'package:injectable/injectable.dart';
import '../../../../core/error/failures.dart';
import '../entities/transaction_approval.dart';
import '../repositories/finance_workflow_repository.dart';

@lazySingleton
class ApproveTransaction {
  final FinanceWorkflowRepository repository;

  ApproveTransaction(this.repository);

  Future<Either<Failure, TransactionApproval>> call({
    required String approvalId,
    String? comment,
  }) async {
    if (approvalId.isEmpty) {
      return Left(ValidationFailure('ID approbation requis'));
    }

    return await repository.approveTransaction(
      approvalId: approvalId,
      comment: comment,
    );
  }
}
