Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return true;
}
const filteredValues = Object.keys(characteristics).filter(key => !!characteristics[key]);
const selected = !!((filteredValues.length === variants.characteristics.length) && variantId);
if (!selected) {
const firstUnselected = this.findUnselectedCharacteristic();
if (firstUnselected) {
const ref = this.refsStore[firstUnselected.id];
// Focus the item for screen readers and broadcast a related live message.
ref.current.focus();
const option = ref.current.innerText;
broadcastLiveMessage('product.pick_option_first', {
params: { option },
});
ref.current.scrollIntoView({ behavior: 'smooth' });
this.setState({ highlight: firstUnselected.id });
}
}
return selected;
}
checkInput = () => {
if (!this.props.required) {
return true;
}
if (this.props.value) {
return true;
}
broadcastLiveMessage('product.fill_out_required_input_first');
this.ref.scrollIntoView({ behavior: 'smooth' });
this.setState({ highlight: true });
return false;
}
this.props.conditioner.check().then((fullfilled) => {
if (!fullfilled) {
return;
}
this.setState({ clicked: true });
this.props.addToCart({
productId: this.props.productId,
options: this.props.options,
quantity: this.context.quantity,
});
broadcastLiveMessage('product.adding_item', {
params: { count: this.context.quantity },
});
if (this.moreButtonRef.current) {
this.moreButtonRef.current.focus();
}
setTimeout(this.resetClicked, 250);
});
}
subscribe(favoritesWillAddItem$, () => {
broadcastLiveMessage('favorites.added');
});
}
handleAddToCart = () => {
if (this.props.isBaseProduct && this.props.hasVariety) {
this.props.showVariantModal(this.props.productId);
return;
}
const productData = {
productId: this.props.productId,
quantity: 1,
};
this.props.addToCart(productData);
broadcastLiveMessage('product.adding_item', {
params: { count: 1 },
});
};
this.props.conditioner.check().then((fulfilled) => {
if (!fulfilled) {
return;
}
this.setState({ clicked: true });
this.props.addToCart({
productId: this.props.productId,
options: this.props.options,
quantity: this.context.quantity,
});
broadcastLiveMessage('product.adding_item', {
params: { count: this.context.quantity },
});
});
}