@merchi/cart 1.4.4
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/LICENSE +21 -0
- package/README.md +134 -0
- package/esm/Cart.js +62 -0
- package/esm/CartAlert.js +47 -0
- package/esm/CartHeader.js +29 -0
- package/esm/CartProvider.js +1101 -0
- package/esm/CartTotals.js +89 -0
- package/esm/assets/merchi-monster-loader.gif +0 -0
- package/esm/assets/merchi-swipe-outline.png +0 -0
- package/esm/assets/product-not-found.png +0 -0
- package/esm/assets/stripe-payment-secure.png +0 -0
- package/esm/buttons/Button.js +23 -0
- package/esm/buttons/ButtonBack.js +35 -0
- package/esm/buttons/ButtonClearCart.js +17 -0
- package/esm/buttons/ButtonInvoiceDownload.js +88 -0
- package/esm/buttons/ButtonNext.js +39 -0
- package/esm/buttons/ButtonNextDynamic.js +19 -0
- package/esm/buttons/ButtonOpenCartMerchiCartModal.js +47 -0
- package/esm/buttons/ButtonPay.js +26 -0
- package/esm/buttons/ButtonShipmentTabNext.js +28 -0
- package/esm/buttons/index.js +7 -0
- package/esm/components/Alert.js +26 -0
- package/esm/components/CartBody.js +14 -0
- package/esm/components/CartClient.js +62 -0
- package/esm/components/CartFooter.js +12 -0
- package/esm/components/CartItemRow.js +230 -0
- package/esm/components/CartPaymentSettingsInvalid.js +13 -0
- package/esm/components/CartShipment.js +52 -0
- package/esm/components/CartTabContent.js +12 -0
- package/esm/components/CartTabPanel.js +25 -0
- package/esm/components/CartTableContainer.js +12 -0
- package/esm/components/CartTitle.js +26 -0
- package/esm/components/CartTotalsListGroup.js +71 -0
- package/esm/components/Collapse.js +32 -0
- package/esm/components/CustomCartProductForm.js +128 -0
- package/esm/components/CustomerCheckoutMethodTabs.js +94 -0
- package/esm/components/DiscountInputGroup.js +293 -0
- package/esm/components/LoadingTemplate.js +23 -0
- package/esm/components/NoCartItems.js +20 -0
- package/esm/components/ShipmentGroupCard.js +207 -0
- package/esm/components/Table.js +13 -0
- package/esm/components/containers.js +31 -0
- package/esm/components/index.js +18 -0
- package/esm/components/product-form-sdk-externals.js +36 -0
- package/esm/forms/FormNewCustomer.js +243 -0
- package/esm/forms/FormReturningCustomer.js +165 -0
- package/esm/forms/FormShipmentAddressAndNotes.js +195 -0
- package/esm/forms/FormSquarePayment.js +19 -0
- package/esm/forms/FormStripePayment.js +19 -0
- package/esm/forms/FormWhatsappCustomer.js +253 -0
- package/esm/forms/InputAcceptUserTermsAndConditions.js +35 -0
- package/esm/forms/InputError.js +16 -0
- package/esm/forms/InputSelect.js +48 -0
- package/esm/forms/InputText.js +56 -0
- package/esm/forms/InputsAddress.js +476 -0
- package/esm/forms/index.js +8 -0
- package/esm/index.js +13 -0
- package/esm/modals.js +51 -0
- package/esm/panels/PanelCartItems.js +49 -0
- package/esm/panels/PanelCartShipment.js +66 -0
- package/esm/panels/PanelClearCart.js +56 -0
- package/esm/panels/PanelClientCheckout.js +81 -0
- package/esm/panels/PanelEditCartItem.js +199 -0
- package/esm/panels/PanelPaymentSuccess.js +63 -0
- package/esm/panels/index.js +7 -0
- package/esm/square/SquareCard.js +106 -0
- package/esm/stripe/LegacyStripeCardForm.js +157 -0
- package/esm/stripe/StripeCardFields.js +126 -0
- package/esm/stripe/StripeCardForm.js +33 -0
- package/esm/stripe/StripePaymentButtons.js +98 -0
- package/esm/stripe/actions.js +192 -0
- package/esm/stripe/utils.js +20 -0
- package/esm/styles/globals.css +463 -0
- package/esm/styles/globals.css.map +1 -0
- package/esm/tabs/CartNav.js +28 -0
- package/esm/tabs/NavTab.js +31 -0
- package/esm/types/assets.d.js +0 -0
- package/esm/types/index.js +1 -0
- package/esm/types/merchi_product_form/index.d.js +0 -0
- package/esm/types/merchi_sdk_ts/index.d.js +0 -0
- package/esm/types/react-redux/index.d.js +0 -0
- package/esm/utilities/address.js +457 -0
- package/esm/utilities/area.js +297 -0
- package/esm/utilities/cart.js +95 -0
- package/esm/utilities/company.js +6 -0
- package/esm/utilities/cookie.js +156 -0
- package/esm/utilities/currency.js +219 -0
- package/esm/utilities/customForm.js +57 -0
- package/esm/utilities/helpers.js +229 -0
- package/esm/utilities/index.js +14 -0
- package/esm/utilities/invoice.js +112 -0
- package/esm/utilities/job.js +9 -0
- package/esm/utilities/local_storage.js +85 -0
- package/esm/utilities/product.js +13 -0
- package/esm/utilities/shipment.js +11 -0
- package/esm/utilities/tabs.js +51 -0
- package/esm/utilities/user.js +65 -0
- package/esm/utilities/variations.js +58 -0
- package/lib/Cart.d.ts +9 -0
- package/lib/Cart.js +69 -0
- package/lib/CartAlert.d.ts +3 -0
- package/lib/CartAlert.js +53 -0
- package/lib/CartHeader.d.ts +3 -0
- package/lib/CartHeader.js +37 -0
- package/lib/CartProvider.d.ts +236 -0
- package/lib/CartProvider.js +1107 -0
- package/lib/CartTotals.d.ts +7 -0
- package/lib/CartTotals.js +96 -0
- package/lib/assets/merchi-monster-loader.gif +0 -0
- package/lib/assets/merchi-swipe-outline.png +0 -0
- package/lib/assets/product-not-found.png +0 -0
- package/lib/assets/stripe-payment-secure.png +0 -0
- package/lib/buttons/Button.d.ts +11 -0
- package/lib/buttons/Button.js +31 -0
- package/lib/buttons/ButtonBack.d.ts +6 -0
- package/lib/buttons/ButtonBack.js +44 -0
- package/lib/buttons/ButtonClearCart.d.ts +3 -0
- package/lib/buttons/ButtonClearCart.js +24 -0
- package/lib/buttons/ButtonInvoiceDownload.d.ts +3 -0
- package/lib/buttons/ButtonInvoiceDownload.js +96 -0
- package/lib/buttons/ButtonNext.d.ts +3 -0
- package/lib/buttons/ButtonNext.js +48 -0
- package/lib/buttons/ButtonNextDynamic.d.ts +3 -0
- package/lib/buttons/ButtonNextDynamic.js +28 -0
- package/lib/buttons/ButtonOpenCartMerchiCartModal.d.ts +9 -0
- package/lib/buttons/ButtonOpenCartMerchiCartModal.js +57 -0
- package/lib/buttons/ButtonPay.d.ts +7 -0
- package/lib/buttons/ButtonPay.js +35 -0
- package/lib/buttons/ButtonShipmentTabNext.d.ts +2 -0
- package/lib/buttons/ButtonShipmentTabNext.js +37 -0
- package/lib/buttons/index.d.ts +7 -0
- package/lib/buttons/index.js +48 -0
- package/lib/components/Alert.d.ts +7 -0
- package/lib/components/Alert.js +34 -0
- package/lib/components/CartBody.d.ts +7 -0
- package/lib/components/CartBody.js +22 -0
- package/lib/components/CartClient.d.ts +4 -0
- package/lib/components/CartClient.js +71 -0
- package/lib/components/CartFooter.d.ts +6 -0
- package/lib/components/CartFooter.js +20 -0
- package/lib/components/CartItemRow.d.ts +7 -0
- package/lib/components/CartItemRow.js +236 -0
- package/lib/components/CartPaymentSettingsInvalid.d.ts +2 -0
- package/lib/components/CartPaymentSettingsInvalid.js +21 -0
- package/lib/components/CartShipment.d.ts +6 -0
- package/lib/components/CartShipment.js +59 -0
- package/lib/components/CartTabContent.d.ts +6 -0
- package/lib/components/CartTabContent.js +20 -0
- package/lib/components/CartTabPanel.d.ts +7 -0
- package/lib/components/CartTabPanel.js +31 -0
- package/lib/components/CartTableContainer.d.ts +6 -0
- package/lib/components/CartTableContainer.js +20 -0
- package/lib/components/CartTitle.d.ts +2 -0
- package/lib/components/CartTitle.js +34 -0
- package/lib/components/CartTotalsListGroup.d.ts +3 -0
- package/lib/components/CartTotalsListGroup.js +78 -0
- package/lib/components/Collapse.d.ts +3 -0
- package/lib/components/Collapse.js +40 -0
- package/lib/components/CustomCartProductForm.d.ts +18 -0
- package/lib/components/CustomCartProductForm.js +136 -0
- package/lib/components/CustomerCheckoutMethodTabs.d.ts +6 -0
- package/lib/components/CustomerCheckoutMethodTabs.js +103 -0
- package/lib/components/DiscountInputGroup.d.ts +2 -0
- package/lib/components/DiscountInputGroup.js +301 -0
- package/lib/components/LoadingTemplate.d.ts +7 -0
- package/lib/components/LoadingTemplate.js +30 -0
- package/lib/components/NoCartItems.d.ts +3 -0
- package/lib/components/NoCartItems.js +27 -0
- package/lib/components/ShipmentGroupCard.d.ts +7 -0
- package/lib/components/ShipmentGroupCard.js +215 -0
- package/lib/components/Table.d.ts +7 -0
- package/lib/components/Table.js +19 -0
- package/lib/components/containers.d.ts +14 -0
- package/lib/components/containers.js +40 -0
- package/lib/components/index.d.ts +18 -0
- package/lib/components/index.js +133 -0
- package/lib/components/product-form-sdk-externals.d.ts +46 -0
- package/lib/components/product-form-sdk-externals.js +43 -0
- package/lib/forms/FormNewCustomer.d.ts +4 -0
- package/lib/forms/FormNewCustomer.js +252 -0
- package/lib/forms/FormReturningCustomer.d.ts +3 -0
- package/lib/forms/FormReturningCustomer.js +173 -0
- package/lib/forms/FormShipmentAddressAndNotes.d.ts +15 -0
- package/lib/forms/FormShipmentAddressAndNotes.js +203 -0
- package/lib/forms/FormSquarePayment.d.ts +3 -0
- package/lib/forms/FormSquarePayment.js +27 -0
- package/lib/forms/FormStripePayment.d.ts +3 -0
- package/lib/forms/FormStripePayment.js +27 -0
- package/lib/forms/FormWhatsappCustomer.d.ts +3 -0
- package/lib/forms/FormWhatsappCustomer.js +261 -0
- package/lib/forms/InputAcceptUserTermsAndConditions.d.ts +7 -0
- package/lib/forms/InputAcceptUserTermsAndConditions.js +41 -0
- package/lib/forms/InputError.d.ts +8 -0
- package/lib/forms/InputError.js +24 -0
- package/lib/forms/InputSelect.d.ts +14 -0
- package/lib/forms/InputSelect.js +55 -0
- package/lib/forms/InputText.d.ts +12 -0
- package/lib/forms/InputText.js +63 -0
- package/lib/forms/InputsAddress.d.ts +11 -0
- package/lib/forms/InputsAddress.js +485 -0
- package/lib/forms/index.d.ts +8 -0
- package/lib/forms/index.js +63 -0
- package/lib/index.d.ts +13 -0
- package/lib/index.js +93 -0
- package/lib/modals.d.ts +17 -0
- package/lib/modals.js +59 -0
- package/lib/panels/PanelCartItems.d.ts +3 -0
- package/lib/panels/PanelCartItems.js +56 -0
- package/lib/panels/PanelCartShipment.d.ts +3 -0
- package/lib/panels/PanelCartShipment.js +72 -0
- package/lib/panels/PanelClearCart.d.ts +3 -0
- package/lib/panels/PanelClearCart.js +62 -0
- package/lib/panels/PanelClientCheckout.d.ts +3 -0
- package/lib/panels/PanelClientCheckout.js +88 -0
- package/lib/panels/PanelEditCartItem.d.ts +6 -0
- package/lib/panels/PanelEditCartItem.js +206 -0
- package/lib/panels/PanelPaymentSuccess.d.ts +3 -0
- package/lib/panels/PanelPaymentSuccess.js +69 -0
- package/lib/panels/index.d.ts +7 -0
- package/lib/panels/index.js +48 -0
- package/lib/square/SquareCard.d.ts +3 -0
- package/lib/square/SquareCard.js +114 -0
- package/lib/stripe/LegacyStripeCardForm.d.ts +3 -0
- package/lib/stripe/LegacyStripeCardForm.js +166 -0
- package/lib/stripe/StripeCardFields.d.ts +15 -0
- package/lib/stripe/StripeCardFields.js +135 -0
- package/lib/stripe/StripeCardForm.d.ts +2 -0
- package/lib/stripe/StripeCardForm.js +42 -0
- package/lib/stripe/StripePaymentButtons.d.ts +8 -0
- package/lib/stripe/StripePaymentButtons.js +106 -0
- package/lib/stripe/actions.d.ts +4 -0
- package/lib/stripe/actions.js +200 -0
- package/lib/stripe/utils.d.ts +18 -0
- package/lib/stripe/utils.js +27 -0
- package/lib/styles/globals.css +463 -0
- package/lib/styles/globals.css.map +1 -0
- package/lib/tabs/CartNav.d.ts +3 -0
- package/lib/tabs/CartNav.js +36 -0
- package/lib/tabs/NavTab.d.ts +9 -0
- package/lib/tabs/NavTab.js +39 -0
- package/lib/types/index.d.ts +13 -0
- package/lib/types/index.js +1 -0
- package/lib/utilities/address.d.ts +30 -0
- package/lib/utilities/address.js +468 -0
- package/lib/utilities/area.d.ts +77 -0
- package/lib/utilities/area.js +328 -0
- package/lib/utilities/cart.d.ts +9 -0
- package/lib/utilities/cart.js +108 -0
- package/lib/utilities/company.d.ts +2 -0
- package/lib/utilities/company.js +13 -0
- package/lib/utilities/cookie.d.ts +4 -0
- package/lib/utilities/cookie.js +165 -0
- package/lib/utilities/currency.d.ts +5 -0
- package/lib/utilities/currency.js +229 -0
- package/lib/utilities/customForm.d.ts +17 -0
- package/lib/utilities/customForm.js +64 -0
- package/lib/utilities/helpers.d.ts +24 -0
- package/lib/utilities/helpers.js +240 -0
- package/lib/utilities/index.d.ts +14 -0
- package/lib/utilities/index.js +159 -0
- package/lib/utilities/invoice.d.ts +3 -0
- package/lib/utilities/invoice.js +118 -0
- package/lib/utilities/job.d.ts +1 -0
- package/lib/utilities/job.js +15 -0
- package/lib/utilities/local_storage.d.ts +31 -0
- package/lib/utilities/local_storage.js +96 -0
- package/lib/utilities/product.d.ts +2 -0
- package/lib/utilities/product.js +21 -0
- package/lib/utilities/shipment.d.ts +2 -0
- package/lib/utilities/shipment.js +18 -0
- package/lib/utilities/tabs.d.ts +14 -0
- package/lib/utilities/tabs.js +60 -0
- package/lib/utilities/user.d.ts +5 -0
- package/lib/utilities/user.js +75 -0
- package/lib/utilities/variations.d.ts +18 -0
- package/lib/utilities/variations.js +66 -0
- package/package.json +109 -0
- package/src/Cart.tsx +96 -0
- package/src/CartAlert.tsx +35 -0
- package/src/CartHeader.tsx +28 -0
- package/src/CartProvider.tsx +992 -0
- package/src/CartTotals.tsx +102 -0
- package/src/assets/merchi-monster-loader.gif +0 -0
- package/src/assets/merchi-swipe-outline.png +0 -0
- package/src/assets/product-not-found.png +0 -0
- package/src/assets/stripe-payment-secure.png +0 -0
- package/src/buttons/Button.tsx +35 -0
- package/src/buttons/ButtonBack.tsx +42 -0
- package/src/buttons/ButtonClearCart.tsx +17 -0
- package/src/buttons/ButtonInvoiceDownload.tsx +60 -0
- package/src/buttons/ButtonNext.tsx +35 -0
- package/src/buttons/ButtonNextDynamic.tsx +31 -0
- package/src/buttons/ButtonOpenCartMerchiCartModal.tsx +61 -0
- package/src/buttons/ButtonPay.tsx +32 -0
- package/src/buttons/ButtonShipmentTabNext.tsx +24 -0
- package/src/buttons/index.ts +15 -0
- package/src/components/Alert.tsx +31 -0
- package/src/components/CartBody.tsx +16 -0
- package/src/components/CartClient.tsx +52 -0
- package/src/components/CartFooter.tsx +15 -0
- package/src/components/CartItemRow.tsx +212 -0
- package/src/components/CartPaymentSettingsInvalid.tsx +12 -0
- package/src/components/CartShipment.tsx +56 -0
- package/src/components/CartTabContent.tsx +15 -0
- package/src/components/CartTabPanel.tsx +25 -0
- package/src/components/CartTableContainer.tsx +15 -0
- package/src/components/CartTitle.tsx +22 -0
- package/src/components/CartTotalsListGroup.tsx +58 -0
- package/src/components/Collapse.tsx +23 -0
- package/src/components/CustomCartProductForm.tsx +123 -0
- package/src/components/CustomerCheckoutMethodTabs.tsx +106 -0
- package/src/components/DiscountInputGroup.tsx +160 -0
- package/src/components/LoadingTemplate.tsx +22 -0
- package/src/components/NoCartItems.tsx +20 -0
- package/src/components/ShipmentGroupCard.tsx +170 -0
- package/src/components/Table.tsx +15 -0
- package/src/components/containers.tsx +40 -0
- package/src/components/index.ts +38 -0
- package/src/components/product-form-sdk-externals.ts +67 -0
- package/src/forms/FormNewCustomer.tsx +170 -0
- package/src/forms/FormReturningCustomer.tsx +117 -0
- package/src/forms/FormShipmentAddressAndNotes.tsx +165 -0
- package/src/forms/FormSquarePayment.tsx +19 -0
- package/src/forms/FormStripePayment.tsx +19 -0
- package/src/forms/FormWhatsappCustomer.tsx +179 -0
- package/src/forms/InputAcceptUserTermsAndConditions.tsx +43 -0
- package/src/forms/InputError.tsx +23 -0
- package/src/forms/InputSelect.tsx +58 -0
- package/src/forms/InputText.tsx +56 -0
- package/src/forms/InputsAddress.tsx +438 -0
- package/src/forms/index.ts +18 -0
- package/src/index.ts +31 -0
- package/src/modals.tsx +65 -0
- package/src/panels/PanelCartItems.tsx +56 -0
- package/src/panels/PanelCartShipment.tsx +86 -0
- package/src/panels/PanelClearCart.tsx +50 -0
- package/src/panels/PanelClientCheckout.tsx +102 -0
- package/src/panels/PanelEditCartItem.tsx +172 -0
- package/src/panels/PanelPaymentSuccess.tsx +66 -0
- package/src/panels/index.ts +15 -0
- package/src/square/SquareCard.tsx +84 -0
- package/src/stripe/LegacyStripeCardForm.tsx +91 -0
- package/src/stripe/StripeCardFields.tsx +173 -0
- package/src/stripe/StripeCardForm.tsx +18 -0
- package/src/stripe/StripePaymentButtons.tsx +117 -0
- package/src/stripe/actions.ts +94 -0
- package/src/stripe/utils.ts +22 -0
- package/src/styles/globals.scss +475 -0
- package/src/tabs/CartNav.tsx +18 -0
- package/src/tabs/NavTab.tsx +36 -0
- package/src/types/assets.d.ts +4 -0
- package/src/types/index.ts +15 -0
- package/src/types/merchi_product_form/index.d.ts +1 -0
- package/src/types/merchi_sdk_ts/index.d.ts +1 -0
- package/src/types/react-redux/index.d.ts +0 -0
- package/src/utilities/address.ts +463 -0
- package/src/utilities/area.ts +359 -0
- package/src/utilities/cart.ts +80 -0
- package/src/utilities/company.ts +8 -0
- package/src/utilities/cookie.ts +58 -0
- package/src/utilities/currency.ts +216 -0
- package/src/utilities/customForm.ts +71 -0
- package/src/utilities/helpers.ts +213 -0
- package/src/utilities/index.ts +14 -0
- package/src/utilities/invoice.ts +60 -0
- package/src/utilities/job.ts +13 -0
- package/src/utilities/local_storage.ts +130 -0
- package/src/utilities/product.ts +14 -0
- package/src/utilities/shipment.ts +11 -0
- package/src/utilities/tabs.ts +38 -0
- package/src/utilities/user.ts +33 -0
- package/src/utilities/variations.ts +80 -0
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
export var currencyMap = {
|
|
2
|
+
ALL: 'L',
|
|
3
|
+
AFN: '؋',
|
|
4
|
+
ARS: '$',
|
|
5
|
+
AWG: 'ƒ',
|
|
6
|
+
AUD: '$',
|
|
7
|
+
AZN: '₼',
|
|
8
|
+
BSD: '$',
|
|
9
|
+
BBD: '$',
|
|
10
|
+
BYR: 'p.',
|
|
11
|
+
BZD: 'BZ$',
|
|
12
|
+
BMD: '$',
|
|
13
|
+
BOB: 'Bs.',
|
|
14
|
+
BAM: 'KM',
|
|
15
|
+
BWP: 'P',
|
|
16
|
+
BGN: 'лв',
|
|
17
|
+
BRL: 'R$',
|
|
18
|
+
BND: '$',
|
|
19
|
+
KHR: '៛',
|
|
20
|
+
CAD: '$',
|
|
21
|
+
KYD: '$',
|
|
22
|
+
CLP: '$',
|
|
23
|
+
CNY: '¥',
|
|
24
|
+
COP: '$',
|
|
25
|
+
CRC: '₡',
|
|
26
|
+
HRK: 'kn',
|
|
27
|
+
CUP: '₱',
|
|
28
|
+
CZK: 'Kč',
|
|
29
|
+
DKK: 'kr',
|
|
30
|
+
DOP: 'RD$',
|
|
31
|
+
XCD: '$',
|
|
32
|
+
EGP: '£',
|
|
33
|
+
SVC: '$',
|
|
34
|
+
EEK: 'kr',
|
|
35
|
+
EUR: '€',
|
|
36
|
+
FKP: '£',
|
|
37
|
+
FJD: '$',
|
|
38
|
+
GHC: '₵',
|
|
39
|
+
GIP: '£',
|
|
40
|
+
GTQ: 'Q',
|
|
41
|
+
GGP: '£',
|
|
42
|
+
GYD: '$',
|
|
43
|
+
HNL: 'L',
|
|
44
|
+
HKD: '$',
|
|
45
|
+
HUF: 'Ft',
|
|
46
|
+
ISK: 'kr',
|
|
47
|
+
INR: '₹',
|
|
48
|
+
IDR: 'Rp',
|
|
49
|
+
IRR: '﷼',
|
|
50
|
+
IMP: '£',
|
|
51
|
+
ILS: '₪',
|
|
52
|
+
JMD: '`J$',
|
|
53
|
+
JPY: '¥',
|
|
54
|
+
JEP: '£',
|
|
55
|
+
KES: 'KSh',
|
|
56
|
+
KZT: 'лв',
|
|
57
|
+
KPW: '₩',
|
|
58
|
+
KRW: '₩',
|
|
59
|
+
KGS: 'лв',
|
|
60
|
+
LAK: '₭',
|
|
61
|
+
LVL: 'Ls',
|
|
62
|
+
LBP: '£',
|
|
63
|
+
LRD: '$',
|
|
64
|
+
LTL: 'Lt',
|
|
65
|
+
MKD: 'ден',
|
|
66
|
+
MYR: 'RM',
|
|
67
|
+
MUR: '₨',
|
|
68
|
+
MXN: '$',
|
|
69
|
+
MNT: '₮',
|
|
70
|
+
MZN: 'MT',
|
|
71
|
+
NAD: '$',
|
|
72
|
+
NPR: '₨',
|
|
73
|
+
ANG: 'ƒ',
|
|
74
|
+
NZD: '$',
|
|
75
|
+
NIO: 'C$',
|
|
76
|
+
NGN: '₦',
|
|
77
|
+
NOK: 'kr',
|
|
78
|
+
OMR: '﷼',
|
|
79
|
+
PKR: '₨',
|
|
80
|
+
PAB: 'B/.',
|
|
81
|
+
PYG: 'Gs',
|
|
82
|
+
PEN: 'S/.',
|
|
83
|
+
PHP: '₱',
|
|
84
|
+
PLN: 'zł',
|
|
85
|
+
QAR: '﷼',
|
|
86
|
+
RON: 'lei',
|
|
87
|
+
RUB: '₽',
|
|
88
|
+
RMB: '¥',
|
|
89
|
+
SHP: '£',
|
|
90
|
+
SAR: '﷼',
|
|
91
|
+
RSD: 'Дин.',
|
|
92
|
+
SCR: '₨',
|
|
93
|
+
SGD: '$',
|
|
94
|
+
SBD: '$',
|
|
95
|
+
SOS: 'S',
|
|
96
|
+
ZAR: 'R',
|
|
97
|
+
LKR: '₨',
|
|
98
|
+
SEK: 'kr',
|
|
99
|
+
CHF: 'CHF',
|
|
100
|
+
SRD: '$',
|
|
101
|
+
SYP: '£',
|
|
102
|
+
TZS: 'TSh',
|
|
103
|
+
TWD: 'NT$',
|
|
104
|
+
THB: '฿',
|
|
105
|
+
TTD: 'TT$',
|
|
106
|
+
TRY: '₺',
|
|
107
|
+
TRL: '₤',
|
|
108
|
+
TVD: '$',
|
|
109
|
+
UGX: 'USh',
|
|
110
|
+
UAH: '₴',
|
|
111
|
+
GBP: '£',
|
|
112
|
+
USD: '$',
|
|
113
|
+
UYU: '$U',
|
|
114
|
+
UZS: 'лв',
|
|
115
|
+
VEF: 'Bs',
|
|
116
|
+
VND: '₫',
|
|
117
|
+
YER: '﷼',
|
|
118
|
+
ZWD: 'Z$'
|
|
119
|
+
};
|
|
120
|
+
export function formatCurrency(amount, options) {
|
|
121
|
+
/*
|
|
122
|
+
* Example usage:
|
|
123
|
+
formatCurrency(-222.123456, {currency: 'EGP',
|
|
124
|
+
showCodeIfNoSymbol: true,
|
|
125
|
+
financialNegative: true,
|
|
126
|
+
decimalPlaces: 3})
|
|
127
|
+
--> '(£222.123)'
|
|
128
|
+
*/
|
|
129
|
+
|
|
130
|
+
var symbol;
|
|
131
|
+
var negative = false;
|
|
132
|
+
var result;
|
|
133
|
+
options = options || {};
|
|
134
|
+
options.currency = options.currency || 'AUD';
|
|
135
|
+
options.showCodeIfNoSymbol = options.showCodeIfNoSymbol || true;
|
|
136
|
+
options.symbolAfterAmount = options.symbolAfterAmount || false;
|
|
137
|
+
options.financialNegative = options.financialNegative || false;
|
|
138
|
+
options.codeAfterSymbol = options.codeAfterSymbol || false;
|
|
139
|
+
options.codeBeforeSymbol = options.codeBeforeSymbol || false;
|
|
140
|
+
options.spaceBetweenSymbol = options.spaceBetweenSymbol || false;
|
|
141
|
+
options.decimalPlaces = options.decimalPlaces || 2;
|
|
142
|
+
options.decimalSeperator = options.decimalSeperator || '.';
|
|
143
|
+
options.codeAfterAmount = options.codeAfterAmount || false;
|
|
144
|
+
if (amount < 0.0) {
|
|
145
|
+
negative = true;
|
|
146
|
+
amount *= -1.0; // eslint-disable-line
|
|
147
|
+
}
|
|
148
|
+
if (Object.prototype.hasOwnProperty.call(currencyMap, options.currency)) {
|
|
149
|
+
symbol = currencyMap[options.currency];
|
|
150
|
+
if (options.codeAfterSymbol) {
|
|
151
|
+
symbol += '(' + options.currency + ') ';
|
|
152
|
+
}
|
|
153
|
+
if (options.codeBeforeSymbol) {
|
|
154
|
+
symbol = "(".concat(options.currency, ") ").concat(symbol);
|
|
155
|
+
}
|
|
156
|
+
} else if (options.showCodeIfNoSymbol) {
|
|
157
|
+
symbol = options.currency;
|
|
158
|
+
} else {
|
|
159
|
+
symbol = '';
|
|
160
|
+
}
|
|
161
|
+
amount = amount.toFixed(options.decimalPlaces);
|
|
162
|
+
amount = amount.replace('.', options.decimalSeperator);
|
|
163
|
+
if (options.symbolAfterAmount) {
|
|
164
|
+
result = amount;
|
|
165
|
+
if (options.spaceBetweenSymbol) {
|
|
166
|
+
result += ' ';
|
|
167
|
+
}
|
|
168
|
+
result += symbol;
|
|
169
|
+
} else {
|
|
170
|
+
result = symbol;
|
|
171
|
+
if (options.spaceBetweenSymbol) {
|
|
172
|
+
result += ' ';
|
|
173
|
+
}
|
|
174
|
+
result += amount;
|
|
175
|
+
}
|
|
176
|
+
if (negative) {
|
|
177
|
+
if (options.financialNegative) {
|
|
178
|
+
result = "(".concat(result, ")");
|
|
179
|
+
} else {
|
|
180
|
+
result = "-".concat(result);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
if (options.codeAfterAmount === true) {
|
|
184
|
+
result += " (".concat(options.currency, ")");
|
|
185
|
+
}
|
|
186
|
+
return result;
|
|
187
|
+
}
|
|
188
|
+
function formatCountryTax(countryTax) {
|
|
189
|
+
var taxName = countryTax.taxName,
|
|
190
|
+
taxPercent = countryTax.taxPercent;
|
|
191
|
+
return taxPercent > 0 ? " inc ".concat(taxName, " (").concat(taxPercent, "%)") : '';
|
|
192
|
+
}
|
|
193
|
+
export function calculateTotalWithTax(total, tax) {
|
|
194
|
+
var taxMultiplier = 1.0;
|
|
195
|
+
if (tax && tax.taxPercent() > 0) {
|
|
196
|
+
taxMultiplier += tax.taxPercent() / 100;
|
|
197
|
+
taxMultiplier = parseFloat(taxMultiplier.toFixed(2));
|
|
198
|
+
}
|
|
199
|
+
var grandTotal = total * taxMultiplier;
|
|
200
|
+
return parseFloat(grandTotal.toFixed(2));
|
|
201
|
+
}
|
|
202
|
+
export function cartItemCurrencyAndCost(cartItem) {
|
|
203
|
+
var currency = cartItem.currency,
|
|
204
|
+
totalCost = cartItem.totalCost,
|
|
205
|
+
taxType = cartItem.taxType;
|
|
206
|
+
var tax = taxType ? formatCountryTax(taxType) : '';
|
|
207
|
+
return "".concat(currency, " ").concat(formatCurrency(totalCost, {
|
|
208
|
+
currency: currency,
|
|
209
|
+
showCodeIfNoSymbol: false
|
|
210
|
+
}), " ").concat(tax);
|
|
211
|
+
}
|
|
212
|
+
export function currencyTaxAndCost(currency, tax, theCost) {
|
|
213
|
+
var totalCost = calculateTotalWithTax(theCost, tax);
|
|
214
|
+
var _tax = tax ? formatCountryTax(tax) : '';
|
|
215
|
+
return "".concat(currency, " ").concat(formatCurrency(totalCost, {
|
|
216
|
+
currency: currency,
|
|
217
|
+
showCodeIfNoSymbol: false
|
|
218
|
+
}), " ").concat(_tax);
|
|
219
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpers for loading a product's published custom form bundle in cart edit.
|
|
3
|
+
* Mirrors the product-embed loader: SRI script tag → window.MERCHI_PRODUCT_FORM_<id>.
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/** If the product has a published custom form with a compiled bundle, return
|
|
7
|
+
* the info needed to load it; otherwise null (caller falls back). */
|
|
8
|
+
export function publishedFormBundle(product) {
|
|
9
|
+
var form = product === null || product === void 0 ? void 0 : product.productForm;
|
|
10
|
+
if (!form || form.status !== 'published') return null;
|
|
11
|
+
var version = form.activeVersion;
|
|
12
|
+
if (!version || !version.compiledBundleUrl) return null;
|
|
13
|
+
return {
|
|
14
|
+
url: version.compiledBundleUrl,
|
|
15
|
+
integrity: version.bundleSha || undefined,
|
|
16
|
+
globalName: "MERCHI_PRODUCT_FORM_".concat(form.id)
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Dynamically load a compiled form bundle and resolve its default export. */
|
|
21
|
+
export function loadFormBundle(bundle) {
|
|
22
|
+
var opts = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
23
|
+
var url = bundle.url,
|
|
24
|
+
integrity = bundle.integrity,
|
|
25
|
+
globalName = bundle.globalName;
|
|
26
|
+
var timeoutMs = opts.timeoutMs || 15000;
|
|
27
|
+
var w = window;
|
|
28
|
+
var existing = w[globalName] && w[globalName]["default"];
|
|
29
|
+
if (existing) return Promise.resolve(existing);
|
|
30
|
+
return new Promise(function (resolve, reject) {
|
|
31
|
+
var settled = false;
|
|
32
|
+
var finish = function finish(fn, arg) {
|
|
33
|
+
if (settled) return;
|
|
34
|
+
settled = true;
|
|
35
|
+
clearTimeout(timer);
|
|
36
|
+
fn(arg);
|
|
37
|
+
};
|
|
38
|
+
var timer = setTimeout(function () {
|
|
39
|
+
return finish(reject, new Error("form bundle ".concat(globalName, " timed out")));
|
|
40
|
+
}, timeoutMs);
|
|
41
|
+
var script = document.createElement('script');
|
|
42
|
+
script.src = url;
|
|
43
|
+
if (integrity) script.integrity = integrity;
|
|
44
|
+
script.crossOrigin = 'anonymous';
|
|
45
|
+
script.async = true;
|
|
46
|
+
script.onload = function () {
|
|
47
|
+
var mod = w[globalName];
|
|
48
|
+
if (mod && mod["default"]) finish(resolve, mod["default"]);else {
|
|
49
|
+
finish(reject, new Error("form bundle ".concat(globalName, " did not register a default export")));
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
script.onerror = function () {
|
|
53
|
+
return finish(reject, new Error("failed to load form bundle ".concat(globalName)));
|
|
54
|
+
};
|
|
55
|
+
document.head.appendChild(script);
|
|
56
|
+
});
|
|
57
|
+
}
|
|
@@ -0,0 +1,229 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t["return"] || t["return"](); } finally { if (u) throw o; } } }; }
|
|
2
|
+
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
3
|
+
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
4
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
5
|
+
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
6
|
+
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
7
|
+
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
|
+
import camelCase from 'lodash/camelCase';
|
|
9
|
+
import snakeCase from 'lodash/snakeCase';
|
|
10
|
+
var TransformationType = /*#__PURE__*/function (TransformationType) {
|
|
11
|
+
TransformationType["CAMEL"] = "camel";
|
|
12
|
+
TransformationType["UNDERSCORE"] = "underscore";
|
|
13
|
+
return TransformationType;
|
|
14
|
+
}(TransformationType || {});
|
|
15
|
+
var functionDict = _defineProperty(_defineProperty({}, TransformationType.CAMEL, camelCase), TransformationType.UNDERSCORE, snakeCase);
|
|
16
|
+
function parseJsonKeyNames(jsonObject, standard) {
|
|
17
|
+
if (_typeof(jsonObject) === 'object' && jsonObject !== null) {
|
|
18
|
+
if (Array.isArray(jsonObject)) {
|
|
19
|
+
var _iterator = _createForOfIteratorHelper(jsonObject),
|
|
20
|
+
_step;
|
|
21
|
+
try {
|
|
22
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
23
|
+
var item = _step.value;
|
|
24
|
+
parseJsonKeyNames(item, standard);
|
|
25
|
+
}
|
|
26
|
+
} catch (err) {
|
|
27
|
+
_iterator.e(err);
|
|
28
|
+
} finally {
|
|
29
|
+
_iterator.f();
|
|
30
|
+
}
|
|
31
|
+
} else {
|
|
32
|
+
var oldKeys = Object.keys(jsonObject);
|
|
33
|
+
for (var _i = 0, _oldKeys = oldKeys; _i < _oldKeys.length; _i++) {
|
|
34
|
+
var old = _oldKeys[_i];
|
|
35
|
+
var newKey = functionDict[standard](old);
|
|
36
|
+
if (newKey !== old) {
|
|
37
|
+
jsonObject[newKey] = jsonObject[old];
|
|
38
|
+
delete jsonObject[old];
|
|
39
|
+
parseJsonKeyNames(jsonObject[newKey], standard);
|
|
40
|
+
} else {
|
|
41
|
+
parseJsonKeyNames(jsonObject[old], standard);
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
return jsonObject;
|
|
47
|
+
}
|
|
48
|
+
function parseJsonKeyCamel(jsonObject) {
|
|
49
|
+
return parseJsonKeyNames(jsonObject, TransformationType.CAMEL);
|
|
50
|
+
}
|
|
51
|
+
export function unpackRecursiveJsonIter(jsonObject, options, fileIndex) {
|
|
52
|
+
if (!options) options = {};
|
|
53
|
+
var result = options.existing || new FormData();
|
|
54
|
+
var prefix = options._prefix || '';
|
|
55
|
+
if (!fileIndex) fileIndex = {
|
|
56
|
+
value: 0
|
|
57
|
+
};
|
|
58
|
+
var appendData = function appendData(name, value) {
|
|
59
|
+
if (prefix) {
|
|
60
|
+
name = prefix + '-' + name;
|
|
61
|
+
}
|
|
62
|
+
if (value !== undefined && value !== null) {
|
|
63
|
+
result.set(name, value.toString()); // Convert to string since FormData accepts only strings or Blobs.
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
var processSingleEntityProperty = function processSingleEntityProperty(key, value) {
|
|
67
|
+
var innerPrefix = key + '-0';
|
|
68
|
+
if (prefix) {
|
|
69
|
+
innerPrefix = prefix + '-' + innerPrefix;
|
|
70
|
+
}
|
|
71
|
+
unpackRecursiveJsonIter(value, {
|
|
72
|
+
existing: result,
|
|
73
|
+
_prefix: innerPrefix
|
|
74
|
+
}, fileIndex);
|
|
75
|
+
appendData(key + '-count', '1');
|
|
76
|
+
};
|
|
77
|
+
var _loop = function _loop(_key) {
|
|
78
|
+
if ([undefined, '', null].includes(jsonObject[_key]) || _key === 'rights') {
|
|
79
|
+
return 1; // continue
|
|
80
|
+
}
|
|
81
|
+
if (Array.isArray(jsonObject[_key])) {
|
|
82
|
+
jsonObject[_key].forEach(function (item, index) {
|
|
83
|
+
if ((_typeof(item) === "object" || Array.isArray(item)) && item !== null) {
|
|
84
|
+
var arrayPrefix = prefix ? "".concat(prefix, "-").concat(_key, "-").concat(index) : "".concat(_key, "-").concat(index);
|
|
85
|
+
unpackRecursiveJsonIter(item, {
|
|
86
|
+
existing: result,
|
|
87
|
+
_prefix: arrayPrefix
|
|
88
|
+
}, fileIndex);
|
|
89
|
+
} else {
|
|
90
|
+
appendData("".concat(_key, "-").concat(index), item);
|
|
91
|
+
}
|
|
92
|
+
});
|
|
93
|
+
appendData(_key + '-count', jsonObject[_key].length.toString());
|
|
94
|
+
} else if (_typeof(jsonObject[_key]) === "object" && jsonObject[_key] !== null) {
|
|
95
|
+
processSingleEntityProperty(_key, jsonObject[_key]);
|
|
96
|
+
} else {
|
|
97
|
+
appendData(_key, jsonObject[_key]);
|
|
98
|
+
}
|
|
99
|
+
};
|
|
100
|
+
for (var _key in jsonObject) {
|
|
101
|
+
if (_loop(_key)) continue;
|
|
102
|
+
}
|
|
103
|
+
return result;
|
|
104
|
+
}
|
|
105
|
+
export function encodeMerchiApiData(dataDict) {
|
|
106
|
+
var dataJson = parseJsonKeyCamel(dataDict);
|
|
107
|
+
return unpackRecursiveJsonIter(dataJson);
|
|
108
|
+
}
|
|
109
|
+
var supportedNumbers = {
|
|
110
|
+
AU: 'Australia (+61)',
|
|
111
|
+
AE: 'United Arab Emirates (+971)',
|
|
112
|
+
BH: 'Bahrain (+973)',
|
|
113
|
+
CN: 'China (+86)',
|
|
114
|
+
DK: 'Denmark (+45)',
|
|
115
|
+
ES: 'Spain (+34)',
|
|
116
|
+
FR: 'France (+33)',
|
|
117
|
+
GB: 'United Kingdom (+44)',
|
|
118
|
+
HK: 'Hong Kong (+852)',
|
|
119
|
+
ID: 'Indonesia (+62)',
|
|
120
|
+
IN: 'India (+91)',
|
|
121
|
+
IT: 'Italy (+39)',
|
|
122
|
+
KR: 'South Korea (+82)',
|
|
123
|
+
NC: 'New Caledonia (+687)',
|
|
124
|
+
NZ: 'New Zealand (+64)',
|
|
125
|
+
OM: 'Oman (+968)',
|
|
126
|
+
PH: 'Philippines (+63)',
|
|
127
|
+
PT: 'Portugal (+351)',
|
|
128
|
+
QA: 'Qatar (+974)',
|
|
129
|
+
SE: 'Sweden (+46)',
|
|
130
|
+
SG: 'Singapore (+65)',
|
|
131
|
+
TH: 'Thailand (+66)',
|
|
132
|
+
US: 'United States (+1)',
|
|
133
|
+
ZA: 'South Africa (+27)'
|
|
134
|
+
};
|
|
135
|
+
export var phoneOptions = Object.keys(supportedNumbers).map(function (key) {
|
|
136
|
+
return {
|
|
137
|
+
value: key,
|
|
138
|
+
label: supportedNumbers[key]
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
export function appendStyleSheetText(css, callback) {
|
|
142
|
+
if (document && document !== undefined) {
|
|
143
|
+
var newStyleSheet = document.createElement('style');
|
|
144
|
+
newStyleSheet.textContent = css;
|
|
145
|
+
if (callback) {
|
|
146
|
+
newStyleSheet.onload = callback;
|
|
147
|
+
}
|
|
148
|
+
document.head.appendChild(newStyleSheet);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
var optionsEmbed = {
|
|
152
|
+
options: {
|
|
153
|
+
linkedFile: {},
|
|
154
|
+
variationCostDiscountGroup: {},
|
|
155
|
+
variationUnitCostDiscountGroup: {}
|
|
156
|
+
},
|
|
157
|
+
variationCostDiscountGroup: {},
|
|
158
|
+
variationUnitCostDiscountGroup: {}
|
|
159
|
+
};
|
|
160
|
+
var variationsEmbed = {
|
|
161
|
+
selectedOptions: {},
|
|
162
|
+
variationField: optionsEmbed,
|
|
163
|
+
variationFiles: {}
|
|
164
|
+
};
|
|
165
|
+
var variationsGroupsEmbed = {
|
|
166
|
+
variations: variationsEmbed
|
|
167
|
+
};
|
|
168
|
+
var productWithImagesEmbed = {
|
|
169
|
+
domain: {
|
|
170
|
+
company: {
|
|
171
|
+
defaultTaxType: {},
|
|
172
|
+
taxTypes: {}
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
featureImage: {},
|
|
176
|
+
groupVariationFields: {
|
|
177
|
+
options: {
|
|
178
|
+
linkedFile: {}
|
|
179
|
+
}
|
|
180
|
+
},
|
|
181
|
+
images: {},
|
|
182
|
+
independentVariationFields: {
|
|
183
|
+
options: {
|
|
184
|
+
linkedFile: {}
|
|
185
|
+
}
|
|
186
|
+
},
|
|
187
|
+
// Published custom form pointer for cart-item edit (same shape as product embed).
|
|
188
|
+
productForm: {
|
|
189
|
+
activeVersion: {}
|
|
190
|
+
},
|
|
191
|
+
taxType: {}
|
|
192
|
+
};
|
|
193
|
+
var cartShipmentQuote = {
|
|
194
|
+
shipmentMethod: {
|
|
195
|
+
originAddress: {},
|
|
196
|
+
taxType: {}
|
|
197
|
+
}
|
|
198
|
+
};
|
|
199
|
+
export var cartEmbed = {
|
|
200
|
+
cartItems: {
|
|
201
|
+
product: productWithImagesEmbed,
|
|
202
|
+
taxType: {},
|
|
203
|
+
variations: variationsEmbed,
|
|
204
|
+
variationsGroups: variationsGroupsEmbed
|
|
205
|
+
},
|
|
206
|
+
client: {
|
|
207
|
+
emailAddresses: {},
|
|
208
|
+
phoneNumbers: {},
|
|
209
|
+
profilePicture: {}
|
|
210
|
+
},
|
|
211
|
+
clientCompany: {},
|
|
212
|
+
discountItems: {},
|
|
213
|
+
domain: {
|
|
214
|
+
company: {
|
|
215
|
+
defaultTaxType: {},
|
|
216
|
+
isStripeAccountEnabled: {},
|
|
217
|
+
taxTypes: {}
|
|
218
|
+
}
|
|
219
|
+
},
|
|
220
|
+
invoice: {},
|
|
221
|
+
receiverAddress: {},
|
|
222
|
+
shipmentGroups: {
|
|
223
|
+
cartItems: {
|
|
224
|
+
product: {}
|
|
225
|
+
},
|
|
226
|
+
quotes: cartShipmentQuote,
|
|
227
|
+
selectedQuote: cartShipmentQuote
|
|
228
|
+
}
|
|
229
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './address';
|
|
2
|
+
export * from './cart';
|
|
3
|
+
export * from './company';
|
|
4
|
+
export * from './cookie';
|
|
5
|
+
export * from './currency';
|
|
6
|
+
export * from './helpers';
|
|
7
|
+
export * from './invoice';
|
|
8
|
+
export * from './job';
|
|
9
|
+
export * from './local_storage';
|
|
10
|
+
export * from './product';
|
|
11
|
+
export * from './shipment';
|
|
12
|
+
export * from './tabs';
|
|
13
|
+
export * from './user';
|
|
14
|
+
export * from './variations';
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i["return"]) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
|
|
2
|
+
function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
|
|
3
|
+
function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
|
|
4
|
+
function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
|
|
5
|
+
var urlToFile = /*#__PURE__*/function () {
|
|
6
|
+
var _ref = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(url, filename, type) {
|
|
7
|
+
var res, buf;
|
|
8
|
+
return _regenerator().w(function (_context) {
|
|
9
|
+
while (1) switch (_context.n) {
|
|
10
|
+
case 0:
|
|
11
|
+
_context.n = 1;
|
|
12
|
+
return fetch(url);
|
|
13
|
+
case 1:
|
|
14
|
+
res = _context.v;
|
|
15
|
+
_context.n = 2;
|
|
16
|
+
return res.arrayBuffer();
|
|
17
|
+
case 2:
|
|
18
|
+
buf = _context.v;
|
|
19
|
+
return _context.a(2, new File([buf], filename, {
|
|
20
|
+
type: type
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
}, _callee);
|
|
24
|
+
}));
|
|
25
|
+
return function urlToFile(_x, _x2, _x3) {
|
|
26
|
+
return _ref.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
}();
|
|
29
|
+
var urlToFilePdf = /*#__PURE__*/function () {
|
|
30
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(url, filename) {
|
|
31
|
+
var file;
|
|
32
|
+
return _regenerator().w(function (_context2) {
|
|
33
|
+
while (1) switch (_context2.n) {
|
|
34
|
+
case 0:
|
|
35
|
+
_context2.n = 1;
|
|
36
|
+
return urlToFile(url, filename, 'application/pdf');
|
|
37
|
+
case 1:
|
|
38
|
+
file = _context2.v;
|
|
39
|
+
return _context2.a(2, file);
|
|
40
|
+
}
|
|
41
|
+
}, _callee2);
|
|
42
|
+
}));
|
|
43
|
+
return function urlToFilePdf(_x4, _x5) {
|
|
44
|
+
return _ref2.apply(this, arguments);
|
|
45
|
+
};
|
|
46
|
+
}();
|
|
47
|
+
export function generatePublicInvoicePdf(_x6, _x7, _x8) {
|
|
48
|
+
return _generatePublicInvoicePdf.apply(this, arguments);
|
|
49
|
+
}
|
|
50
|
+
function _generatePublicInvoicePdf() {
|
|
51
|
+
_generatePublicInvoicePdf = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3(apiUrl, invoice, receipt) {
|
|
52
|
+
var id, domain, queryString, fetchOptions, uri, response, r, pdf, url, doc, anchor, _t;
|
|
53
|
+
return _regenerator().w(function (_context3) {
|
|
54
|
+
while (1) switch (_context3.p = _context3.n) {
|
|
55
|
+
case 0:
|
|
56
|
+
id = invoice.id;
|
|
57
|
+
domain = invoice.domain.emailDomain;
|
|
58
|
+
queryString = new URLSearchParams({
|
|
59
|
+
invoice_token: invoice.invoiceToken
|
|
60
|
+
}).toString();
|
|
61
|
+
fetchOptions = {
|
|
62
|
+
method: 'GET',
|
|
63
|
+
mode: 'cors'
|
|
64
|
+
};
|
|
65
|
+
uri = receipt ? '/generate/receipt/pdf/' : '/generate/pdf/';
|
|
66
|
+
_context3.p = 1;
|
|
67
|
+
_context3.n = 2;
|
|
68
|
+
return fetch("".concat(apiUrl, "invoices/").concat(id).concat(uri, "?").concat(queryString), fetchOptions);
|
|
69
|
+
case 2:
|
|
70
|
+
response = _context3.v;
|
|
71
|
+
if (response.ok) {
|
|
72
|
+
_context3.n = 3;
|
|
73
|
+
break;
|
|
74
|
+
}
|
|
75
|
+
throw new Error("Error fetching PDF.");
|
|
76
|
+
case 3:
|
|
77
|
+
_context3.n = 4;
|
|
78
|
+
return response.json();
|
|
79
|
+
case 4:
|
|
80
|
+
r = _context3.v;
|
|
81
|
+
_context3.n = 5;
|
|
82
|
+
return urlToFilePdf("data:application/pdf;base64,".concat(r.pdf), "".concat(domain, "-invoice-").concat(id, ".pdf"));
|
|
83
|
+
case 5:
|
|
84
|
+
pdf = _context3.v;
|
|
85
|
+
url = URL.createObjectURL(pdf);
|
|
86
|
+
doc = document;
|
|
87
|
+
anchor = doc.createElement('a');
|
|
88
|
+
anchor.href = url;
|
|
89
|
+
anchor.download = pdf.name;
|
|
90
|
+
|
|
91
|
+
// Append to the DOM
|
|
92
|
+
doc.body.appendChild(anchor);
|
|
93
|
+
|
|
94
|
+
// Trigger `click` event
|
|
95
|
+
anchor.click();
|
|
96
|
+
|
|
97
|
+
// Remove element from DOM
|
|
98
|
+
doc.body.removeChild(anchor);
|
|
99
|
+
return _context3.a(2, {
|
|
100
|
+
success: true
|
|
101
|
+
});
|
|
102
|
+
case 6:
|
|
103
|
+
_context3.p = 6;
|
|
104
|
+
_t = _context3.v;
|
|
105
|
+
throw _t;
|
|
106
|
+
case 7:
|
|
107
|
+
return _context3.a(2);
|
|
108
|
+
}
|
|
109
|
+
}, _callee3, null, [[1, 6]]);
|
|
110
|
+
}));
|
|
111
|
+
return _generatePublicInvoicePdf.apply(this, arguments);
|
|
112
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Merchi } from '@merchi/sdk';
|
|
2
|
+
export function makeJob(jobJson, makeDirty, arrayValueStrict) {
|
|
3
|
+
var merchi = new Merchi();
|
|
4
|
+
var job = new merchi.Job();
|
|
5
|
+
return job.fromJson(jobJson, {
|
|
6
|
+
makeDirty: !!makeDirty,
|
|
7
|
+
arrayValueStrict: !!arrayValueStrict
|
|
8
|
+
});
|
|
9
|
+
}
|