part of 'void_form_bloc.dart';

@freezed
class VoidFormState with _$VoidFormState {
  factory VoidFormState({
    required Order order,
    required List<OrderItem> pendingItems,
    required List<OrderItem> voidItems,
    required VoidType voidType,
    required Map<String, int> selectedItemQuantities,
    String? voidReason,
    required int totalPriceVoid,
    required Option<Either<OrderFailure, Unit>> failureOrVoid,
    @Default(false) bool isSubmitting,
    /// Idempotency key untuk void submission.
    /// Di-generate saat user tap "Void", dipakai ulang saat retry,
    /// di-clear setelah sukses atau clearState.
    String? idempotencyKey,
  }) = _VoidFormState;

  factory VoidFormState.initial() => VoidFormState(
    order: Order.empty(),
    voidType: VoidType.all,
    selectedItemQuantities: {},
    pendingItems: [],
    totalPriceVoid: 0,
    failureOrVoid: none(),
    voidItems: [],
  );
}
