@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.mjs CHANGED
@@ -1727,29 +1727,22 @@ var useUpdateLineCodeAmountAttributes = ({
1727
1727
  }).filter(
1728
1728
  ({ attrNeedUpdate, attrNeedDelete }) => attrNeedUpdate.length || attrNeedDelete.length
1729
1729
  ).map(({ line, attrNeedUpdate, attrNeedDelete }) => {
1730
+ let lineId = line.id;
1731
+ let attributes = line.customAttributes || [];
1732
+ if (attrNeedDelete.length) {
1733
+ attributes = attributes.filter(
1734
+ (attr) => !attrNeedDelete.includes(attr.key)
1735
+ );
1736
+ }
1730
1737
  if (attrNeedUpdate.length) {
1731
- return {
1732
- id: line.id,
1733
- attributes: [
1734
- ...line.customAttributes?.filter(
1735
- (attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
1736
- ) || [],
1737
- ...attrNeedUpdate
1738
- ]
1739
- };
1740
- } else if (attrNeedDelete.length) {
1741
- return {
1742
- id: line.id,
1743
- attributes: line.customAttributes?.filter(
1744
- (attr) => !attrNeedDelete.includes(attr.key)
1745
- ) || []
1746
- };
1747
- } else {
1748
- return {
1749
- id: line.id,
1750
- attributes: line.customAttributes || []
1751
- };
1738
+ attributes = attributes.filter(
1739
+ (attr) => !attrNeedUpdate.some((updateAttr) => updateAttr.key === attr.key)
1740
+ ).concat(attrNeedUpdate);
1752
1741
  }
1742
+ return {
1743
+ id: lineId,
1744
+ attributes
1745
+ };
1753
1746
  }),
1754
1747
  [cart?.lineItems, mainProductDiscountCodes]
1755
1748
  );