You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug linesRemove and linesAdd do not support promises
consthandleCustomOnClick=async(event)=>{if(performed.current){performed.current=false;return;}event.preventDefault();// Stop default behavior// Check if there is an old line with handle === "kit"constexistingTableLine=lines.find((item)=>item.merchandise.product.productType==='Style de kit',);// Remove the existing line with handle === "kit"if(existingTableLine){awaitlinesRemove([existingTableLine.id]);}// Add the new productconstlineToAdd=selectedVariant?.id;constnewProduct={merchandiseId: lineToAdd,quantity: 1,};// Display loading messagemessageApi.open({
key,type: 'loading',content: 'Chargement...',});// Delay for a smoother transitionawaitnewPromise((resolve)=>setTimeout(resolve,700));// Add the new lineawaitlinesAdd([newProduct]);// Display success messageif(!existingTableLine){messageApi.open({
key,type: 'success',content: 'Ajouter au panier!',duration: 3,});}performed.current=true;// Prevent retriggeringbuttonRef.current.click();// Trigger button default behaviorconsole.log('lines',lines);};// btn add to lines handleCustomOnClick<AddToCartButtonvariantId={selectedVariant?.id}quantity={qantity}accessibleAddingToCartLabel="Ajout d'un article à votre panier"disabled={isOutOfStock}type="button"onClick={handleCustomOnClick}><divwidth="full"variant={isOutOfStock ? 'secondary' : 'primary'}>{isOutOfStock ? null : children}</div></AddToCartButton>
Hydrogen version 3.25.0
Node version v18.12.1
The text was updated successfully, but these errors were encountered:
Describe the bug
linesRemove and linesAdd do not support promises
The text was updated successfully, but these errors were encountered: