@springmicro/cart 0.5.16 → 0.6.0
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 +28 -22
- package/dist/index.umd.cjs +1 -1
- package/package.json +3 -3
- package/src/ProductCard.tsx +8 -0
package/dist/index.js
CHANGED
|
@@ -29455,50 +29455,53 @@ function sC({
|
|
|
29455
29455
|
function KI({
|
|
29456
29456
|
product: e,
|
|
29457
29457
|
component: t,
|
|
29458
|
-
priceTierName: n
|
|
29458
|
+
priceTierName: n,
|
|
29459
|
+
disabled: r
|
|
29459
29460
|
}) {
|
|
29460
|
-
const
|
|
29461
|
-
(
|
|
29462
|
-
),
|
|
29463
|
-
function
|
|
29464
|
-
if (
|
|
29461
|
+
const a = JSON.parse(zl(mt)), i = a.items.findIndex(
|
|
29462
|
+
(f) => f.product_id === e.id
|
|
29463
|
+
), s = !!~i, l = JSON.parse(e.pricing), c = l.findIndex((f) => f.tier_label === n), u = c != -1 ? a.items.findIndex((f) => f.price_id === l[c].id) : -1;
|
|
29464
|
+
function d(f = c) {
|
|
29465
|
+
if (f === -1)
|
|
29465
29466
|
throw "Price index not found. Provide price index to addToCart OR provide priceTierName to ProductCard.";
|
|
29466
29467
|
kf({
|
|
29467
29468
|
product_id: e.id,
|
|
29468
29469
|
name: e.name,
|
|
29469
|
-
price_id:
|
|
29470
|
+
price_id: l[f].id,
|
|
29470
29471
|
image: void 0,
|
|
29471
29472
|
quantity: void 0
|
|
29472
29473
|
});
|
|
29473
29474
|
}
|
|
29474
|
-
const
|
|
29475
|
+
const p = {
|
|
29475
29476
|
product: e,
|
|
29477
|
+
disabled: r,
|
|
29476
29478
|
foundInCart: {
|
|
29477
|
-
product:
|
|
29478
|
-
price:
|
|
29479
|
+
product: s,
|
|
29480
|
+
price: c != -1 ? !!~u : null
|
|
29479
29481
|
},
|
|
29480
|
-
pricing:
|
|
29481
|
-
addToCart:
|
|
29482
|
-
removeFromCart: (
|
|
29483
|
-
Ul(
|
|
29482
|
+
pricing: l,
|
|
29483
|
+
addToCart: d,
|
|
29484
|
+
removeFromCart: (f) => {
|
|
29485
|
+
Ul(f ? u : i);
|
|
29484
29486
|
}
|
|
29485
29487
|
};
|
|
29486
|
-
return t !== void 0 ? t(
|
|
29488
|
+
return t !== void 0 ? t(p) : /* @__PURE__ */ m.jsx(lC, { ...p });
|
|
29487
29489
|
}
|
|
29488
29490
|
function lC({
|
|
29489
29491
|
product: e,
|
|
29490
29492
|
foundInCart: t,
|
|
29491
29493
|
pricing: n,
|
|
29492
29494
|
addToCart: r,
|
|
29493
|
-
removeFromCart: a
|
|
29495
|
+
removeFromCart: a,
|
|
29496
|
+
disabled: i
|
|
29494
29497
|
}) {
|
|
29495
29498
|
return /* @__PURE__ */ m.jsxs(
|
|
29496
29499
|
"div",
|
|
29497
29500
|
{
|
|
29498
29501
|
className: "card",
|
|
29499
|
-
onClick: (
|
|
29502
|
+
onClick: (s) => (
|
|
29500
29503
|
// @ts-expect-error it works
|
|
29501
|
-
!
|
|
29504
|
+
!s.target.closest("button") && (window.location.href = `/product/${e.id}`)
|
|
29502
29505
|
),
|
|
29503
29506
|
children: [
|
|
29504
29507
|
/* @__PURE__ */ m.jsxs("div", { className: "card-section", children: [
|
|
@@ -29513,6 +29516,7 @@ function lC({
|
|
|
29513
29516
|
onClick: () => {
|
|
29514
29517
|
a();
|
|
29515
29518
|
},
|
|
29519
|
+
disabled: i,
|
|
29516
29520
|
children: "Remove from cart"
|
|
29517
29521
|
}
|
|
29518
29522
|
) : n.length === 1 ? /* @__PURE__ */ m.jsxs(
|
|
@@ -29522,6 +29526,7 @@ function lC({
|
|
|
29522
29526
|
onClick: () => {
|
|
29523
29527
|
r();
|
|
29524
29528
|
},
|
|
29529
|
+
disabled: i,
|
|
29525
29530
|
children: [
|
|
29526
29531
|
"Add ",
|
|
29527
29532
|
qu(n[0])
|
|
@@ -29529,19 +29534,20 @@ function lC({
|
|
|
29529
29534
|
}
|
|
29530
29535
|
) : n.length === 0 ? /* @__PURE__ */ m.jsx("button", { className: "addtocartbutton disabled", children: "Currently unavailable" }) : /* @__PURE__ */ m.jsxs("button", { className: "addtocartbutton hover-button", children: [
|
|
29531
29536
|
"Add to cart ▼",
|
|
29532
|
-
/* @__PURE__ */ m.jsx("div", { className: "hover-section", children: /* @__PURE__ */ m.jsx("div", { className: "hover-data", children: /* @__PURE__ */ m.jsx("div", { children: n.map((
|
|
29537
|
+
/* @__PURE__ */ m.jsx("div", { className: "hover-section", children: /* @__PURE__ */ m.jsx("div", { className: "hover-data", children: /* @__PURE__ */ m.jsx("div", { children: n.map((s, l) => /* @__PURE__ */ m.jsxs(
|
|
29533
29538
|
"button",
|
|
29534
29539
|
{
|
|
29535
29540
|
className: "tieredpricingbutton",
|
|
29536
29541
|
onClick: () => {
|
|
29537
|
-
r(
|
|
29542
|
+
r(l);
|
|
29538
29543
|
},
|
|
29544
|
+
disabled: i,
|
|
29539
29545
|
children: [
|
|
29540
29546
|
"Tier ",
|
|
29541
|
-
|
|
29547
|
+
l + 1,
|
|
29542
29548
|
":",
|
|
29543
29549
|
/* @__PURE__ */ m.jsx("br", {}),
|
|
29544
|
-
qu(
|
|
29550
|
+
qu(s)
|
|
29545
29551
|
]
|
|
29546
29552
|
}
|
|
29547
29553
|
)) }) }) })
|