part of 'order_form_bloc.dart';

@freezed
class OrderFormState with _$OrderFormState {
  factory OrderFormState({
    PaymentMethod? paymentMethod,
    String? customerName,
    Customer? customer,
    required Option<Either<OrderFailure, Order>> failureOrCreateOrder,
    required Option<Either<OrderFailure, Order>>
    failureOrCreateOrderWithPayment,
    required Option<Either<OrderFailure, Order>> failureOrAddItemOrder,
    @Default(false) bool isCreating,
    @Default(false) bool isCreatingWithPayment,
    @Default(false) bool isAddingItemOrder,
    /// Idempotency key untuk add item order.
    /// Di-generate saat user tap "Add Items", dipakai ulang saat retry,
    /// di-clear setelah sukses.
    String? addItemIdempotencyKey,
  }) = _OrderFormState;

  factory OrderFormState.initial() => OrderFormState(
    failureOrCreateOrder: none(),
    failureOrCreateOrderWithPayment: none(),
    failureOrAddItemOrder: none(),
  );
}
