part of 'payment_form_bloc.dart';

@freezed
class PaymentFormState with _$PaymentFormState {
  factory PaymentFormState({
    required Order order,
    required List<OrderItem> pendingItems,
    required Option<Either<OrderFailure, Payment>> failureOrPayment,
    required Option<Either<OrderFailure, Payment>> failureOrPaymentSplitBill,
    PaymentMethod? paymentMethod,
    @Default(false) bool isSubmitting,
    /// Idempotency key untuk payment submission.
    /// Di-generate saat user tap "Bayar", dipakai ulang saat retry,
    /// di-clear setelah sukses.
    String? idempotencyKey,
    /// Idempotency key untuk split bill submission.
    String? splitBillIdempotencyKey,
  }) = _PaymentFormState;

  factory PaymentFormState.initial() => PaymentFormState(
    order: Order.empty(),
    pendingItems: [],
    failureOrPayment: none(),
    failureOrPaymentSplitBill: none(),
  );
}
