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

24 lines
695 B
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);
}
}