// lib/presentation/reservation/cubit/reservation_cubit.dart

// ignore: depend_on_referenced_packages
import 'package:bloc/bloc.dart';

part 'reservation_state.dart';

class ReservationCubit extends Cubit<ReservationState> {
  ReservationCubit() : super(const ReservationState());

  void reserveProduct(String productId) {
    if (state.reservedProductIds.contains(productId)) return;

    final updatedList = List<String>.from(state.reservedProductIds)..add(productId);
    emit(state.copyWith(reservedProductIds: updatedList));
  }

  // متد جدید برای تنظیم کردن همه شناسه‌های رزرو شده
  void setReservedIds(List<String> productIds) {
    emit(state.copyWith(reservedProductIds: productIds));
  }

  bool isProductReserved(String productId) {
    return state.reservedProductIds.contains(productId);
  }
}