/// Status pengiriman satu entri transaksi (grup atau tip).
enum SubmissionStatus { pending, sending, success, failed }

/// Hasil pengiriman satu grup transaksi ke Firefly III.
///
/// Dipakai oleh popup daftar transaksi untuk menampilkan status real-time.
class GroupSubmissionResult {
  final String groupId;
  final String label; // Nama akun sumber atau "Tip"
  final double amount;
  final bool isTip;
  SubmissionStatus status;
  String? transactionId;
  String? error;

  GroupSubmissionResult({
    required this.groupId,
    required this.label,
    required this.amount,
    this.isTip = false,
    this.status = SubmissionStatus.pending,
    this.transactionId,
    this.error,
  });

  bool get isSuccess => status == SubmissionStatus.success;
  bool get isFailed => status == SubmissionStatus.failed;
  bool get isSending => status == SubmissionStatus.sending;
  bool get isPending => status == SubmissionStatus.pending;

  GroupSubmissionResult copyWith({
    SubmissionStatus? status,
    String? transactionId,
    String? error,
  }) {
    return GroupSubmissionResult(
      groupId: groupId,
      label: label,
      amount: amount,
      isTip: isTip,
      status: status ?? this.status,
      transactionId: transactionId ?? this.transactionId,
      error: error ?? this.error,
    );
  }
}
