@libreapps/commerce 7.5.1
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/.turbo/turbo-build.log +4 -0
- package/CHANGELOG.md +13 -0
- package/LICENSE.md +21 -0
- package/components/Icons.tsx +35 -0
- package/components/add-to-cart-widget.tsx +183 -0
- package/components/buy/buy-card.tsx +259 -0
- package/components/buy/carousel-buy-card.tsx +242 -0
- package/components/buy/multi-family/all-variants-carousel.tsx +261 -0
- package/components/buy/multi-family/family-carousel/index.tsx +77 -0
- package/components/buy/multi-family/family-carousel/slide.tsx +83 -0
- package/components/buy/multi-family/family-carousel/state.ts +87 -0
- package/components/buy/multi-family/index.ts +2 -0
- package/components/buy/single-family-selector.tsx +90 -0
- package/components/buy/title-and-byline.tsx +25 -0
- package/components/cart/cart-panel/cart-line-item.tsx +76 -0
- package/components/cart/cart-panel/index.tsx +154 -0
- package/components/cart/cart-panel/promo-code.tsx +109 -0
- package/components/cart/cart-panel/total-area.tsx +60 -0
- package/components/checkout/payment-step-form/card-icon-row.tsx +26 -0
- package/components/checkout/payment-step-form/card-icons/amex.tsx +32 -0
- package/components/checkout/payment-step-form/card-icons/diners-club.tsx +13 -0
- package/components/checkout/payment-step-form/card-icons/discover.tsx +25 -0
- package/components/checkout/payment-step-form/card-icons/jcb.tsx +26 -0
- package/components/checkout/payment-step-form/card-icons/mastercard.tsx +27 -0
- package/components/checkout/payment-step-form/card-icons/visa.tsx +25 -0
- package/components/checkout/payment-step-form/cc-button.tsx +17 -0
- package/components/checkout/payment-step-form/contact-form.tsx +50 -0
- package/components/checkout/payment-step-form/crypto-icons/btc.tsx +11 -0
- package/components/checkout/payment-step-form/crypto-icons/eth.tsx +20 -0
- package/components/checkout/payment-step-form/crypto-icons/usdt.tsx +13 -0
- package/components/checkout/payment-step-form/index.tsx +122 -0
- package/components/checkout/payment-step-form/methods/bank-transfer.tsx +79 -0
- package/components/checkout/payment-step-form/methods/card.tsx +232 -0
- package/components/checkout/payment-step-form/methods/crypto.tsx +227 -0
- package/components/checkout/payment-step-form/methods/index.ts +23 -0
- package/components/checkout/shipping-step-form.tsx +175 -0
- package/components/index.ts +11 -0
- package/components/item/product-card.tsx +48 -0
- package/components/item-selector/button.tsx +188 -0
- package/components/item-selector/carousel/index.tsx +197 -0
- package/components/item-selector/carousel/slider.tsx +40 -0
- package/components/item-selector/index.ts +5 -0
- package/components/item-selector/quantity-indicator.tsx +48 -0
- package/components/node-tabs/index.tsx +91 -0
- package/components/node-tabs/node-image.tsx +31 -0
- package/dist/components/Icons.d.ts +18 -0
- package/dist/components/Icons.js +19 -0
- package/dist/components/Icons.js.map +1 -0
- package/dist/components/add-to-cart-widget.d.ts +11 -0
- package/dist/components/add-to-cart-widget.js +85 -0
- package/dist/components/add-to-cart-widget.js.map +1 -0
- package/dist/components/buy/buy-card.d.ts +30 -0
- package/dist/components/buy/buy-card.js +109 -0
- package/dist/components/buy/buy-card.js.map +1 -0
- package/dist/components/buy/carousel-buy-card.d.ts +12 -0
- package/dist/components/buy/carousel-buy-card.js +94 -0
- package/dist/components/buy/carousel-buy-card.js.map +1 -0
- package/dist/components/buy/multi-family/all-variants-carousel.d.ts +4 -0
- package/dist/components/buy/multi-family/all-variants-carousel.js +115 -0
- package/dist/components/buy/multi-family/all-variants-carousel.js.map +1 -0
- package/dist/components/buy/multi-family/family-carousel/index.d.ts +4 -0
- package/dist/components/buy/multi-family/family-carousel/index.js +27 -0
- package/dist/components/buy/multi-family/family-carousel/index.js.map +1 -0
- package/dist/components/buy/multi-family/family-carousel/slide.d.ts +11 -0
- package/dist/components/buy/multi-family/family-carousel/slide.js +35 -0
- package/dist/components/buy/multi-family/family-carousel/slide.js.map +1 -0
- package/dist/components/buy/multi-family/family-carousel/state.d.ts +20 -0
- package/dist/components/buy/multi-family/family-carousel/state.js +59 -0
- package/dist/components/buy/multi-family/family-carousel/state.js.map +1 -0
- package/dist/components/buy/multi-family/index.d.ts +2 -0
- package/dist/components/buy/multi-family/index.js +3 -0
- package/dist/components/buy/multi-family/index.js.map +1 -0
- package/dist/components/buy/single-family-selector.d.ts +15 -0
- package/dist/components/buy/single-family-selector.js +28 -0
- package/dist/components/buy/single-family-selector.js.map +1 -0
- package/dist/components/buy/title-and-byline.d.ts +8 -0
- package/dist/components/buy/title-and-byline.js +7 -0
- package/dist/components/buy/title-and-byline.js.map +1 -0
- package/dist/components/cart/cart-panel/cart-line-item.d.ts +11 -0
- package/dist/components/cart/cart-panel/cart-line-item.js +25 -0
- package/dist/components/cart/cart-panel/cart-line-item.js.map +1 -0
- package/dist/components/cart/cart-panel/index.d.ts +19 -0
- package/dist/components/cart/cart-panel/index.js +65 -0
- package/dist/components/cart/cart-panel/index.js.map +1 -0
- package/dist/components/cart/cart-panel/promo-code.d.ts +4 -0
- package/dist/components/cart/cart-panel/promo-code.js +62 -0
- package/dist/components/cart/cart-panel/promo-code.js.map +1 -0
- package/dist/components/cart/cart-panel/total-area.d.ts +7 -0
- package/dist/components/cart/cart-panel/total-area.js +14 -0
- package/dist/components/cart/cart-panel/total-area.js.map +1 -0
- package/dist/components/checkout/payment-step-form/card-icon-row.d.ts +2 -0
- package/dist/components/checkout/payment-step-form/card-icon-row.js +14 -0
- package/dist/components/checkout/payment-step-form/card-icon-row.js.map +1 -0
- package/dist/components/checkout/payment-step-form/card-icons/amex.d.ts +4 -0
- package/dist/components/checkout/payment-step-form/card-icons/amex.js +6 -0
- package/dist/components/checkout/payment-step-form/card-icons/amex.js.map +1 -0
- package/dist/components/checkout/payment-step-form/card-icons/diners-club.d.ts +4 -0
- package/dist/components/checkout/payment-step-form/card-icons/diners-club.js +6 -0
- package/dist/components/checkout/payment-step-form/card-icons/diners-club.js.map +1 -0
- package/dist/components/checkout/payment-step-form/card-icons/discover.d.ts +4 -0
- package/dist/components/checkout/payment-step-form/card-icons/discover.js +6 -0
- package/dist/components/checkout/payment-step-form/card-icons/discover.js.map +1 -0
- package/dist/components/checkout/payment-step-form/card-icons/jcb.d.ts +4 -0
- package/dist/components/checkout/payment-step-form/card-icons/jcb.js +6 -0
- package/dist/components/checkout/payment-step-form/card-icons/jcb.js.map +1 -0
- package/dist/components/checkout/payment-step-form/card-icons/mastercard.d.ts +4 -0
- package/dist/components/checkout/payment-step-form/card-icons/mastercard.js +6 -0
- package/dist/components/checkout/payment-step-form/card-icons/mastercard.js.map +1 -0
- package/dist/components/checkout/payment-step-form/card-icons/visa.d.ts +4 -0
- package/dist/components/checkout/payment-step-form/card-icons/visa.js +6 -0
- package/dist/components/checkout/payment-step-form/card-icons/visa.js.map +1 -0
- package/dist/components/checkout/payment-step-form/cc-button.d.ts +3 -0
- package/dist/components/checkout/payment-step-form/cc-button.js +6 -0
- package/dist/components/checkout/payment-step-form/cc-button.js.map +1 -0
- package/dist/components/checkout/payment-step-form/contact-form.d.ts +5 -0
- package/dist/components/checkout/payment-step-form/contact-form.js +6 -0
- package/dist/components/checkout/payment-step-form/contact-form.js.map +1 -0
- package/dist/components/checkout/payment-step-form/crypto-icons/btc.d.ts +4 -0
- package/dist/components/checkout/payment-step-form/crypto-icons/btc.js +6 -0
- package/dist/components/checkout/payment-step-form/crypto-icons/btc.js.map +1 -0
- package/dist/components/checkout/payment-step-form/crypto-icons/eth.d.ts +4 -0
- package/dist/components/checkout/payment-step-form/crypto-icons/eth.js +6 -0
- package/dist/components/checkout/payment-step-form/crypto-icons/eth.js.map +1 -0
- package/dist/components/checkout/payment-step-form/crypto-icons/usdt.d.ts +4 -0
- package/dist/components/checkout/payment-step-form/crypto-icons/usdt.js +6 -0
- package/dist/components/checkout/payment-step-form/crypto-icons/usdt.js.map +1 -0
- package/dist/components/checkout/payment-step-form/index.d.ts +4 -0
- package/dist/components/checkout/payment-step-form/index.js +77 -0
- package/dist/components/checkout/payment-step-form/index.js.map +1 -0
- package/dist/components/checkout/payment-step-form/methods/bank-transfer.d.ts +4 -0
- package/dist/components/checkout/payment-step-form/methods/bank-transfer.js +24 -0
- package/dist/components/checkout/payment-step-form/methods/bank-transfer.js.map +1 -0
- package/dist/components/checkout/payment-step-form/methods/card.d.ts +4 -0
- package/dist/components/checkout/payment-step-form/methods/card.js +160 -0
- package/dist/components/checkout/payment-step-form/methods/card.js.map +1 -0
- package/dist/components/checkout/payment-step-form/methods/crypto.d.ts +9 -0
- package/dist/components/checkout/payment-step-form/methods/crypto.js +137 -0
- package/dist/components/checkout/payment-step-form/methods/crypto.js.map +1 -0
- package/dist/components/checkout/payment-step-form/methods/index.d.ts +6 -0
- package/dist/components/checkout/payment-step-form/methods/index.js +21 -0
- package/dist/components/checkout/payment-step-form/methods/index.js.map +1 -0
- package/dist/components/checkout/shipping-step-form.d.ts +3 -0
- package/dist/components/checkout/shipping-step-form.js +53 -0
- package/dist/components/checkout/shipping-step-form.js.map +1 -0
- package/dist/components/index.d.ts +8 -0
- package/dist/components/index.js +9 -0
- package/dist/components/index.js.map +1 -0
- package/dist/components/item/product-card.d.ts +7 -0
- package/dist/components/item/product-card.js +9 -0
- package/dist/components/item/product-card.js.map +1 -0
- package/dist/components/item-selector/button.d.ts +4 -0
- package/dist/components/item-selector/button.js +47 -0
- package/dist/components/item-selector/button.js.map +1 -0
- package/dist/components/item-selector/carousel/index.d.ts +12 -0
- package/dist/components/item-selector/carousel/index.js +74 -0
- package/dist/components/item-selector/carousel/index.js.map +1 -0
- package/dist/components/item-selector/carousel/slider.d.ts +8 -0
- package/dist/components/item-selector/carousel/slider.js +12 -0
- package/dist/components/item-selector/carousel/slider.js.map +1 -0
- package/dist/components/item-selector/index.d.ts +2 -0
- package/dist/components/item-selector/index.js +3 -0
- package/dist/components/item-selector/index.js.map +1 -0
- package/dist/components/item-selector/quantity-indicator.d.ts +9 -0
- package/dist/components/item-selector/quantity-indicator.js +16 -0
- package/dist/components/item-selector/quantity-indicator.js.map +1 -0
- package/dist/components/node-tabs/index.d.ts +14 -0
- package/dist/components/node-tabs/index.js +42 -0
- package/dist/components/node-tabs/index.js.map +1 -0
- package/dist/components/node-tabs/node-image.d.ts +6 -0
- package/dist/components/node-tabs/node-image.js +13 -0
- package/dist/components/node-tabs/node-image.js.map +1 -0
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/index.js.map +1 -0
- package/dist/service/context.d.ts +8 -0
- package/dist/service/context.js +19 -0
- package/dist/service/context.js.map +1 -0
- package/dist/service/debug.d.ts +10 -0
- package/dist/service/debug.js +30 -0
- package/dist/service/debug.js.map +1 -0
- package/dist/service/impls/standalone/actual-line-item.d.ts +40 -0
- package/dist/service/impls/standalone/actual-line-item.js +84 -0
- package/dist/service/impls/standalone/actual-line-item.js.map +1 -0
- package/dist/service/impls/standalone/get-instance.d.ts +2 -0
- package/dist/service/impls/standalone/get-instance.js +39 -0
- package/dist/service/impls/standalone/get-instance.js.map +1 -0
- package/dist/service/impls/standalone/index.d.ts +67 -0
- package/dist/service/impls/standalone/index.js +416 -0
- package/dist/service/impls/standalone/index.js.map +1 -0
- package/dist/service/impls/standalone/order/firebase.d.ts +2 -0
- package/dist/service/impls/standalone/order/firebase.js +13 -0
- package/dist/service/impls/standalone/order/firebase.js.map +1 -0
- package/dist/service/impls/standalone/order/index.d.ts +24 -0
- package/dist/service/impls/standalone/order/index.js +61 -0
- package/dist/service/impls/standalone/order/index.js.map +1 -0
- package/dist/service/impls/standalone/persistence.d.ts +4 -0
- package/dist/service/impls/standalone/persistence.js +22 -0
- package/dist/service/impls/standalone/persistence.js.map +1 -0
- package/dist/service/path-utils.d.ts +7 -0
- package/dist/service/path-utils.js +16 -0
- package/dist/service/path-utils.js.map +1 -0
- package/dist/service/sep.d.ts +6 -0
- package/dist/service/sep.js +6 -0
- package/dist/service/sep.js.map +1 -0
- package/dist/types/category-node.d.ts +36 -0
- package/dist/types/category-node.js +2 -0
- package/dist/types/category-node.js.map +1 -0
- package/dist/types/checkout.d.ts +33 -0
- package/dist/types/checkout.js +2 -0
- package/dist/types/checkout.js.map +1 -0
- package/dist/types/commerce-config.d.ts +11 -0
- package/dist/types/commerce-config.js +2 -0
- package/dist/types/commerce-config.js.map +1 -0
- package/dist/types/commerce-service.d.ts +109 -0
- package/dist/types/commerce-service.js +2 -0
- package/dist/types/commerce-service.js.map +1 -0
- package/dist/types/family.d.ts +16 -0
- package/dist/types/family.js +2 -0
- package/dist/types/family.js.map +1 -0
- package/dist/types/index.d.ts +13 -0
- package/dist/types/index.js +8 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types/item-selector.d.ts +72 -0
- package/dist/types/item-selector.js +2 -0
- package/dist/types/item-selector.js.map +1 -0
- package/dist/types/line-item.d.ts +14 -0
- package/dist/types/line-item.js +2 -0
- package/dist/types/line-item.js.map +1 -0
- package/dist/types/multi-family-selector-props.d.ts +16 -0
- package/dist/types/multi-family-selector-props.js +2 -0
- package/dist/types/multi-family-selector-props.js.map +1 -0
- package/dist/types/product.d.ts +15 -0
- package/dist/types/product.js +2 -0
- package/dist/types/product.js.map +1 -0
- package/dist/types/promo.d.ts +7 -0
- package/dist/types/promo.js +2 -0
- package/dist/types/promo.js.map +1 -0
- package/dist/types/selection-ui-specifier.d.ts +40 -0
- package/dist/types/selection-ui-specifier.js +2 -0
- package/dist/types/selection-ui-specifier.js.map +1 -0
- package/dist/types/string-mutator.d.ts +9 -0
- package/dist/types/string-mutator.js +2 -0
- package/dist/types/string-mutator.js.map +1 -0
- package/dist/types/token-separators.d.ts +6 -0
- package/dist/types/token-separators.js +2 -0
- package/dist/types/token-separators.js.map +1 -0
- package/dist/util/analytics.d.ts +9 -0
- package/dist/util/analytics.js +10 -0
- package/dist/util/analytics.js.map +1 -0
- package/dist/util/countries.d.ts +7 -0
- package/dist/util/countries.js +197 -0
- package/dist/util/countries.js.map +1 -0
- package/dist/util/error.d.ts +1 -0
- package/dist/util/error.js +22 -0
- package/dist/util/error.js.map +1 -0
- package/dist/util/index.d.ts +15 -0
- package/dist/util/index.js +54 -0
- package/dist/util/index.js.map +1 -0
- package/dist/util/item-selector-options-accessor.d.ts +3 -0
- package/dist/util/item-selector-options-accessor.js +27 -0
- package/dist/util/item-selector-options-accessor.js.map +1 -0
- package/dist/util/line-item-ref.d.ts +8 -0
- package/dist/util/line-item-ref.js +15 -0
- package/dist/util/line-item-ref.js.map +1 -0
- package/dist/util/multi-family-selector-options-accessor.d.ts +3 -0
- package/dist/util/multi-family-selector-options-accessor.js +11 -0
- package/dist/util/multi-family-selector-options-accessor.js.map +1 -0
- package/dist/util/obs-string-mutator.d.ts +8 -0
- package/dist/util/obs-string-mutator.js +15 -0
- package/dist/util/obs-string-mutator.js.map +1 -0
- package/dist/util/product-media-accessor.d.ts +29 -0
- package/dist/util/product-media-accessor.js +22 -0
- package/dist/util/product-media-accessor.js.map +1 -0
- package/dist/util/promo-codes.d.ts +3 -0
- package/dist/util/promo-codes.js +100 -0
- package/dist/util/promo-codes.js.map +1 -0
- package/dist/util/selection-ui-specifiers.d.ts +3 -0
- package/dist/util/selection-ui-specifiers.js +24 -0
- package/dist/util/selection-ui-specifiers.js.map +1 -0
- package/dist/util/square-payment.d.ts +7 -0
- package/dist/util/square-payment.js +37 -0
- package/dist/util/square-payment.js.map +1 -0
- package/dist/util/use-sync-sku-param-w-current-item.d.ts +2 -0
- package/dist/util/use-sync-sku-param-w-current-item.js +61 -0
- package/dist/util/use-sync-sku-param-w-current-item.js.map +1 -0
- package/index.ts +13 -0
- package/libreapps-ui.d.ts +108 -0
- package/package.json +67 -0
- package/service/context.tsx +45 -0
- package/service/debug.ts +41 -0
- package/service/impls/standalone/actual-line-item.ts +136 -0
- package/service/impls/standalone/get-instance.ts +64 -0
- package/service/impls/standalone/index.ts +579 -0
- package/service/impls/standalone/order/firebase.ts +14 -0
- package/service/impls/standalone/order/index.ts +129 -0
- package/service/impls/standalone/persistence.ts +33 -0
- package/service/path-utils.ts +26 -0
- package/service/sep.ts +7 -0
- package/tsconfig.json +17 -0
- package/types/README.md +2 -0
- package/types/category-node.ts +50 -0
- package/types/checkout.ts +47 -0
- package/types/commerce-config.ts +13 -0
- package/types/commerce-service.ts +128 -0
- package/types/family.ts +26 -0
- package/types/index.ts +15 -0
- package/types/item-selector.ts +97 -0
- package/types/line-item.ts +29 -0
- package/types/multi-family-selector-props.ts +20 -0
- package/types/product.ts +21 -0
- package/types/promo.ts +10 -0
- package/types/selection-ui-specifier.ts +52 -0
- package/types/string-mutator.ts +14 -0
- package/types/token-separators.ts +7 -0
- package/util/analytics.ts +21 -0
- package/util/countries.ts +196 -0
- package/util/error.ts +34 -0
- package/util/index.ts +71 -0
- package/util/item-selector-options-accessor.ts +35 -0
- package/util/line-item-ref.ts +23 -0
- package/util/multi-family-selector-options-accessor.ts +15 -0
- package/util/obs-string-mutator.ts +22 -0
- package/util/product-media-accessor.ts +58 -0
- package/util/promo-codes.ts +106 -0
- package/util/selection-ui-specifiers.ts +30 -0
- package/util/square-payment.ts +50 -0
- package/util/use-sync-sku-param-w-current-item.ts +88 -0
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
const referallCodeDiscountedSkus = [
|
|
2
|
+
'LXM-CR-B-ABT', 'LXM-CR-B-GM', 'LXM-CR-F-CC', 'LXM-CR-F-IC', 'LXM-CR-E-24G', 'LXM-CR-E-SS', 'LXM-CR-S-RT', // credit cards
|
|
3
|
+
'LXM-VL-GN', 'LXM-VL-VL', 'LXM-VL-MI', 'LXM-VL-NA', // validators
|
|
4
|
+
'LXM-PS-PS', // pass
|
|
5
|
+
'LXM-AG-B-1_OZ', // silver
|
|
6
|
+
];
|
|
7
|
+
const PROMO_CODES = [
|
|
8
|
+
{
|
|
9
|
+
type: 'percent',
|
|
10
|
+
code: 'ANGEL',
|
|
11
|
+
value: 22
|
|
12
|
+
},
|
|
13
|
+
{
|
|
14
|
+
type: 'percent',
|
|
15
|
+
code: 'NASSER',
|
|
16
|
+
value: 11.11
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
type: 'percent',
|
|
20
|
+
code: 'ROSEY',
|
|
21
|
+
value: 20
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
type: 'percent',
|
|
25
|
+
code: 'IYKYK',
|
|
26
|
+
value: 11.1
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
type: 'percent',
|
|
30
|
+
code: 'GENESIS',
|
|
31
|
+
value: 99,
|
|
32
|
+
skus: ['LXM-PS-PS']
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
type: 'percent',
|
|
36
|
+
code: 'ANTJE',
|
|
37
|
+
value: 33.3,
|
|
38
|
+
skus: referallCodeDiscountedSkus
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
type: 'percent',
|
|
42
|
+
code: 'ASHLEY',
|
|
43
|
+
value: 33.3,
|
|
44
|
+
skus: referallCodeDiscountedSkus
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
type: 'percent',
|
|
48
|
+
code: 'CALE',
|
|
49
|
+
value: 33.3,
|
|
50
|
+
skus: referallCodeDiscountedSkus
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
type: 'percent',
|
|
54
|
+
code: 'DARA',
|
|
55
|
+
value: 33.3,
|
|
56
|
+
skus: referallCodeDiscountedSkus
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
type: 'percent',
|
|
60
|
+
code: 'KENJI',
|
|
61
|
+
value: 33.3,
|
|
62
|
+
skus: referallCodeDiscountedSkus
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
type: 'percent',
|
|
66
|
+
code: 'MAJOR',
|
|
67
|
+
value: 33.3,
|
|
68
|
+
skus: referallCodeDiscountedSkus
|
|
69
|
+
},
|
|
70
|
+
{
|
|
71
|
+
type: 'percent',
|
|
72
|
+
code: 'CYRUS',
|
|
73
|
+
value: 33.3,
|
|
74
|
+
skus: referallCodeDiscountedSkus
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
type: 'percent',
|
|
78
|
+
code: 'STOBIE',
|
|
79
|
+
value: 33.3,
|
|
80
|
+
skus: referallCodeDiscountedSkus
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
type: 'percent',
|
|
84
|
+
code: 'SKYLER',
|
|
85
|
+
value: 33.3,
|
|
86
|
+
skus: referallCodeDiscountedSkus
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
type: 'percent',
|
|
90
|
+
code: 'ZEEKAY',
|
|
91
|
+
value: 33.3,
|
|
92
|
+
skus: referallCodeDiscountedSkus
|
|
93
|
+
}
|
|
94
|
+
];
|
|
95
|
+
// TODO: implement a real API call
|
|
96
|
+
const getPromoFromApi = async (code) => {
|
|
97
|
+
return PROMO_CODES.find(promo => promo.code === code);
|
|
98
|
+
};
|
|
99
|
+
export { getPromoFromApi as default };
|
|
100
|
+
//# sourceMappingURL=promo-codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promo-codes.js","sourceRoot":"","sources":["../../util/promo-codes.ts"],"names":[],"mappings":"AAEA,MAAM,0BAA0B,GAAG;IACjC,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,aAAa,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,eAAe;IAC1H,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa;IACjE,WAAW,EAAG,OAAO;IACrB,eAAe,EAAE,SAAS;CAC3B,CAAA;AAED,MAAM,WAAW,GAAY;IAC3B;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,EAAE;KACV;IACD;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,QAAQ;QACd,KAAK,EAAE,KAAK;KACb;IACD;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,EAAE;KACV;IACD;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,OAAO;QACb,KAAK,EAAE,IAAI;KACZ;IACD;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,SAAS;QACf,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,CAAC,WAAW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AAI,CAAC,CAAA;AACvD,CAAC,CAAA;AAED,OAAO,EACL,eAAe,IAAI,OAAO,EAC3B,CAAA"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import sep from '../service/sep';
|
|
2
|
+
const DEFAULT = {
|
|
3
|
+
multiFamily: {
|
|
4
|
+
type: 'all-variants-carousel'
|
|
5
|
+
},
|
|
6
|
+
singleFamily: { type: 'carousel' }
|
|
7
|
+
};
|
|
8
|
+
const map = new Map();
|
|
9
|
+
// key: first two tokens of path
|
|
10
|
+
export const initSelectionUI = (v) => {
|
|
11
|
+
// Might have multiple calls client and server side
|
|
12
|
+
if (map.size > 0) {
|
|
13
|
+
map.clear();
|
|
14
|
+
}
|
|
15
|
+
for (let [key, value] of Object.entries(v)) {
|
|
16
|
+
map.set(key, value);
|
|
17
|
+
}
|
|
18
|
+
};
|
|
19
|
+
export const getSelectionUISpecifier = (skuPath) => {
|
|
20
|
+
const key = skuPath.split(sep.tok).slice(0, 2).join(sep.tok);
|
|
21
|
+
const result = map.get(key);
|
|
22
|
+
return result ?? DEFAULT;
|
|
23
|
+
};
|
|
24
|
+
//# sourceMappingURL=selection-ui-specifiers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"selection-ui-specifiers.js","sourceRoot":"","sources":["../../util/selection-ui-specifiers.ts"],"names":[],"mappings":"AACA,OAAO,GAAG,MAAM,gBAAgB,CAAA;AAEhC,MAAM,OAAO,GAAG;IACd,WAAW,EAAE;QACX,IAAI,EAAE,uBAAuB;KAC9B;IACD,YAAY,EAAE,EAAE,IAAI,EAAE,UAAU,EAAE;CACJ,CAAA;AAEhC,MAAM,GAAG,GAAG,IAAI,GAAG,EAAgC,CAAA;AAEjD,gCAAgC;AAClC,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,CAAuC,EAAE,EAAE;IAEvE,mDAAmD;IACrD,IAAI,GAAG,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;QACjB,GAAG,CAAC,KAAK,EAAE,CAAA;IACb,CAAC;IAED,KAAK,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC;QAC3C,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,KAAK,CAAC,CAAA;IACrB,CAAC;AACH,CAAC,CAAA;AAED,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,OAAe,EAAwB,EAAE;IAC/E,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC5D,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;IAC3B,OAAO,MAAM,IAAI,OAAO,CAAA;AAC1B,CAAC,CAAA"}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
// Payment processing - requires API endpoint
|
|
2
|
+
// For static builds, this will call an external payment API
|
|
3
|
+
BigInt.prototype.toJSON = function () { return this.toString(); };
|
|
4
|
+
const processPayment = async (sourceId, amount, verificationToken) => {
|
|
5
|
+
// For static builds, payments should be processed via an API endpoint
|
|
6
|
+
// Check if we're in a browser environment
|
|
7
|
+
if (typeof window !== 'undefined') {
|
|
8
|
+
// Client-side: call the payment API
|
|
9
|
+
try {
|
|
10
|
+
const response = await fetch('/api/payment', {
|
|
11
|
+
method: 'POST',
|
|
12
|
+
headers: {
|
|
13
|
+
'Content-Type': 'application/json',
|
|
14
|
+
},
|
|
15
|
+
body: JSON.stringify({
|
|
16
|
+
sourceId,
|
|
17
|
+
amount,
|
|
18
|
+
verificationToken
|
|
19
|
+
})
|
|
20
|
+
});
|
|
21
|
+
if (!response.ok) {
|
|
22
|
+
console.error('Payment API error:', response.statusText);
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
return await response.json();
|
|
26
|
+
}
|
|
27
|
+
catch (error) {
|
|
28
|
+
console.error('Error processing payment:', error);
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
// Server-side (for SSR builds only, not static export)
|
|
33
|
+
console.warn('Server-side payment processing not available in static export');
|
|
34
|
+
return null;
|
|
35
|
+
};
|
|
36
|
+
export { processPayment as default };
|
|
37
|
+
//# sourceMappingURL=square-payment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"square-payment.js","sourceRoot":"","sources":["../../util/square-payment.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,4DAA4D;AAS5D,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,cAAa,OAAO,IAAI,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAA;AAEhE,MAAM,cAAc,GAAG,KAAK,EAAE,QAAgB,EAAE,MAAc,EAAE,iBAAyB,EAAE,EAAE;IAC3F,sEAAsE;IACtE,0CAA0C;IAC1C,IAAI,OAAO,MAAM,KAAK,WAAW,EAAE,CAAC;QAClC,oCAAoC;QACpC,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,cAAc,EAAE;gBAC3C,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACnB,QAAQ;oBACR,MAAM;oBACN,iBAAiB;iBAClB,CAAC;aACH,CAAC,CAAA;YAEF,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;gBACjB,OAAO,CAAC,KAAK,CAAC,oBAAoB,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAA;gBACxD,OAAO,IAAI,CAAA;YACb,CAAC;YAED,OAAO,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAA;QAC9B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,2BAA2B,EAAE,KAAK,CAAC,CAAA;YACjD,OAAO,IAAI,CAAA;QACb,CAAC;IACH,CAAC;IAED,uDAAuD;IACvD,OAAO,CAAC,IAAI,CAAC,+DAA+D,CAAC,CAAA;IAC7E,OAAO,IAAI,CAAA;AACb,CAAC,CAAA;AAED,OAAO,EACL,cAAc,IAAI,OAAO,EAC1B,CAAA"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useEffect } from 'react';
|
|
3
|
+
import { reaction } from 'mobx';
|
|
4
|
+
import { useQueryState, parseAsString, parseAsBoolean, } from 'next-usequerystate';
|
|
5
|
+
import { useCommerce } from '../service/context';
|
|
6
|
+
import sep from '../service/sep';
|
|
7
|
+
const PLEASE_SELECT_FACETS = 'Please select an option from each group.';
|
|
8
|
+
const useSyncSkuParamWithCurrentItem = (familyLevel, setMessage, setLoading) => {
|
|
9
|
+
const cmmc = useCommerce();
|
|
10
|
+
const [skuParam, setSkuParam] = useQueryState('sku', parseAsString.withDefault('').withOptions({ clearOnDefault: true }));
|
|
11
|
+
const [addParam, setAddParam] = useQueryState('add', parseAsBoolean.withDefault(false).withOptions({ clearOnDefault: true }));
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
return reaction(() => ({
|
|
14
|
+
specifiedCat: cmmc.selectedFamilies.length === 1 ? cmmc.selectedFamilies[0] : undefined,
|
|
15
|
+
currentItem: cmmc.currentItem
|
|
16
|
+
}), ({ specifiedCat, currentItem }) => {
|
|
17
|
+
//console.log("REACTION: " + `CAT ID: ${family?.id} SKU: ${item?.sku}`)
|
|
18
|
+
if (currentItem) {
|
|
19
|
+
// if we set the currentItem w sku, then user selects other facets
|
|
20
|
+
if (specifiedCat && currentItem.familyId != specifiedCat.id) {
|
|
21
|
+
cmmc.setCurrentItem(specifiedCat.products[0].sku);
|
|
22
|
+
}
|
|
23
|
+
setSkuParam(cmmc.currentItem.sku);
|
|
24
|
+
}
|
|
25
|
+
else if (specifiedCat) {
|
|
26
|
+
cmmc.setCurrentItem(specifiedCat.products[0].sku);
|
|
27
|
+
setSkuParam(cmmc.currentItem.sku);
|
|
28
|
+
}
|
|
29
|
+
});
|
|
30
|
+
}, []);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
const setCurrentFamilyFromSku = (sku) => {
|
|
33
|
+
const toks = sku.split(sep.tok);
|
|
34
|
+
const fv = {};
|
|
35
|
+
// TODO: confirm that extra trailing nonsense tokens won't break selectPaths()
|
|
36
|
+
for (let i = 1; i < familyLevel; i++) {
|
|
37
|
+
if (i in toks) {
|
|
38
|
+
fv[i] = [toks[i]];
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
cmmc.selectPaths(fv);
|
|
42
|
+
};
|
|
43
|
+
// setCI returns true if it's a recognized sku
|
|
44
|
+
if (skuParam && cmmc.setCurrentItem(skuParam)) {
|
|
45
|
+
if (addParam) {
|
|
46
|
+
if (cmmc.currentItem.quantity === 0) {
|
|
47
|
+
cmmc.currentItem.increment();
|
|
48
|
+
}
|
|
49
|
+
setAddParam(false);
|
|
50
|
+
}
|
|
51
|
+
setCurrentFamilyFromSku(skuParam);
|
|
52
|
+
setMessage(undefined);
|
|
53
|
+
}
|
|
54
|
+
else {
|
|
55
|
+
setMessage(PLEASE_SELECT_FACETS);
|
|
56
|
+
}
|
|
57
|
+
setLoading && setLoading(false);
|
|
58
|
+
}, [skuParam]);
|
|
59
|
+
};
|
|
60
|
+
export default useSyncSkuParamWithCurrentItem;
|
|
61
|
+
//# sourceMappingURL=use-sync-sku-param-w-current-item.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-sync-sku-param-w-current-item.js","sourceRoot":"","sources":["../../util/use-sync-sku-param-w-current-item.ts"],"names":[],"mappings":"AAAA,YAAY,CAAA;AACZ,OAAO,EAAG,SAAS,EAAE,MAAM,OAAO,CAAA;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,MAAM,CAAA;AAE/B,OAAO,EACL,aAAa,EACb,aAAa,EACb,cAA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oBAAoB,CAAC,CAAA;QAClC,CAAC;QAED,UAAU,IAAI,UAAU,CAAC,KAAK,CAAC,CAAA;IACjC,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAA;AAChB,CAAC,CAAA;AAED,eAAe,8BAA8B,CAAA"}
|
package/index.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export * from './service/context'
|
|
2
|
+
export * from './components'
|
|
3
|
+
// Impl-dependent, so leave w impl
|
|
4
|
+
export type { StandaloneServiceOptions as ServiceOptions } from './service/impls/standalone'
|
|
5
|
+
export {
|
|
6
|
+
useSyncSkuParamWithCurrentItem,
|
|
7
|
+
getFacetValuesMutator,
|
|
8
|
+
formatCurrencyValue,
|
|
9
|
+
ProductMediaAccessor,
|
|
10
|
+
LineItemRef
|
|
11
|
+
} from './util'
|
|
12
|
+
|
|
13
|
+
export * from './util/selection-ui-specifiers'
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
// Temporary type declarations for @libreapps/ui imports
|
|
2
|
+
// Until proper .d.ts files are generated
|
|
3
|
+
|
|
4
|
+
declare module '@libreapps/ui/types' {
|
|
5
|
+
export type Dimensions = any
|
|
6
|
+
export type MediaStackDef = any
|
|
7
|
+
export type ImageDef = any
|
|
8
|
+
export type VideoDef = any
|
|
9
|
+
export type AnimationDef = any
|
|
10
|
+
export type MediaTransform = any
|
|
11
|
+
export type LinkDef = any
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
declare module '@libreapps/ui/primitives' {
|
|
15
|
+
export type CarouselApi = any
|
|
16
|
+
export type CarouselOptions = any
|
|
17
|
+
export const Carousel: any
|
|
18
|
+
export const CarouselContent: any
|
|
19
|
+
export const CarouselItem: any
|
|
20
|
+
export const CarouselNext: any
|
|
21
|
+
export const CarouselPrevious: any
|
|
22
|
+
export const Button: any
|
|
23
|
+
export const buttonVariants: any
|
|
24
|
+
export const Input: any
|
|
25
|
+
export const Label: any
|
|
26
|
+
export const Separator: any
|
|
27
|
+
export const toast: any
|
|
28
|
+
export const Toaster: any
|
|
29
|
+
export const Image: any
|
|
30
|
+
export const Select: any
|
|
31
|
+
export const SelectContent: any
|
|
32
|
+
export const SelectGroup: any
|
|
33
|
+
export const SelectItem: any
|
|
34
|
+
export const SelectTrigger: any
|
|
35
|
+
export const SelectValue: any
|
|
36
|
+
export const RadioGroup: any
|
|
37
|
+
export const ScrollArea: any
|
|
38
|
+
export const ApplyTypography: any
|
|
39
|
+
export const MediaStack: any
|
|
40
|
+
export const Slider: any
|
|
41
|
+
export const Skeleton: any
|
|
42
|
+
export const Card: any
|
|
43
|
+
export const CardContent: any
|
|
44
|
+
export const CardFooter: any
|
|
45
|
+
export const CardHeader: any
|
|
46
|
+
export const CardTitle: any
|
|
47
|
+
export const ToggleGroup: any
|
|
48
|
+
export const ToggleGroupItem: any
|
|
49
|
+
export const Tabs: any
|
|
50
|
+
export const TabsContent: any
|
|
51
|
+
export const TabsList: any
|
|
52
|
+
export const TabsTrigger: any
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
declare module '@libreapps/ui/form' {
|
|
56
|
+
export const Form: any
|
|
57
|
+
export const FormControl: any
|
|
58
|
+
export const FormField: any
|
|
59
|
+
export const FormItem: any
|
|
60
|
+
export const FormLabel: any
|
|
61
|
+
export const FormMessage: any
|
|
62
|
+
export const FormDescription: any
|
|
63
|
+
export const useFormField: any
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
declare module '@libreapps/ui/util' {
|
|
67
|
+
export function cn(...inputs: any[]): string
|
|
68
|
+
export type VariantProps<T> = any
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Workaround for lucide-react with React 19 type mismatches
|
|
72
|
+
declare module 'lucide-react' {
|
|
73
|
+
import type { SVGProps } from 'react'
|
|
74
|
+
export type LucideProps = SVGProps<SVGSVGElement>
|
|
75
|
+
export const ChevronLeft: any
|
|
76
|
+
export const ChevronRight: any
|
|
77
|
+
export const Minus: any
|
|
78
|
+
export const Plus: any
|
|
79
|
+
export const X: any
|
|
80
|
+
export const Check: any
|
|
81
|
+
export const CreditCard: any
|
|
82
|
+
export const ShoppingCart: any
|
|
83
|
+
export const Menu: any
|
|
84
|
+
export const Loader2: any
|
|
85
|
+
export const ChevronDown: any
|
|
86
|
+
export const ChevronsLeft: any
|
|
87
|
+
export const ChevronsRight: any
|
|
88
|
+
export const Image: any
|
|
89
|
+
export const Trash2: any
|
|
90
|
+
export const Search: any
|
|
91
|
+
export const Barcode: any
|
|
92
|
+
export const LockKeyhole: any
|
|
93
|
+
export const Copy: any
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
// Workaround for react-square-web-payments-sdk with React 19
|
|
97
|
+
declare module 'react-square-web-payments-sdk' {
|
|
98
|
+
export const ApplePay: any
|
|
99
|
+
export const GooglePay: any
|
|
100
|
+
export const CreditCard: any
|
|
101
|
+
export const PaymentForm: any
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
// Workaround for next/image with React 19
|
|
105
|
+
declare module 'next/image' {
|
|
106
|
+
const Image: any
|
|
107
|
+
export default Image
|
|
108
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@libreapps/commerce",
|
|
3
|
+
"version": "7.5.1",
|
|
4
|
+
"description": "e-commerce framework.",
|
|
5
|
+
"publishConfig": {
|
|
6
|
+
"registry": "https://registry.npmjs.org/",
|
|
7
|
+
"access": "public",
|
|
8
|
+
"scope": "@libreapps"
|
|
9
|
+
},
|
|
10
|
+
"author": "LibreApps Contributors",
|
|
11
|
+
"license": "BSD-3-Clause",
|
|
12
|
+
"repository": {
|
|
13
|
+
"type": "git",
|
|
14
|
+
"url": "git+https://github.com/libre-apps/UI.git",
|
|
15
|
+
"directory": "pkg/commerce"
|
|
16
|
+
},
|
|
17
|
+
"keywords": [
|
|
18
|
+
"cart",
|
|
19
|
+
"libreapps",
|
|
20
|
+
"libreapps"
|
|
21
|
+
],
|
|
22
|
+
"exports": {
|
|
23
|
+
".": "./index.ts",
|
|
24
|
+
"./types": "./types/index.ts",
|
|
25
|
+
"./debug": "./service/debug.ts"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"ethers": "^6.12.0",
|
|
29
|
+
"next-usequerystate": "^1.17.1",
|
|
30
|
+
"react-square-web-payments-sdk": "^3.2.1",
|
|
31
|
+
"square": "^35.1.0"
|
|
32
|
+
},
|
|
33
|
+
"peerDependencies": {
|
|
34
|
+
"firebase": "^10.8.0",
|
|
35
|
+
"@hookform/resolvers": "^3.3.4",
|
|
36
|
+
"@radix-ui/react-radio-group": "^1.1.3",
|
|
37
|
+
"lucide-react": ">=0.456.0",
|
|
38
|
+
"mobx": "^6.12.3",
|
|
39
|
+
"mobx-react-lite": "^4.0.7",
|
|
40
|
+
"mobx-utils": "^6.0.8",
|
|
41
|
+
"next": ">=14.2.16",
|
|
42
|
+
"react": "^18.0.0 || ^19.0.0",
|
|
43
|
+
"react-dom": "^18.0.0 || ^19.0.0",
|
|
44
|
+
"react-hook-form": ">=7.51.4",
|
|
45
|
+
"zod": "^3.23.8"
|
|
46
|
+
},
|
|
47
|
+
"peerDependenciesMeta": {
|
|
48
|
+
"firebase": {
|
|
49
|
+
"optional": true
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"devDependencies": {
|
|
53
|
+
"@types/react": "18.3.12",
|
|
54
|
+
"@types/react-dom": "18.3.1",
|
|
55
|
+
"firebase": "^10.14.1",
|
|
56
|
+
"cross-fetch": "^4.0.0",
|
|
57
|
+
"typescript": "5.6.3",
|
|
58
|
+
"@libreapps/auth": "3.0.1",
|
|
59
|
+
"@libreapps/ui": "5.4.1"
|
|
60
|
+
},
|
|
61
|
+
"scripts": {
|
|
62
|
+
"lat": "npm show @libreapps/commerce version",
|
|
63
|
+
"pub": "npm publish",
|
|
64
|
+
"tc": "tsc",
|
|
65
|
+
"build": "tsc --outDir dist --declaration --emitDeclarationOnly false --module ESNext --esModuleInterop true --skipLibCheck true --sourceMap true"
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
'use client'
|
|
2
|
+
import React, {
|
|
3
|
+
createContext,
|
|
4
|
+
useContext,
|
|
5
|
+
useRef,
|
|
6
|
+
type PropsWithChildren,
|
|
7
|
+
} from 'react'
|
|
8
|
+
|
|
9
|
+
// https://dev.to/ivandotv/mobx-server-side-rendering-with-next-js-4m18
|
|
10
|
+
import { enableStaticRendering } from 'mobx-react-lite'
|
|
11
|
+
enableStaticRendering(typeof window === "undefined")
|
|
12
|
+
|
|
13
|
+
import type CommerceService from '../types/commerce-service'
|
|
14
|
+
import type { CommerceConfig } from '../types'
|
|
15
|
+
import { getInstance } from './impls/standalone'
|
|
16
|
+
|
|
17
|
+
const CommerceContext = createContext<CommerceService | undefined>(undefined)
|
|
18
|
+
|
|
19
|
+
const useCommerce = (): CommerceService => {
|
|
20
|
+
return useContext(CommerceContext) as CommerceService
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
const CommerceProvider: React.FC<PropsWithChildren & {
|
|
24
|
+
config: CommerceConfig
|
|
25
|
+
}> = ({
|
|
26
|
+
children,
|
|
27
|
+
config
|
|
28
|
+
}) => {
|
|
29
|
+
|
|
30
|
+
// TODO: Inject Promo fixture here from siteDef
|
|
31
|
+
const service = getInstance(config)
|
|
32
|
+
const valueRef = useRef<CommerceService>(service)
|
|
33
|
+
|
|
34
|
+
return (
|
|
35
|
+
<CommerceContext.Provider value={valueRef.current}>
|
|
36
|
+
{children}
|
|
37
|
+
</CommerceContext.Provider>
|
|
38
|
+
)
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
useCommerce,
|
|
43
|
+
CommerceProvider
|
|
44
|
+
}
|
|
45
|
+
|
package/service/debug.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { CategoryNode, CategoryNodeRole, Family, LineItem } from '../types'
|
|
2
|
+
|
|
3
|
+
// Node recursion
|
|
4
|
+
export const categoryNodeDump = (node: CategoryNode, level: number = 0): void => {
|
|
5
|
+
const spacers: string[] = []
|
|
6
|
+
for (let i = 0; i < level; i++) {
|
|
7
|
+
spacers.push('----')
|
|
8
|
+
}
|
|
9
|
+
console.log("NODE:" + spacers.join(''), node.skuToken)
|
|
10
|
+
node.subNodes?.forEach((sn: CategoryNode) => {categoryNodeDump(sn, level + 1)})
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const selectedFamiliesDump = (result: Family[]): string => {
|
|
14
|
+
const toDisplay = result.map((c) => (c.id))
|
|
15
|
+
return JSON.stringify(toDisplay, null, 2)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export const peekDump = (result : {
|
|
19
|
+
role: CategoryNodeRole
|
|
20
|
+
family: Family | undefined
|
|
21
|
+
families: Family[] | undefined
|
|
22
|
+
node: CategoryNode | undefined
|
|
23
|
+
item: LineItem | undefined
|
|
24
|
+
} | string): string => {
|
|
25
|
+
|
|
26
|
+
if (typeof result === 'string') {
|
|
27
|
+
return result
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
const toDisplay = {
|
|
31
|
+
role: result.role,
|
|
32
|
+
item: result.item ? result.item.sku : 'UNDEF',
|
|
33
|
+
family: result.family ? result.family.id : 'UNDEF',
|
|
34
|
+
families: result.families ? result.families.map((f) => (f.id)) : 'UNDEF',
|
|
35
|
+
node: result.node ?
|
|
36
|
+
(result.node.skuToken + (result.node.label ? (': ' + result.node.label) : ''))
|
|
37
|
+
:
|
|
38
|
+
'UNDEF'
|
|
39
|
+
}
|
|
40
|
+
return JSON.stringify(toDisplay, null, 2)
|
|
41
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import {
|
|
2
|
+
action,
|
|
3
|
+
computed,
|
|
4
|
+
makeObservable,
|
|
5
|
+
observable,
|
|
6
|
+
} from 'mobx'
|
|
7
|
+
|
|
8
|
+
import type { ImageDef, MediaTransform, VideoDef } from '@libreapps/ui/types'
|
|
9
|
+
|
|
10
|
+
import type { Product, LineItem, CommerceService } from '../../../types'
|
|
11
|
+
|
|
12
|
+
interface ActualLineItemSnapshot {
|
|
13
|
+
sku: string
|
|
14
|
+
familyId: string // helps impl of restoreFromSnapshot
|
|
15
|
+
title: string
|
|
16
|
+
price: number
|
|
17
|
+
quantity: number
|
|
18
|
+
timeAdded: number
|
|
19
|
+
timeModified: number
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
class ActualLineItem
|
|
23
|
+
implements LineItem
|
|
24
|
+
{
|
|
25
|
+
qu: number = 0
|
|
26
|
+
|
|
27
|
+
id: string
|
|
28
|
+
sku: string
|
|
29
|
+
fullTitle?: string
|
|
30
|
+
optionLabel: string
|
|
31
|
+
optionLabelShort?: string
|
|
32
|
+
familyTitle: string
|
|
33
|
+
familyId: string
|
|
34
|
+
byline?: string
|
|
35
|
+
desc?: string
|
|
36
|
+
price: number
|
|
37
|
+
img?: ImageDef
|
|
38
|
+
video?: VideoDef
|
|
39
|
+
animation?: string
|
|
40
|
+
mediaTransform?: MediaTransform
|
|
41
|
+
optionImg?: ImageDef
|
|
42
|
+
|
|
43
|
+
timeAdded: number = 0 // Timestamp when added
|
|
44
|
+
timeModified: number = 0 // Timestamp quantity last modified (0 if not in cart)
|
|
45
|
+
|
|
46
|
+
constructor(prod: Product, snap?: ActualLineItemSnapshot) {
|
|
47
|
+
this.id = prod.id
|
|
48
|
+
this.sku = prod.sku
|
|
49
|
+
this.fullTitle = prod.fullTitle
|
|
50
|
+
this.optionLabel = prod.optionLabel
|
|
51
|
+
this.optionLabelShort = prod.optionLabelShort
|
|
52
|
+
this.familyTitle = prod.familyTitle
|
|
53
|
+
this.familyId = prod.familyId
|
|
54
|
+
this.byline = prod.byline
|
|
55
|
+
this.desc = prod.desc
|
|
56
|
+
this.price = prod.price
|
|
57
|
+
this.img = prod.img
|
|
58
|
+
this.video = prod.video
|
|
59
|
+
this.animation = prod.animation
|
|
60
|
+
this.optionImg = prod.optionImg
|
|
61
|
+
this.mediaTransform = prod.mediaTransform
|
|
62
|
+
|
|
63
|
+
if (snap) {
|
|
64
|
+
this.qu = snap.quantity
|
|
65
|
+
this.timeAdded = snap.timeAdded
|
|
66
|
+
this.timeModified = snap.timeModified
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
makeObservable(this, {
|
|
70
|
+
qu: observable,
|
|
71
|
+
timeAdded: observable,
|
|
72
|
+
timeModified: observable,
|
|
73
|
+
canDecrement: computed,
|
|
74
|
+
isInCart: computed,
|
|
75
|
+
title: computed,
|
|
76
|
+
increment: action,
|
|
77
|
+
decrement: action,
|
|
78
|
+
})
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
// TODO: create a way to pass template strings to the ui conf per sku path!
|
|
82
|
+
get title(): string {
|
|
83
|
+
return this.fullTitle ? this.fullTitle : (this.familyTitle + ', ' + this.optionLabel)
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
takeSnapshot = (cmmc: CommerceService): ActualLineItemSnapshot => {
|
|
87
|
+
|
|
88
|
+
const title = this.fullTitle ?
|
|
89
|
+
this.fullTitle
|
|
90
|
+
:
|
|
91
|
+
((cmmc.getFamilyById(this.familyId)?.title ?? this.familyTitle) + ', ' + this.optionLabel)
|
|
92
|
+
|
|
93
|
+
return({
|
|
94
|
+
sku: this.sku,
|
|
95
|
+
familyId: this.familyId,
|
|
96
|
+
title,
|
|
97
|
+
price: this.price,
|
|
98
|
+
quantity: this.qu,
|
|
99
|
+
timeAdded: this.timeAdded,
|
|
100
|
+
timeModified: this.timeModified
|
|
101
|
+
} satisfies ActualLineItemSnapshot)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
get canDecrement(): boolean { return this.qu > 0 }
|
|
105
|
+
get quantity(): number {return this.qu}
|
|
106
|
+
get isInCart(): boolean {return this.qu > 0}
|
|
107
|
+
|
|
108
|
+
increment(): void {
|
|
109
|
+
if (this.qu === 0) {
|
|
110
|
+
this.timeAdded = new Date().getTime()
|
|
111
|
+
this.timeModified = this.timeAdded
|
|
112
|
+
}
|
|
113
|
+
else {
|
|
114
|
+
this.timeModified = new Date().getTime()
|
|
115
|
+
}
|
|
116
|
+
this.qu++
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
decrement(): void {
|
|
120
|
+
if (this.canDecrement) {
|
|
121
|
+
this.qu--
|
|
122
|
+
if (this.qu === 0) {
|
|
123
|
+
this.timeAdded = 0
|
|
124
|
+
this.timeModified = 0
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
this.timeModified = new Date().getTime()
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export {
|
|
134
|
+
type ActualLineItemSnapshot,
|
|
135
|
+
ActualLineItem as default
|
|
136
|
+
}
|