@nextblock-cms/ecom 0.13.6 → 0.13.8
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-dev-runtime"),n=require("@nextblock-cms/ui/button"),o=require("lucide-react"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-dev-runtime"),n=require("@nextblock-cms/ui/button"),o=require("lucide-react"),c=require("sonner"),p=require("next/link"),v=require("../use-cart.cjs.js"),N=require("@nextblock-cms/utils"),d=require("../types.cjs.js"),g=require("../CurrencyProvider.cjs.js"),h=({product:e,className:r,quantity:m})=>{const a=v.useCart(t=>t),{t:i}=N.useTranslations(),{activeCurrencyCode:u}=g.useCurrency(),l=d.isDigitalProduct(e),_=!!e.has_variants&&!e.variant_id&&!l,b=!l&&typeof e.stock=="number"&&e.stock<=0;if(_)return s.jsxDEV(n.Button,{asChild:!0,className:r,children:s.jsxDEV(p,{href:`/product/${e.slug}`,children:"Select Options"},void 0,!1,{fileName:"C:/Users/desjardinsn/Desktop/nextblock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",lineNumber:37,columnNumber:9},void 0)},void 0,!1,{fileName:"C:/Users/desjardinsn/Desktop/nextblock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",lineNumber:36,columnNumber:7},void 0);if(b){const t=i("ecommerce.out_of_stock");return s.jsxDEV(n.Button,{disabled:!0,className:r,children:[s.jsxDEV(o.ShoppingCart,{className:"mr-2 h-4 w-4"},void 0,!1,{fileName:"C:/Users/desjardinsn/Desktop/nextblock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",lineNumber:47,columnNumber:9},void 0),t==="ecommerce.out_of_stock"?"Out of stock":t]},void 0,!0,{fileName:"C:/Users/desjardinsn/Desktop/nextblock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",lineNumber:46,columnNumber:7},void 0)}if(!a)return s.jsxDEV(n.Button,{disabled:!0,className:r,children:[s.jsxDEV(o.ShoppingCart,{className:"mr-2 h-4 w-4"},void 0,!1,{fileName:"C:/Users/desjardinsn/Desktop/nextblock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",lineNumber:58,columnNumber:9},void 0),i("ecommerce.add_to_cart")]},void 0,!0,{fileName:"C:/Users/desjardinsn/Desktop/nextblock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",lineNumber:57,columnNumber:7},void 0);const{addItem:f}=a,C=()=>{const t=d.getProductPaymentProvider(e)??"stripe",{success:k,error:x}=f({id:e.variant_id||e.id,product_id:e.id,title:e.title,price:e.price,prices:e.prices,sale_price:e.sale_price,sale_prices:e.sale_prices,is_taxable:e.is_taxable,image_url:e.image_url,slug:e.slug,sku:e.sku,stock:e.stock,language_id:e.language_id,translation_group_id:e.translation_group_id,product_type:e.product_type,payment_provider:e.payment_provider??t,provider:t,freemius_product_id:e.freemius_product_id,freemius_plan_id:e.freemius_plan_id,trial_period_days:e.trial_period_days??0,trial_requires_payment_method:e.trial_requires_payment_method??!1,has_variants:e.has_variants,variant_id:e.variant_id,variant_label:e.variant_label,selected_options:e.selected_options,currency_code:u,quantity:m});k?c.toast.success(i("ecommerce.added_to_cart_success",{item:e.title})):c.toast.error(x||i("ecommerce.added_to_cart_error"))};return s.jsxDEV(n.Button,{onClick:C,className:r,children:[s.jsxDEV(o.ShoppingCart,{className:"mr-2 h-4 w-4"},void 0,!1,{fileName:"C:/Users/desjardinsn/Desktop/nextblock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",lineNumber:108,columnNumber:7},void 0),i("ecommerce.add_to_cart")]},void 0,!0,{fileName:"C:/Users/desjardinsn/Desktop/nextblock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",lineNumber:107,columnNumber:5},void 0)};exports.AddToCartButton=h;
|
|
@@ -1,41 +1,56 @@
|
|
|
1
1
|
'use client';
|
|
2
|
-
import { jsxDEV as
|
|
2
|
+
import { jsxDEV as s } from "react/jsx-dev-runtime";
|
|
3
3
|
import { Button as n } from "@nextblock-cms/ui/button";
|
|
4
|
-
import { ShoppingCart as
|
|
4
|
+
import { ShoppingCart as o } from "lucide-react";
|
|
5
5
|
import { toast as l } from "sonner";
|
|
6
|
-
import
|
|
7
|
-
import { useCart as
|
|
8
|
-
import { useTranslations as
|
|
9
|
-
import { isDigitalProduct as
|
|
10
|
-
import { useCurrency as
|
|
11
|
-
const
|
|
12
|
-
const
|
|
13
|
-
if (
|
|
14
|
-
return /* @__PURE__ */
|
|
6
|
+
import k from "next/link";
|
|
7
|
+
import { useCart as C } from "../use-cart.es.js";
|
|
8
|
+
import { useTranslations as N } from "@nextblock-cms/utils";
|
|
9
|
+
import { isDigitalProduct as v, getProductPaymentProvider as x } from "../types.es.js";
|
|
10
|
+
import { useCurrency as h } from "../CurrencyProvider.es.js";
|
|
11
|
+
const P = ({ product: e, className: t, quantity: d }) => {
|
|
12
|
+
const a = C((r) => r), { t: i } = N(), { activeCurrencyCode: c } = h(), m = v(e), _ = !!e.has_variants && !e.variant_id && !m, u = !m && typeof e.stock == "number" && e.stock <= 0;
|
|
13
|
+
if (_)
|
|
14
|
+
return /* @__PURE__ */ s(n, { asChild: !0, className: t, children: /* @__PURE__ */ s(k, { href: `/product/${e.slug}`, children: "Select Options" }, void 0, !1, {
|
|
15
15
|
fileName: "C:/Users/desjardinsn/Desktop/nextblock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",
|
|
16
|
-
lineNumber:
|
|
16
|
+
lineNumber: 37,
|
|
17
17
|
columnNumber: 9
|
|
18
18
|
}, void 0) }, void 0, !1, {
|
|
19
19
|
fileName: "C:/Users/desjardinsn/Desktop/nextblock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",
|
|
20
|
-
lineNumber:
|
|
20
|
+
lineNumber: 36,
|
|
21
21
|
columnNumber: 7
|
|
22
22
|
}, void 0);
|
|
23
|
-
if (
|
|
24
|
-
|
|
25
|
-
|
|
23
|
+
if (u) {
|
|
24
|
+
const r = i("ecommerce.out_of_stock");
|
|
25
|
+
return /* @__PURE__ */ s(n, { disabled: !0, className: t, children: [
|
|
26
|
+
/* @__PURE__ */ s(o, { className: "mr-2 h-4 w-4" }, void 0, !1, {
|
|
26
27
|
fileName: "C:/Users/desjardinsn/Desktop/nextblock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",
|
|
27
|
-
lineNumber:
|
|
28
|
+
lineNumber: 47,
|
|
29
|
+
columnNumber: 9
|
|
30
|
+
}, void 0),
|
|
31
|
+
r === "ecommerce.out_of_stock" ? "Out of stock" : r
|
|
32
|
+
] }, void 0, !0, {
|
|
33
|
+
fileName: "C:/Users/desjardinsn/Desktop/nextblock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",
|
|
34
|
+
lineNumber: 46,
|
|
35
|
+
columnNumber: 7
|
|
36
|
+
}, void 0);
|
|
37
|
+
}
|
|
38
|
+
if (!a)
|
|
39
|
+
return /* @__PURE__ */ s(n, { disabled: !0, className: t, children: [
|
|
40
|
+
/* @__PURE__ */ s(o, { className: "mr-2 h-4 w-4" }, void 0, !1, {
|
|
41
|
+
fileName: "C:/Users/desjardinsn/Desktop/nextblock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",
|
|
42
|
+
lineNumber: 58,
|
|
28
43
|
columnNumber: 9
|
|
29
44
|
}, void 0),
|
|
30
45
|
i("ecommerce.add_to_cart")
|
|
31
46
|
] }, void 0, !0, {
|
|
32
47
|
fileName: "C:/Users/desjardinsn/Desktop/nextblock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",
|
|
33
|
-
lineNumber:
|
|
48
|
+
lineNumber: 57,
|
|
34
49
|
columnNumber: 7
|
|
35
50
|
}, void 0);
|
|
36
|
-
const { addItem:
|
|
37
|
-
return /* @__PURE__ */
|
|
38
|
-
const
|
|
51
|
+
const { addItem: b } = a;
|
|
52
|
+
return /* @__PURE__ */ s(n, { onClick: () => {
|
|
53
|
+
const r = x(e) ?? "stripe", { success: f, error: p } = b({
|
|
39
54
|
id: e.variant_id || e.id,
|
|
40
55
|
product_id: e.id,
|
|
41
56
|
title: e.title,
|
|
@@ -51,8 +66,8 @@ const q = ({ product: e, className: t, quantity: m }) => {
|
|
|
51
66
|
language_id: e.language_id,
|
|
52
67
|
translation_group_id: e.translation_group_id,
|
|
53
68
|
product_type: e.product_type,
|
|
54
|
-
payment_provider: e.payment_provider ??
|
|
55
|
-
provider:
|
|
69
|
+
payment_provider: e.payment_provider ?? r,
|
|
70
|
+
provider: r,
|
|
56
71
|
freemius_product_id: e.freemius_product_id,
|
|
57
72
|
// include just in case it wasn't intercepted
|
|
58
73
|
freemius_plan_id: e.freemius_plan_id,
|
|
@@ -62,23 +77,23 @@ const q = ({ product: e, className: t, quantity: m }) => {
|
|
|
62
77
|
variant_id: e.variant_id,
|
|
63
78
|
variant_label: e.variant_label,
|
|
64
79
|
selected_options: e.selected_options,
|
|
65
|
-
currency_code:
|
|
66
|
-
quantity:
|
|
80
|
+
currency_code: c,
|
|
81
|
+
quantity: d
|
|
67
82
|
});
|
|
68
|
-
|
|
83
|
+
f ? l.success(i("ecommerce.added_to_cart_success", { item: e.title })) : l.error(p || i("ecommerce.added_to_cart_error"));
|
|
69
84
|
}, className: t, children: [
|
|
70
|
-
/* @__PURE__ */
|
|
85
|
+
/* @__PURE__ */ s(o, { className: "mr-2 h-4 w-4" }, void 0, !1, {
|
|
71
86
|
fileName: "C:/Users/desjardinsn/Desktop/nextblock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",
|
|
72
|
-
lineNumber:
|
|
87
|
+
lineNumber: 108,
|
|
73
88
|
columnNumber: 7
|
|
74
89
|
}, void 0),
|
|
75
90
|
i("ecommerce.add_to_cart")
|
|
76
91
|
] }, void 0, !0, {
|
|
77
92
|
fileName: "C:/Users/desjardinsn/Desktop/nextblock/libs/ecommerce/src/lib/components/AddToCartButton.tsx",
|
|
78
|
-
lineNumber:
|
|
93
|
+
lineNumber: 107,
|
|
79
94
|
columnNumber: 5
|
|
80
95
|
}, void 0);
|
|
81
96
|
};
|
|
82
97
|
export {
|
|
83
|
-
|
|
98
|
+
P as AddToCartButton
|
|
84
99
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nextblock-cms/ecom",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.8",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -10,9 +10,9 @@
|
|
|
10
10
|
},
|
|
11
11
|
"type": "module",
|
|
12
12
|
"dependencies": {
|
|
13
|
-
"@nextblock-cms/db": "^0.13.
|
|
14
|
-
"@nextblock-cms/ui": "^0.13.
|
|
15
|
-
"@nextblock-cms/utils": "^0.13.
|
|
13
|
+
"@nextblock-cms/db": "^0.13.8",
|
|
14
|
+
"@nextblock-cms/ui": "^0.13.8",
|
|
15
|
+
"@nextblock-cms/utils": "^0.13.8",
|
|
16
16
|
"@freemius/checkout": "^1.4.1",
|
|
17
17
|
"@freemius/sdk": "^0.3.0",
|
|
18
18
|
"@hookform/resolvers": "^5.2.2",
|