@anker-in/shopify-react 0.1.1-beta.23 → 0.1.1-beta.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1630,29 +1630,22 @@ var useUpdateLineCodeAmountAttributes = ({
1630
1630
  }).filter(
1631
1631
  ({ attrNeedUpdate, attrNeedDelete }) => attrNeedUpdate.length || attrNeedDelete.length
1632
1632
  ).map(({ line, attrNeedUpdate, attrNeedDelete }) => {
1633
+ let lineId = line.id;
1634
+ let attributes = line.customAttributes || [];
1635
+ if (attrNeedDelete.length) {
1636
+ attributes = attributes.filter(
1637
+ (attr) => !attrNeedDelete.includes(attr.key)
1638
+ );
1639
+ }
1633
1640
  if (attrNeedUpdate.length) {
1634
- return {
1635
- id: line.id,
1636
- attributes: [
1637
- ...line.customAttributes?.filter(
1638
- (attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
1639
- ) || [],
1640
- ...attrNeedUpdate
1641
- ]
1642
- };
1643
- } else if (attrNeedDelete.length) {
1644
- return {
1645
- id: line.id,
1646
- attributes: line.customAttributes?.filter(
1647
- (attr) => !attrNeedDelete.includes(attr.key)
1648
- ) || []
1649
- };
1650
- } else {
1651
- return {
1652
- id: line.id,
1653
- attributes: line.customAttributes || []
1654
- };
1641
+ attributes = attributes.filter(
1642
+ (attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
1643
+ ).concat(attrNeedUpdate);
1655
1644
  }
1645
+ return {
1646
+ id: lineId,
1647
+ attributes
1648
+ };
1656
1649
  }),
1657
1650
  [cart?.lineItems, mainProductDiscountCodes]
1658
1651
  );