@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.
package/dist/index.js CHANGED
@@ -1735,29 +1735,22 @@ var useUpdateLineCodeAmountAttributes = ({
1735
1735
  }).filter(
1736
1736
  ({ attrNeedUpdate, attrNeedDelete }) => attrNeedUpdate.length || attrNeedDelete.length
1737
1737
  ).map(({ line, attrNeedUpdate, attrNeedDelete }) => {
1738
+ let lineId = line.id;
1739
+ let attributes = line.customAttributes || [];
1740
+ if (attrNeedDelete.length) {
1741
+ attributes = attributes.filter(
1742
+ (attr) => !attrNeedDelete.includes(attr.key)
1743
+ );
1744
+ }
1738
1745
  if (attrNeedUpdate.length) {
1739
- return {
1740
- id: line.id,
1741
- attributes: [
1742
- ...line.customAttributes?.filter(
1743
- (attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
1744
- ) || [],
1745
- ...attrNeedUpdate
1746
- ]
1747
- };
1748
- } else if (attrNeedDelete.length) {
1749
- return {
1750
- id: line.id,
1751
- attributes: line.customAttributes?.filter(
1752
- (attr) => !attrNeedDelete.includes(attr.key)
1753
- ) || []
1754
- };
1755
- } else {
1756
- return {
1757
- id: line.id,
1758
- attributes: line.customAttributes || []
1759
- };
1746
+ attributes = attributes.filter(
1747
+ (attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
1748
+ ).concat(attrNeedUpdate);
1760
1749
  }
1750
+ return {
1751
+ id: lineId,
1752
+ attributes
1753
+ };
1761
1754
  }),
1762
1755
  [cart?.lineItems, mainProductDiscountCodes]
1763
1756
  );