@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
package/src/modals.tsx
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { CartComponents } from './Cart';
|
|
2
|
+
import { Modal } from 'reactstrap';
|
|
3
|
+
import { ButtonListWrappedOpenCart } from './buttons/ButtonOpenCartMerchiCartModal';
|
|
4
|
+
import CartProvider, { PropsCart, useCartContext } from './CartProvider';
|
|
5
|
+
|
|
6
|
+
interface Props extends PropsCart {
|
|
7
|
+
cartButtonWrappedInContainer?: boolean;
|
|
8
|
+
cartIconButtonClass?: string;
|
|
9
|
+
currentUser?: any;
|
|
10
|
+
customSuccessMessage?: string;
|
|
11
|
+
domainId?: number;
|
|
12
|
+
listContainerClass?: string;
|
|
13
|
+
listItemClass?: string;
|
|
14
|
+
showOpenCartButton?: boolean;
|
|
15
|
+
size?: string;
|
|
16
|
+
storeId?: number;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function CartModal(props: Props) {
|
|
20
|
+
const { isCartModalOpen, toggleCartModal } = useCartContext();
|
|
21
|
+
const {
|
|
22
|
+
cartButtonWrappedInContainer = true,
|
|
23
|
+
footer,
|
|
24
|
+
listContainerClass,
|
|
25
|
+
listItemClass,
|
|
26
|
+
showOpenCartButton = true,
|
|
27
|
+
size = 'xl',
|
|
28
|
+
} = props;
|
|
29
|
+
return (
|
|
30
|
+
<>
|
|
31
|
+
{showOpenCartButton && (
|
|
32
|
+
<ButtonListWrappedOpenCart
|
|
33
|
+
cartButtonWrappedInContainer={cartButtonWrappedInContainer}
|
|
34
|
+
listContainerClass={listContainerClass}
|
|
35
|
+
listItemClass={listItemClass}
|
|
36
|
+
/>
|
|
37
|
+
)}
|
|
38
|
+
<Modal
|
|
39
|
+
size={size}
|
|
40
|
+
className='m-auto'
|
|
41
|
+
isOpen={isCartModalOpen}
|
|
42
|
+
toggle={toggleCartModal}
|
|
43
|
+
>
|
|
44
|
+
<CartComponents
|
|
45
|
+
footer={footer}
|
|
46
|
+
/>
|
|
47
|
+
</Modal>
|
|
48
|
+
</>
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export function MerchiCartModal(props: Props) {
|
|
53
|
+
return (
|
|
54
|
+
<CartProvider {...props}>
|
|
55
|
+
<CartModal {...props} />
|
|
56
|
+
</CartProvider>
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export function MerchiShoppingCartModal(props: Props) {
|
|
61
|
+
const { storeId } = props;
|
|
62
|
+
return (
|
|
63
|
+
<MerchiCartModal {...props} domainId={storeId} />
|
|
64
|
+
);
|
|
65
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import CartItemRow from '../components/CartItemRow'
|
|
2
|
+
import { tabIdItems } from '../utilities/tabs';
|
|
3
|
+
import {
|
|
4
|
+
CartTableContainer,
|
|
5
|
+
CartTabPanel,
|
|
6
|
+
NoCartItems,
|
|
7
|
+
Table,
|
|
8
|
+
} from '../components';
|
|
9
|
+
import { useCartContext } from '../CartProvider';
|
|
10
|
+
|
|
11
|
+
function PanelCartItems() {
|
|
12
|
+
const { cart } = useCartContext();
|
|
13
|
+
const cartItems = cart.cartItems ? cart.cartItems : [];
|
|
14
|
+
const hasItems = cartItems.length > 0;
|
|
15
|
+
return (
|
|
16
|
+
<CartTabPanel tabId={tabIdItems}>
|
|
17
|
+
<div>
|
|
18
|
+
{hasItems ? (
|
|
19
|
+
<CartTableContainer>
|
|
20
|
+
<Table>
|
|
21
|
+
<thead>
|
|
22
|
+
<tr>
|
|
23
|
+
<th scope='col' className='merchi-cart-item-table-head'>
|
|
24
|
+
Product
|
|
25
|
+
</th>
|
|
26
|
+
<th scope='col' className='merchi-cart-item-table-head-right'>
|
|
27
|
+
Quantity
|
|
28
|
+
</th>
|
|
29
|
+
<th scope='col' className='merchi-cart-item-table-head-right'>
|
|
30
|
+
Price
|
|
31
|
+
</th>
|
|
32
|
+
<th scope='col' className='merchi-cart-item-table-head-right'>
|
|
33
|
+
Actions
|
|
34
|
+
</th>
|
|
35
|
+
</tr>
|
|
36
|
+
</thead>
|
|
37
|
+
<tbody>
|
|
38
|
+
{cartItems.map((cartItem: any, index: number) =>
|
|
39
|
+
<CartItemRow
|
|
40
|
+
key={cartItem.id}
|
|
41
|
+
cartItem={cartItem}
|
|
42
|
+
index={index}
|
|
43
|
+
/>)
|
|
44
|
+
}
|
|
45
|
+
</tbody>
|
|
46
|
+
</Table>
|
|
47
|
+
</CartTableContainer>
|
|
48
|
+
) : (
|
|
49
|
+
<NoCartItems />
|
|
50
|
+
)}
|
|
51
|
+
</div>
|
|
52
|
+
</CartTabPanel>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default PanelCartItems;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { faTruck } from '@fortawesome/free-solid-svg-icons';
|
|
2
|
+
import { ActiveFormShipmentAddressAndNotes } from '../forms/FormShipmentAddressAndNotes';
|
|
3
|
+
import {
|
|
4
|
+
CheckoutContainer,
|
|
5
|
+
InnerContainer,
|
|
6
|
+
} from '../components/containers';
|
|
7
|
+
import {
|
|
8
|
+
Alert,
|
|
9
|
+
CartBody,
|
|
10
|
+
CartTabPanel,
|
|
11
|
+
LoadingTemplateSm,
|
|
12
|
+
ShipmentGroupCard,
|
|
13
|
+
Title,
|
|
14
|
+
} from '../components';
|
|
15
|
+
import { tabIdShipment } from '../utilities/tabs';
|
|
16
|
+
import { useCartContext } from '../CartProvider';
|
|
17
|
+
|
|
18
|
+
function PanelCartShipment() {
|
|
19
|
+
const {
|
|
20
|
+
cart,
|
|
21
|
+
fetchingShipmentGroups,
|
|
22
|
+
} = useCartContext();
|
|
23
|
+
const { shipmentGroups = [] } = cart;
|
|
24
|
+
return (
|
|
25
|
+
<CartTabPanel tabId={tabIdShipment}>
|
|
26
|
+
<CartBody style={{ paddingTop: '2rem' }}>
|
|
27
|
+
<div className='merchi-cart-tab-content'>
|
|
28
|
+
<CheckoutContainer textAlign='left'>
|
|
29
|
+
<InnerContainer width={700} paddingBottom='3rem'>
|
|
30
|
+
<ActiveFormShipmentAddressAndNotes />
|
|
31
|
+
</InnerContainer>
|
|
32
|
+
</CheckoutContainer>
|
|
33
|
+
<CheckoutContainer textAlign='center'>
|
|
34
|
+
<InnerContainer
|
|
35
|
+
paddingBottom='0px'
|
|
36
|
+
width={700}
|
|
37
|
+
>
|
|
38
|
+
<Title
|
|
39
|
+
icon={faTruck}
|
|
40
|
+
title={
|
|
41
|
+
shipmentGroups.length > 1
|
|
42
|
+
? 'Select shipment methods'
|
|
43
|
+
: shipmentGroups.length
|
|
44
|
+
? 'Select a shipment method'
|
|
45
|
+
: ''
|
|
46
|
+
}
|
|
47
|
+
/>
|
|
48
|
+
</InnerContainer>
|
|
49
|
+
</CheckoutContainer>
|
|
50
|
+
{fetchingShipmentGroups ? (
|
|
51
|
+
<CheckoutContainer>
|
|
52
|
+
<InnerContainer width={700}>
|
|
53
|
+
<LoadingTemplateSm />
|
|
54
|
+
<p>Fetching shipping options.</p>
|
|
55
|
+
</InnerContainer>
|
|
56
|
+
</CheckoutContainer>
|
|
57
|
+
) : (
|
|
58
|
+
<CheckoutContainer textAlign='left'>
|
|
59
|
+
<InnerContainer
|
|
60
|
+
paddingBottom='1rem'
|
|
61
|
+
width={700}
|
|
62
|
+
>
|
|
63
|
+
{shipmentGroups.length > 1 &&
|
|
64
|
+
<Alert alertType='warning'>
|
|
65
|
+
Items within this cart are warehoused in different locations
|
|
66
|
+
and will be shipped separately. Please select how you would
|
|
67
|
+
like your items to be shipped.
|
|
68
|
+
</Alert>
|
|
69
|
+
}
|
|
70
|
+
{shipmentGroups.map((group: any, index: number) =>
|
|
71
|
+
<ShipmentGroupCard
|
|
72
|
+
group={group}
|
|
73
|
+
groupIndex={index}
|
|
74
|
+
key={`${index}-shipment-group`}
|
|
75
|
+
/>
|
|
76
|
+
)}
|
|
77
|
+
</InnerContainer>
|
|
78
|
+
</CheckoutContainer>
|
|
79
|
+
)}
|
|
80
|
+
</div>
|
|
81
|
+
</CartBody>
|
|
82
|
+
</CartTabPanel>
|
|
83
|
+
);
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
export default PanelCartShipment;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
2
|
+
import { faTrashAlt } from '@fortawesome/free-solid-svg-icons';
|
|
3
|
+
import { tabIdClearCart } from '../utilities/tabs';
|
|
4
|
+
import { Button } from '../buttons';
|
|
5
|
+
import { CartBody, CartTabPanel } from '../components';
|
|
6
|
+
import { useCartContext } from '../CartProvider';
|
|
7
|
+
|
|
8
|
+
function PanelClearCart() {
|
|
9
|
+
const {
|
|
10
|
+
classNameBtnDanger,
|
|
11
|
+
classNameBtnDefault,
|
|
12
|
+
classNameClearCartContainer,
|
|
13
|
+
classNameClearCartText,
|
|
14
|
+
clearCart,
|
|
15
|
+
closeClearCart,
|
|
16
|
+
} = useCartContext();
|
|
17
|
+
return (
|
|
18
|
+
<CartTabPanel tabId={tabIdClearCart}>
|
|
19
|
+
<CartBody>
|
|
20
|
+
<div style={{display: 'flex', justifyContent: 'center', minHeight: '450px'}}>
|
|
21
|
+
<div className={classNameClearCartContainer}>
|
|
22
|
+
<h2><FontAwesomeIcon icon={faTrashAlt} /></h2>
|
|
23
|
+
<h3>Clear Cart</h3>
|
|
24
|
+
<p className={classNameClearCartText}>
|
|
25
|
+
Are you sure you would like to clear this cart?
|
|
26
|
+
</p>
|
|
27
|
+
<p>
|
|
28
|
+
<Button
|
|
29
|
+
className={classNameBtnDefault}
|
|
30
|
+
onClick={closeClearCart}
|
|
31
|
+
>
|
|
32
|
+
Cancel
|
|
33
|
+
</Button>
|
|
34
|
+
</p>
|
|
35
|
+
<p>
|
|
36
|
+
<Button
|
|
37
|
+
className={classNameBtnDanger}
|
|
38
|
+
onClick={() => clearCart()}
|
|
39
|
+
>
|
|
40
|
+
Yes, clear cart
|
|
41
|
+
</Button>
|
|
42
|
+
</p>
|
|
43
|
+
</div>
|
|
44
|
+
</div>
|
|
45
|
+
</CartBody>
|
|
46
|
+
</CartTabPanel>
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export default PanelClearCart;
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
import { tabIdCheckout } from '../utilities/tabs';
|
|
2
|
+
import {
|
|
3
|
+
CheckoutContainer,
|
|
4
|
+
InnerContainer,
|
|
5
|
+
} from '../components/containers';
|
|
6
|
+
import CartClient from '../components/CartClient';
|
|
7
|
+
import CartShipment from '../components/CartShipment';
|
|
8
|
+
import {
|
|
9
|
+
CartBody,
|
|
10
|
+
CartTabPanel,
|
|
11
|
+
CustomerCheckoutMethodTabs,
|
|
12
|
+
Title,
|
|
13
|
+
} from '../components';
|
|
14
|
+
import FormSquarePayment from '../forms/FormSquarePayment';
|
|
15
|
+
import FormStripePayment from '../forms/FormStripePayment';
|
|
16
|
+
import { faCoins, faCreditCard } from '@fortawesome/free-solid-svg-icons';
|
|
17
|
+
import { useCartContext } from '../CartProvider';
|
|
18
|
+
import DiscountInputGroup from '../components/DiscountInputGroup';
|
|
19
|
+
import CartTotalsListGroup from '../components/CartTotalsListGroup';
|
|
20
|
+
import { cartItemsNeedShipment } from '../utilities/shipment';
|
|
21
|
+
|
|
22
|
+
function PanelClientCheckout() {
|
|
23
|
+
const { cart, cartClient, showDiscountCode } = useCartContext();
|
|
24
|
+
const needsShipping = cartItemsNeedShipment(cart);
|
|
25
|
+
const { domain } = cart;
|
|
26
|
+
const company = domain && domain.company;
|
|
27
|
+
const whatsappEnabled = Boolean(domain?.enableWhatsappNotifications);
|
|
28
|
+
return (
|
|
29
|
+
<CartTabPanel tabId={tabIdCheckout}>
|
|
30
|
+
<CartBody style={{ paddingTop: '2rem' }}>
|
|
31
|
+
{cartClient && cartClient.id > -1 ?
|
|
32
|
+
<>
|
|
33
|
+
<CheckoutContainer>
|
|
34
|
+
<InnerContainer paddingBottom='3rem'>
|
|
35
|
+
<CartClient />
|
|
36
|
+
</InnerContainer>
|
|
37
|
+
</CheckoutContainer>
|
|
38
|
+
{needsShipping &&
|
|
39
|
+
<CheckoutContainer>
|
|
40
|
+
<InnerContainer
|
|
41
|
+
paddingBottom='3rem'
|
|
42
|
+
>
|
|
43
|
+
<CartShipment cart={cart} />
|
|
44
|
+
</InnerContainer>
|
|
45
|
+
</CheckoutContainer>
|
|
46
|
+
}
|
|
47
|
+
{showDiscountCode && (
|
|
48
|
+
<CheckoutContainer>
|
|
49
|
+
<InnerContainer
|
|
50
|
+
paddingBottom='3rem'
|
|
51
|
+
>
|
|
52
|
+
<DiscountInputGroup />
|
|
53
|
+
</InnerContainer>
|
|
54
|
+
</CheckoutContainer>
|
|
55
|
+
)}
|
|
56
|
+
{Boolean(company) && company.acceptSquare &&
|
|
57
|
+
<CheckoutContainer>
|
|
58
|
+
<InnerContainer
|
|
59
|
+
paddingTop='3rem'
|
|
60
|
+
paddingBottom='3rem'
|
|
61
|
+
>
|
|
62
|
+
<FormSquarePayment />
|
|
63
|
+
</InnerContainer>
|
|
64
|
+
</CheckoutContainer>
|
|
65
|
+
}
|
|
66
|
+
<CheckoutContainer>
|
|
67
|
+
<InnerContainer
|
|
68
|
+
paddingBottom='3rem'
|
|
69
|
+
>
|
|
70
|
+
<Title
|
|
71
|
+
icon={faCoins}
|
|
72
|
+
title='Cart total'
|
|
73
|
+
/>
|
|
74
|
+
<CartTotalsListGroup />
|
|
75
|
+
</InnerContainer>
|
|
76
|
+
</CheckoutContainer>
|
|
77
|
+
<CheckoutContainer>
|
|
78
|
+
<InnerContainer
|
|
79
|
+
paddingBottom='3rem'
|
|
80
|
+
>
|
|
81
|
+
<Title
|
|
82
|
+
icon={faCreditCard}
|
|
83
|
+
title='Credit card payment'
|
|
84
|
+
/>
|
|
85
|
+
<FormStripePayment />
|
|
86
|
+
</InnerContainer>
|
|
87
|
+
</CheckoutContainer>
|
|
88
|
+
|
|
89
|
+
</>
|
|
90
|
+
:
|
|
91
|
+
<CheckoutContainer>
|
|
92
|
+
<InnerContainer paddingBottom='0px'>
|
|
93
|
+
<CustomerCheckoutMethodTabs whatsappEnabled={whatsappEnabled} />
|
|
94
|
+
</InnerContainer>
|
|
95
|
+
</CheckoutContainer>
|
|
96
|
+
}
|
|
97
|
+
</CartBody>
|
|
98
|
+
</CartTabPanel>
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export default PanelClientCheckout;
|
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
import { Suspense, lazy, useState } from 'react';
|
|
2
|
+
import { tabIdItem, tabIdItems } from '../utilities/tabs';
|
|
3
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
4
|
+
import { faCircleNotch } from '@fortawesome/free-solid-svg-icons';
|
|
5
|
+
import { Button, ButtonBack } from '../buttons';
|
|
6
|
+
import {
|
|
7
|
+
CartBody,
|
|
8
|
+
CartFooter,
|
|
9
|
+
CartTabPanel,
|
|
10
|
+
} from '../components';
|
|
11
|
+
import { LoadingTemplateSm } from '../components/LoadingTemplate';
|
|
12
|
+
import { useCartContext } from '../CartProvider';
|
|
13
|
+
import { makeCartItem } from '../utilities/cart';
|
|
14
|
+
import { getCartCookieToken } from '../utilities/cookie';
|
|
15
|
+
import { publishedFormBundle } from '../utilities/customForm';
|
|
16
|
+
import CustomCartProductForm from '../components/CustomCartProductForm';
|
|
17
|
+
|
|
18
|
+
const MerchiProductForm = lazy(() => import('@merchi/product-form'));
|
|
19
|
+
|
|
20
|
+
function cleanVariation(variation: any) {
|
|
21
|
+
const { variationField = {}, variationFiles = [] } = variation;
|
|
22
|
+
return {
|
|
23
|
+
...variation,
|
|
24
|
+
id: undefined,
|
|
25
|
+
value: variation.value,
|
|
26
|
+
variationField: {id: variationField.id},
|
|
27
|
+
variationFiles: variationFiles.map((f: any) => ({id: f.id})),
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
function cleanVariationGroups(variationsGroup: any) {
|
|
32
|
+
const { quantity = 0, variations = [] } = variationsGroup;
|
|
33
|
+
return {
|
|
34
|
+
idL: undefined,
|
|
35
|
+
quantity,
|
|
36
|
+
variations: variations?.map(cleanVariation),
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
interface Props {
|
|
41
|
+
cart: any;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function PanelEditCartItem({ cart }: Props) {
|
|
45
|
+
const {
|
|
46
|
+
activeTabIndex,
|
|
47
|
+
alertError,
|
|
48
|
+
alertSuccess,
|
|
49
|
+
cartItem,
|
|
50
|
+
domainId,
|
|
51
|
+
productFormClassNames,
|
|
52
|
+
classNameBtnEditCartItem,
|
|
53
|
+
apiUrl,
|
|
54
|
+
refetchCart,
|
|
55
|
+
setActiveTabIndex,
|
|
56
|
+
setCartItem,
|
|
57
|
+
} = useCartContext();
|
|
58
|
+
const [loading, setLoading] = useState(false);
|
|
59
|
+
const [customFormActive, setCustomFormActive] = useState(false);
|
|
60
|
+
const formId = 'edit-cart-item-form';
|
|
61
|
+
|
|
62
|
+
// This action patches the cart item
|
|
63
|
+
async function actionCartItemEdit(cartItemJson: any) {
|
|
64
|
+
setLoading(true);
|
|
65
|
+
const cartToken = await getCartCookieToken((domainId as number));
|
|
66
|
+
try {
|
|
67
|
+
const {
|
|
68
|
+
product,
|
|
69
|
+
quantity = 0,
|
|
70
|
+
taxType,
|
|
71
|
+
variations = [],
|
|
72
|
+
variationsGroups = [],
|
|
73
|
+
} = cartItemJson;
|
|
74
|
+
|
|
75
|
+
const cartItemEnt = makeCartItem({
|
|
76
|
+
...cartItem,
|
|
77
|
+
id: (cartItem as any).id,
|
|
78
|
+
cart: {id: (cart as any).id},
|
|
79
|
+
product: product ? {id: product.id} : undefined,
|
|
80
|
+
taxType: taxType ? {id: taxType.id} : undefined,
|
|
81
|
+
quantity,
|
|
82
|
+
variations: variations.map(cleanVariation),
|
|
83
|
+
variationsGroups: variationsGroups.map(cleanVariationGroups),
|
|
84
|
+
}, true, cartToken);
|
|
85
|
+
|
|
86
|
+
// Save changes to the Cart Item
|
|
87
|
+
await cartItemEnt.save();
|
|
88
|
+
|
|
89
|
+
// Refetch the Cart and all it's relationships
|
|
90
|
+
await refetchCart();
|
|
91
|
+
|
|
92
|
+
// Show success alert
|
|
93
|
+
alertSuccess('Item updated.');
|
|
94
|
+
|
|
95
|
+
// Set active Cart tab
|
|
96
|
+
setActiveTabIndex(tabIdItems);
|
|
97
|
+
|
|
98
|
+
// Clear Cart Item from state
|
|
99
|
+
setCartItem({});
|
|
100
|
+
} catch (e: any) {
|
|
101
|
+
alertError(e.errorMessage || e.message || 'Unable to edit Cart Item.');
|
|
102
|
+
} finally {
|
|
103
|
+
setLoading(false);
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
function onSubmit(jobJson: any) {
|
|
108
|
+
actionCartItemEdit(jobJson);
|
|
109
|
+
}
|
|
110
|
+
const cleanCartItem = {
|
|
111
|
+
...cartItem,
|
|
112
|
+
id: undefined,
|
|
113
|
+
};
|
|
114
|
+
const showForm =
|
|
115
|
+
activeTabIndex === tabIdItem && !!cartItem?.id && !!cartItem?.product?.id;
|
|
116
|
+
const hasPublishedCustomForm = !!publishedFormBundle(cartItem?.product);
|
|
117
|
+
|
|
118
|
+
const defaultForm = (
|
|
119
|
+
<Suspense fallback={<LoadingTemplateSm />}>
|
|
120
|
+
<MerchiProductForm
|
|
121
|
+
apiUrl={apiUrl}
|
|
122
|
+
isCartItem={true}
|
|
123
|
+
initJob={{...cleanCartItem}}
|
|
124
|
+
initProduct={cartItem.product}
|
|
125
|
+
onSubmit={onSubmit}
|
|
126
|
+
productFormId={formId}
|
|
127
|
+
hideRequestQuotationButton={true}
|
|
128
|
+
hidePaymentUpfrontButton={true}
|
|
129
|
+
{...productFormClassNames}
|
|
130
|
+
/>
|
|
131
|
+
</Suspense>
|
|
132
|
+
);
|
|
133
|
+
|
|
134
|
+
return (
|
|
135
|
+
<CartTabPanel tabId={tabIdItem}>
|
|
136
|
+
<CartBody style={{padding: '2rem'}}>
|
|
137
|
+
{showForm && (
|
|
138
|
+
hasPublishedCustomForm ? (
|
|
139
|
+
<CustomCartProductForm
|
|
140
|
+
product={cartItem.product}
|
|
141
|
+
initialJob={cleanCartItem}
|
|
142
|
+
apiUrl={apiUrl}
|
|
143
|
+
onSave={onSubmit}
|
|
144
|
+
fallback={defaultForm}
|
|
145
|
+
onActiveChange={setCustomFormActive}
|
|
146
|
+
/>
|
|
147
|
+
) : (
|
|
148
|
+
defaultForm
|
|
149
|
+
)
|
|
150
|
+
)}
|
|
151
|
+
</CartBody>
|
|
152
|
+
<CartFooter>
|
|
153
|
+
<ButtonBack />
|
|
154
|
+
{/* Custom forms render their own Save in ProductFormShell; keep the
|
|
155
|
+
HTML-form Save only for the default @merchi/product-form path. */}
|
|
156
|
+
{!customFormActive && (
|
|
157
|
+
<Button
|
|
158
|
+
className={classNameBtnEditCartItem}
|
|
159
|
+
disabled={loading}
|
|
160
|
+
form={formId}
|
|
161
|
+
type='submit'
|
|
162
|
+
>
|
|
163
|
+
{loading && <FontAwesomeIcon icon={faCircleNotch} spin />}
|
|
164
|
+
{loading ? ' Loading...' : 'Save'}
|
|
165
|
+
</Button>
|
|
166
|
+
)}
|
|
167
|
+
</CartFooter>
|
|
168
|
+
</CartTabPanel>
|
|
169
|
+
);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
export default PanelEditCartItem;
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import {
|
|
2
|
+
CheckoutContainer,
|
|
3
|
+
InnerContainer,
|
|
4
|
+
} from '../components/containers';
|
|
5
|
+
import { tabIdPaymentSuccess } from '../utilities/tabs';
|
|
6
|
+
import { companyPrimaryAddress } from '../utilities/company';
|
|
7
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
8
|
+
import { faCheckCircle } from '@fortawesome/free-solid-svg-icons';
|
|
9
|
+
import { Button, ButtonInvoiceDownload } from '../buttons';
|
|
10
|
+
import { CartBody, CartTabPanel } from '../components';
|
|
11
|
+
import { useCartContext } from '../CartProvider';
|
|
12
|
+
|
|
13
|
+
function PanelPaymentSuccess() {
|
|
14
|
+
const {
|
|
15
|
+
classNameBtnPrimary,
|
|
16
|
+
customSuccessMessage,
|
|
17
|
+
fetchingCart,
|
|
18
|
+
invoiceJson,
|
|
19
|
+
setCartComplete,
|
|
20
|
+
urlTrackingPage,
|
|
21
|
+
} = useCartContext();
|
|
22
|
+
const { domain, id, unpaid } = invoiceJson;
|
|
23
|
+
const email = domain && domain.company ? companyPrimaryAddress(domain.company) : null;
|
|
24
|
+
return (
|
|
25
|
+
<CartTabPanel tabId={tabIdPaymentSuccess}>
|
|
26
|
+
<CartBody>
|
|
27
|
+
<CheckoutContainer>
|
|
28
|
+
<InnerContainer>
|
|
29
|
+
<h2><FontAwesomeIcon icon={faCheckCircle} /></h2>
|
|
30
|
+
<h3>Order #{id}</h3>
|
|
31
|
+
<h4>Payment Received!</h4>
|
|
32
|
+
{customSuccessMessage ? (
|
|
33
|
+
<p className='merchi-cart-success-message '>
|
|
34
|
+
{customSuccessMessage}
|
|
35
|
+
</p>
|
|
36
|
+
) : (
|
|
37
|
+
<p className='merchi-cart-success-message '>
|
|
38
|
+
Your order #{id} is being processed and you should
|
|
39
|
+
receive an email from us shortly. If you haven't heard from us within 24
|
|
40
|
+
hours please feel free to contact us{email ? ` at ${email.emailAddress}.` : '.'}
|
|
41
|
+
</p>
|
|
42
|
+
)}
|
|
43
|
+
{!unpaid && <p><ButtonInvoiceDownload /></p>}
|
|
44
|
+
<p>
|
|
45
|
+
<Button
|
|
46
|
+
className={classNameBtnPrimary}
|
|
47
|
+
disabled={fetchingCart}
|
|
48
|
+
onClick={setCartComplete}
|
|
49
|
+
>
|
|
50
|
+
{fetchingCart ? 'Loading...' : 'Done'}
|
|
51
|
+
</Button>
|
|
52
|
+
</p>
|
|
53
|
+
</InnerContainer>
|
|
54
|
+
</CheckoutContainer>
|
|
55
|
+
{urlTrackingPage &&
|
|
56
|
+
<iframe
|
|
57
|
+
style={{height: '1px', left: '0px', width: '1px'}}
|
|
58
|
+
src={urlTrackingPage}
|
|
59
|
+
/>
|
|
60
|
+
}
|
|
61
|
+
</CartBody>
|
|
62
|
+
</CartTabPanel>
|
|
63
|
+
);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export default PanelPaymentSuccess;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import PanelCartItems from "./PanelCartItems";
|
|
2
|
+
import PanelCartShipment from "./PanelCartShipment";
|
|
3
|
+
import PanelClearCart from "./PanelClearCart";
|
|
4
|
+
import PanelClientCheckout from "./PanelClientCheckout";
|
|
5
|
+
import PanelEditCartItem from "./PanelEditCartItem";
|
|
6
|
+
import PanelPaymentSuccess from "./PanelPaymentSuccess";
|
|
7
|
+
|
|
8
|
+
export {
|
|
9
|
+
PanelCartItems,
|
|
10
|
+
PanelCartShipment,
|
|
11
|
+
PanelClearCart,
|
|
12
|
+
PanelClientCheckout,
|
|
13
|
+
PanelPaymentSuccess,
|
|
14
|
+
PanelEditCartItem,
|
|
15
|
+
}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { CreditCard, PaymentForm } from 'react-square-web-payments-sdk';
|
|
3
|
+
import { currencyMap } from '../utilities/currency';
|
|
4
|
+
import { useCartContext } from '../CartProvider';
|
|
5
|
+
import { tabIdPaymentSuccess } from '../utilities/tabs';
|
|
6
|
+
import { Merchi } from '@merchi/sdk';
|
|
7
|
+
|
|
8
|
+
declare const SQUARE_APPLICATION_ID: string;
|
|
9
|
+
|
|
10
|
+
function SquareCard() {
|
|
11
|
+
const {
|
|
12
|
+
alertError,
|
|
13
|
+
cart,
|
|
14
|
+
setActiveTabIndex,
|
|
15
|
+
setInvoiceJson,
|
|
16
|
+
} = useCartContext();
|
|
17
|
+
const { currency, domain, totalCost } = cart;
|
|
18
|
+
const [loading, setLoading] = React.useState(false);
|
|
19
|
+
const company = domain.company;
|
|
20
|
+
function ButtonText() {
|
|
21
|
+
return (
|
|
22
|
+
<span>
|
|
23
|
+
Pay {currencyMap[currency]}
|
|
24
|
+
{totalCost}<small> / inc tax</small>
|
|
25
|
+
</span>
|
|
26
|
+
);
|
|
27
|
+
}
|
|
28
|
+
const squareWebLocationId = company.squareWebLocationId;
|
|
29
|
+
function callbackCreditCardPaymentSuccess(invoiceJson: any) {
|
|
30
|
+
setInvoiceJson(invoiceJson);
|
|
31
|
+
setActiveTabIndex(tabIdPaymentSuccess);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
async function actionSquarePaymentProcess(
|
|
35
|
+
sourceId: string,
|
|
36
|
+
callbackPaymentSuccess: any,
|
|
37
|
+
) {
|
|
38
|
+
setLoading(true);
|
|
39
|
+
let url = `/cart/${cart.id}/square/payment/`;
|
|
40
|
+
const fetchOptions: any = {
|
|
41
|
+
method: 'GET',
|
|
42
|
+
query: [['sourceId', sourceId], ['cart_token', cart.token]],
|
|
43
|
+
};
|
|
44
|
+
try {
|
|
45
|
+
const merchi = new Merchi();
|
|
46
|
+
const r = await merchi.authenticatedFetch(url, fetchOptions);
|
|
47
|
+
callbackPaymentSuccess(r.invoice);
|
|
48
|
+
} catch(e: any) {
|
|
49
|
+
alertError(e.errorMessage || e.message || 'Server eror.');
|
|
50
|
+
} finally {
|
|
51
|
+
setLoading(false);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
return squareWebLocationId ? (
|
|
55
|
+
<PaymentForm
|
|
56
|
+
/**
|
|
57
|
+
* Identifies the calling form with a verified application ID generated from
|
|
58
|
+
* the Square Application Dashboard.
|
|
59
|
+
*/
|
|
60
|
+
applicationId={SQUARE_APPLICATION_ID}
|
|
61
|
+
/**
|
|
62
|
+
* Invoked when payment form receives the result of a tokenize generation
|
|
63
|
+
* request. The result will be a valid credit card or wallet token, or an error.
|
|
64
|
+
*/
|
|
65
|
+
cardTokenizeResponseReceived={(token: any, buyer: any) =>
|
|
66
|
+
actionSquarePaymentProcess(
|
|
67
|
+
token.token,
|
|
68
|
+
callbackCreditCardPaymentSuccess
|
|
69
|
+
)
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Identifies the location of the merchant that is taking the payment.
|
|
73
|
+
* Obtained from the Square Application Dashboard - Locations tab.
|
|
74
|
+
*/
|
|
75
|
+
locationId={squareWebLocationId}
|
|
76
|
+
>
|
|
77
|
+
<CreditCard>
|
|
78
|
+
<ButtonText />
|
|
79
|
+
</CreditCard>
|
|
80
|
+
</PaymentForm>
|
|
81
|
+
) : <></>;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export default SquareCard;
|