@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,43 @@
|
|
|
1
|
+
import { useCartContext } from '../CartProvider';
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
interface Props {
|
|
5
|
+
isChecked: boolean;
|
|
6
|
+
setIsChecked: (isChecked: boolean) => void;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
function InputAcceptUserTermsAndConditions({ isChecked, setIsChecked }: Props) {
|
|
10
|
+
const {
|
|
11
|
+
classNameCartFormCheckbox,
|
|
12
|
+
classNameCartFormGroupCheckbox,
|
|
13
|
+
classNameCartFormLabelCheckbox,
|
|
14
|
+
} = useCartContext();
|
|
15
|
+
return (
|
|
16
|
+
<div
|
|
17
|
+
onClick={
|
|
18
|
+
() => setIsChecked(!isChecked)
|
|
19
|
+
}
|
|
20
|
+
className={classNameCartFormGroupCheckbox}
|
|
21
|
+
>
|
|
22
|
+
<label className={classNameCartFormLabelCheckbox}>
|
|
23
|
+
<input
|
|
24
|
+
className={classNameCartFormCheckbox}
|
|
25
|
+
defaultChecked={isChecked}
|
|
26
|
+
type='checkbox'
|
|
27
|
+
/>
|
|
28
|
+
{' '}
|
|
29
|
+
<span style={{ fontSize: '14px' }} className='text-muted'>
|
|
30
|
+
I agree to the user profile{' '}
|
|
31
|
+
<a
|
|
32
|
+
href='/terms-and-conditions/user/'
|
|
33
|
+
target='_blank'
|
|
34
|
+
>
|
|
35
|
+
terms & conditions
|
|
36
|
+
</a>.
|
|
37
|
+
</span>
|
|
38
|
+
</label>
|
|
39
|
+
</div>
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export default InputAcceptUserTermsAndConditions;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useCartContext } from '../CartProvider';
|
|
3
|
+
|
|
4
|
+
interface InputErrorProps {
|
|
5
|
+
error?: {
|
|
6
|
+
message?: string;
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const InputError: React.FC<InputErrorProps> = ({ error }) => {
|
|
11
|
+
const { classNameCartInputError } = useCartContext();
|
|
12
|
+
if (!error || !error.message) {
|
|
13
|
+
return null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
return (
|
|
17
|
+
<div className={classNameCartInputError}>
|
|
18
|
+
{error.message}
|
|
19
|
+
</div>
|
|
20
|
+
);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
export default InputError;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
2
|
+
import { useController } from 'react-hook-form';
|
|
3
|
+
import InputError from './InputError';
|
|
4
|
+
import { useCartContext } from '../CartProvider';
|
|
5
|
+
|
|
6
|
+
interface Option {
|
|
7
|
+
label: string;
|
|
8
|
+
value: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
interface Props {
|
|
12
|
+
control: any;
|
|
13
|
+
label?: string;
|
|
14
|
+
name: string;
|
|
15
|
+
options: Option[];
|
|
16
|
+
rules?: any;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function InputSelect({
|
|
20
|
+
control,
|
|
21
|
+
label,
|
|
22
|
+
name,
|
|
23
|
+
options,
|
|
24
|
+
rules,
|
|
25
|
+
}: Props) {
|
|
26
|
+
const {
|
|
27
|
+
classNameCartFormGroup,
|
|
28
|
+
classNameCartFormInput,
|
|
29
|
+
} = useCartContext();
|
|
30
|
+
const {
|
|
31
|
+
field,
|
|
32
|
+
fieldState: { error, invalid }
|
|
33
|
+
} = useController({
|
|
34
|
+
name,
|
|
35
|
+
control,
|
|
36
|
+
rules,
|
|
37
|
+
defaultValue: '',
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
return (
|
|
41
|
+
<div className={classNameCartFormGroup}>
|
|
42
|
+
{label && <label>{label}</label>}
|
|
43
|
+
<select
|
|
44
|
+
{...field}
|
|
45
|
+
className={`${classNameCartFormInput} ${invalid && ' is-invalid'}`}
|
|
46
|
+
>
|
|
47
|
+
{options.map((option, index) => (
|
|
48
|
+
<option key={index + uuidv4()} value={option.value}>
|
|
49
|
+
{option.label}
|
|
50
|
+
</option>
|
|
51
|
+
))}
|
|
52
|
+
</select>
|
|
53
|
+
<InputError error={error} />
|
|
54
|
+
</div>
|
|
55
|
+
);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export default InputSelect;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { useController } from 'react-hook-form';
|
|
2
|
+
import { useCartContext } from '../CartProvider';
|
|
3
|
+
import InputError from './InputError';
|
|
4
|
+
|
|
5
|
+
interface Props {
|
|
6
|
+
control: any;
|
|
7
|
+
label?: string;
|
|
8
|
+
name: string;
|
|
9
|
+
placeholder: string;
|
|
10
|
+
type?: string;
|
|
11
|
+
onChange?: (event: any) => void;
|
|
12
|
+
rules?: Record<string, any>;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function InputText({
|
|
16
|
+
control,
|
|
17
|
+
label,
|
|
18
|
+
name,
|
|
19
|
+
placeholder,
|
|
20
|
+
type = 'text',
|
|
21
|
+
onChange,
|
|
22
|
+
rules,
|
|
23
|
+
}: Props) {
|
|
24
|
+
const {
|
|
25
|
+
classNameCartFormGroup,
|
|
26
|
+
classNameCartFormInput,
|
|
27
|
+
} = useCartContext();
|
|
28
|
+
const {
|
|
29
|
+
field: { ref, ...inputProps },
|
|
30
|
+
fieldState: { error, invalid }
|
|
31
|
+
} = useController({
|
|
32
|
+
name,
|
|
33
|
+
control,
|
|
34
|
+
rules,
|
|
35
|
+
defaultValue: '',
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<div className={classNameCartFormGroup}>
|
|
40
|
+
{label && <label>{label}</label>}
|
|
41
|
+
<input
|
|
42
|
+
className={`${classNameCartFormInput} ${invalid && ' is-invalid'}`}
|
|
43
|
+
type={type}
|
|
44
|
+
placeholder={placeholder}
|
|
45
|
+
{...inputProps}
|
|
46
|
+
onChange={(e) => {
|
|
47
|
+
if (onChange) onChange(e); // Check if custom onChange was provided
|
|
48
|
+
inputProps.onChange(e); // Default RHF onChange
|
|
49
|
+
}}
|
|
50
|
+
/>
|
|
51
|
+
<InputError error={error} />
|
|
52
|
+
</div>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export default InputText;
|
|
@@ -0,0 +1,438 @@
|
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import { useEffect, useMemo, useState } from 'react';
|
|
3
|
+
import { debounce } from 'lodash';
|
|
4
|
+
import { Merchi } from '@merchi/sdk';
|
|
5
|
+
import { CountryDropdown, RegionDropdown } from 'react-country-region-selector';
|
|
6
|
+
import { Controller } from 'react-hook-form';
|
|
7
|
+
import InputText from './InputText';
|
|
8
|
+
import {
|
|
9
|
+
addressInOneLine,
|
|
10
|
+
googlePlacesResultAsNewAddress,
|
|
11
|
+
} from '../utilities/address';
|
|
12
|
+
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
13
|
+
import {
|
|
14
|
+
faSpinner,
|
|
15
|
+
faTimes,
|
|
16
|
+
faEdit,
|
|
17
|
+
faExclamationTriangle,
|
|
18
|
+
} from '@fortawesome/free-solid-svg-icons';
|
|
19
|
+
import { Collapse } from '../components';
|
|
20
|
+
import { useCartContext } from '../CartProvider';
|
|
21
|
+
|
|
22
|
+
const merchi = new Merchi();
|
|
23
|
+
|
|
24
|
+
interface Suggestion {
|
|
25
|
+
placeId: string;
|
|
26
|
+
description: string;
|
|
27
|
+
structuredFormatting: any;
|
|
28
|
+
types: string[];
|
|
29
|
+
matchedSubstrings: any[];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
interface Props {
|
|
33
|
+
defaultAddress?: any;
|
|
34
|
+
labelGeoSuggest?: string;
|
|
35
|
+
hookForm: any;
|
|
36
|
+
name: string;
|
|
37
|
+
placeholder?: string;
|
|
38
|
+
updateAddress: (address: any) => void;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function InputsAddress({
|
|
42
|
+
defaultAddress = {},
|
|
43
|
+
labelGeoSuggest = 'Address',
|
|
44
|
+
hookForm,
|
|
45
|
+
name,
|
|
46
|
+
placeholder = 'Search your address',
|
|
47
|
+
updateAddress,
|
|
48
|
+
}: Props) {
|
|
49
|
+
const {
|
|
50
|
+
classNameCartFormGroup,
|
|
51
|
+
classNameCartFormInput,
|
|
52
|
+
classNameCartRow,
|
|
53
|
+
classNameCartRowColumn,
|
|
54
|
+
classNameCartGoogleSuggestList,
|
|
55
|
+
classNameCartGoogleSuggestListItem,
|
|
56
|
+
} = useCartContext();
|
|
57
|
+
|
|
58
|
+
const [inputValue, setInputValue] = React.useState('');
|
|
59
|
+
const [suggestions, setSuggestions] = React.useState<Suggestion[]>([]);
|
|
60
|
+
const [showSuggestions, setShowSuggestions] = React.useState(false);
|
|
61
|
+
const [loading, setLoading] = React.useState(false);
|
|
62
|
+
const [selectedIndex, setSelectedIndex] = React.useState(-1);
|
|
63
|
+
|
|
64
|
+
const inputRef = React.useRef<HTMLInputElement>(null);
|
|
65
|
+
const suggestionsRef = React.useRef<HTMLDivElement>(null);
|
|
66
|
+
|
|
67
|
+
const {
|
|
68
|
+
control,
|
|
69
|
+
formState: { errors, isValid, submitCount },
|
|
70
|
+
setValue,
|
|
71
|
+
getValues,
|
|
72
|
+
reset,
|
|
73
|
+
watch,
|
|
74
|
+
} = hookForm;
|
|
75
|
+
const inputName = (_name: string) => `${name ? `${name}.` : ''}${_name}`;
|
|
76
|
+
const selectedCountry = watch(inputName('country'));
|
|
77
|
+
|
|
78
|
+
function onChangeCountryState() {
|
|
79
|
+
const values = getValues();
|
|
80
|
+
updateAddress(name ? values[name] : values);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const [addressFieldsOpen, setAddressFieldsOpen] = useState(false);
|
|
84
|
+
const toggleAddressFieldsOpen = () => setAddressFieldsOpen(!addressFieldsOpen);
|
|
85
|
+
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
if (!isValid && !addressFieldsOpen && submitCount > 0) {
|
|
88
|
+
toggleAddressFieldsOpen();
|
|
89
|
+
}
|
|
90
|
+
}, [isValid, submitCount]);
|
|
91
|
+
|
|
92
|
+
useEffect(() => {
|
|
93
|
+
if (!defaultAddress?.lineOne) return;
|
|
94
|
+
|
|
95
|
+
const nextAddress = { ...defaultAddress };
|
|
96
|
+
setInputValue(addressInOneLine(nextAddress));
|
|
97
|
+
reset(
|
|
98
|
+
name
|
|
99
|
+
? { ...getValues(), [name]: nextAddress }
|
|
100
|
+
: { ...getValues(), ...nextAddress },
|
|
101
|
+
{ keepSubmitCount: true },
|
|
102
|
+
);
|
|
103
|
+
}, [defaultAddress?.lineOne, defaultAddress?.city, defaultAddress?.postcode]);
|
|
104
|
+
|
|
105
|
+
async function searchAddresses(query: string) {
|
|
106
|
+
if (!query.trim()) {
|
|
107
|
+
setSuggestions([]);
|
|
108
|
+
setShowSuggestions(false);
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
setLoading(true);
|
|
113
|
+
try {
|
|
114
|
+
const response = await merchi.authenticatedFetch('/addresses/place-search/', {
|
|
115
|
+
method: 'GET',
|
|
116
|
+
query: [['q', query]],
|
|
117
|
+
});
|
|
118
|
+
|
|
119
|
+
if (response.status === 'success') {
|
|
120
|
+
setSuggestions(response.results || []);
|
|
121
|
+
setShowSuggestions(true);
|
|
122
|
+
setSelectedIndex(-1);
|
|
123
|
+
}
|
|
124
|
+
} catch (error) {
|
|
125
|
+
console.error('Error searching addresses:', error);
|
|
126
|
+
setSuggestions([]);
|
|
127
|
+
setShowSuggestions(false);
|
|
128
|
+
} finally {
|
|
129
|
+
setLoading(false);
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const debouncedSearch = useMemo(() => debounce(searchAddresses, 500), []);
|
|
134
|
+
|
|
135
|
+
useEffect(() => () => debouncedSearch.cancel(), [debouncedSearch]);
|
|
136
|
+
|
|
137
|
+
function handleInputChange(event: React.ChangeEvent<HTMLInputElement>) {
|
|
138
|
+
const value = event.target.value;
|
|
139
|
+
setInputValue(value);
|
|
140
|
+
debouncedSearch(value);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
async function handleSuggestionSelect(suggestion: Suggestion) {
|
|
144
|
+
function applyDescriptionOnly() {
|
|
145
|
+
setInputValue(suggestion.description);
|
|
146
|
+
updateAddress({
|
|
147
|
+
city: '',
|
|
148
|
+
country: '',
|
|
149
|
+
lineOne: suggestion.description,
|
|
150
|
+
lineTwo: '',
|
|
151
|
+
postcode: '',
|
|
152
|
+
state: '',
|
|
153
|
+
});
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
setLoading(true);
|
|
157
|
+
try {
|
|
158
|
+
const response = await merchi.authenticatedFetch('/addresses/place-details/', {
|
|
159
|
+
method: 'GET',
|
|
160
|
+
query: [['place_id', suggestion.placeId]],
|
|
161
|
+
});
|
|
162
|
+
|
|
163
|
+
const parsedAddress = response.status === 'success'
|
|
164
|
+
? googlePlacesResultAsNewAddress(response.result)
|
|
165
|
+
: null;
|
|
166
|
+
|
|
167
|
+
if (parsedAddress) {
|
|
168
|
+
setInputValue(addressInOneLine(parsedAddress));
|
|
169
|
+
updateAddress(parsedAddress);
|
|
170
|
+
} else {
|
|
171
|
+
applyDescriptionOnly();
|
|
172
|
+
}
|
|
173
|
+
} catch (error) {
|
|
174
|
+
console.error('Error fetching place details:', error);
|
|
175
|
+
applyDescriptionOnly();
|
|
176
|
+
} finally {
|
|
177
|
+
setLoading(false);
|
|
178
|
+
setShowSuggestions(false);
|
|
179
|
+
setSuggestions([]);
|
|
180
|
+
setSelectedIndex(-1);
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
function handleKeyDown(event: React.KeyboardEvent<HTMLInputElement>) {
|
|
185
|
+
if (!showSuggestions || suggestions.length === 0) return;
|
|
186
|
+
|
|
187
|
+
switch (event.key) {
|
|
188
|
+
case 'ArrowDown':
|
|
189
|
+
event.preventDefault();
|
|
190
|
+
setSelectedIndex((prev) =>
|
|
191
|
+
prev < suggestions.length - 1 ? prev + 1 : 0,
|
|
192
|
+
);
|
|
193
|
+
break;
|
|
194
|
+
case 'ArrowUp':
|
|
195
|
+
event.preventDefault();
|
|
196
|
+
setSelectedIndex((prev) =>
|
|
197
|
+
prev > 0 ? prev - 1 : suggestions.length - 1,
|
|
198
|
+
);
|
|
199
|
+
break;
|
|
200
|
+
case 'Enter':
|
|
201
|
+
event.preventDefault();
|
|
202
|
+
if (selectedIndex >= 0 && selectedIndex < suggestions.length) {
|
|
203
|
+
handleSuggestionSelect(suggestions[selectedIndex]);
|
|
204
|
+
}
|
|
205
|
+
break;
|
|
206
|
+
case 'Escape':
|
|
207
|
+
setShowSuggestions(false);
|
|
208
|
+
setSelectedIndex(-1);
|
|
209
|
+
break;
|
|
210
|
+
default:
|
|
211
|
+
break;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
function handleInputBlur() {
|
|
216
|
+
setTimeout(() => {
|
|
217
|
+
if (!suggestionsRef.current?.contains(document.activeElement)) {
|
|
218
|
+
setShowSuggestions(false);
|
|
219
|
+
setSelectedIndex(-1);
|
|
220
|
+
}
|
|
221
|
+
}, 200);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
function handleInputFocus() {
|
|
225
|
+
if (suggestions.length > 0) {
|
|
226
|
+
setShowSuggestions(true);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
function clearInput(e: React.MouseEvent) {
|
|
231
|
+
e.preventDefault();
|
|
232
|
+
setInputValue('');
|
|
233
|
+
setSuggestions([]);
|
|
234
|
+
setShowSuggestions(false);
|
|
235
|
+
updateAddress({
|
|
236
|
+
city: '',
|
|
237
|
+
country: '',
|
|
238
|
+
lineOne: '',
|
|
239
|
+
lineTwo: '',
|
|
240
|
+
postcode: '',
|
|
241
|
+
state: '',
|
|
242
|
+
});
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
const hasErrors = !!Object.keys(errors || {}).length;
|
|
246
|
+
|
|
247
|
+
const addressForm = (
|
|
248
|
+
<>
|
|
249
|
+
<InputText
|
|
250
|
+
control={control}
|
|
251
|
+
label="Address line one"
|
|
252
|
+
name={inputName('lineOne')}
|
|
253
|
+
placeholder="123 Fake st"
|
|
254
|
+
rules={{ required: 'Address line one is required.' }}
|
|
255
|
+
/>
|
|
256
|
+
<InputText
|
|
257
|
+
control={control}
|
|
258
|
+
label="Continue address"
|
|
259
|
+
name={inputName('lineTwo')}
|
|
260
|
+
placeholder="Continue address..."
|
|
261
|
+
/>
|
|
262
|
+
<div className={classNameCartRow}>
|
|
263
|
+
<div className={classNameCartRowColumn}>
|
|
264
|
+
<InputText
|
|
265
|
+
control={control}
|
|
266
|
+
label="City / Province"
|
|
267
|
+
name={inputName('city')}
|
|
268
|
+
placeholder="City"
|
|
269
|
+
rules={{ required: 'City / Province is required.' }}
|
|
270
|
+
/>
|
|
271
|
+
</div>
|
|
272
|
+
<div className={classNameCartRowColumn}>
|
|
273
|
+
<InputText
|
|
274
|
+
control={control}
|
|
275
|
+
label="Post / Zip code"
|
|
276
|
+
name={inputName('postcode')}
|
|
277
|
+
placeholder="90210"
|
|
278
|
+
/>
|
|
279
|
+
</div>
|
|
280
|
+
</div>
|
|
281
|
+
<div className={classNameCartRow}>
|
|
282
|
+
<div className={classNameCartRowColumn}>
|
|
283
|
+
<div className={classNameCartFormGroup}>
|
|
284
|
+
<label>Country</label>
|
|
285
|
+
<Controller
|
|
286
|
+
name={inputName('country')}
|
|
287
|
+
control={control}
|
|
288
|
+
defaultValue={defaultAddress && defaultAddress.country}
|
|
289
|
+
render={({ field }: any) => (
|
|
290
|
+
<CountryDropdown
|
|
291
|
+
{...field}
|
|
292
|
+
classes={classNameCartFormInput}
|
|
293
|
+
onChange={(val) => {
|
|
294
|
+
setValue(inputName('country'), val);
|
|
295
|
+
setValue(inputName('state'), '');
|
|
296
|
+
field.onChange(val);
|
|
297
|
+
onChangeCountryState();
|
|
298
|
+
}}
|
|
299
|
+
valueType="short"
|
|
300
|
+
/>
|
|
301
|
+
)}
|
|
302
|
+
/>
|
|
303
|
+
</div>
|
|
304
|
+
</div>
|
|
305
|
+
<div className={classNameCartRowColumn}>
|
|
306
|
+
<div className={classNameCartFormGroup}>
|
|
307
|
+
<label>State / Region</label>
|
|
308
|
+
<Controller
|
|
309
|
+
name={inputName('state')}
|
|
310
|
+
control={control}
|
|
311
|
+
defaultValue={defaultAddress && defaultAddress.state}
|
|
312
|
+
render={({ field }: any) => (
|
|
313
|
+
<RegionDropdown
|
|
314
|
+
{...field}
|
|
315
|
+
countryValueType="short"
|
|
316
|
+
country={selectedCountry}
|
|
317
|
+
classes={classNameCartFormInput}
|
|
318
|
+
onChange={(val) => {
|
|
319
|
+
setValue(inputName('state'), val);
|
|
320
|
+
field.onChange(val);
|
|
321
|
+
onChangeCountryState();
|
|
322
|
+
}}
|
|
323
|
+
valueType="short"
|
|
324
|
+
/>
|
|
325
|
+
)}
|
|
326
|
+
/>
|
|
327
|
+
</div>
|
|
328
|
+
</div>
|
|
329
|
+
</div>
|
|
330
|
+
</>
|
|
331
|
+
);
|
|
332
|
+
|
|
333
|
+
return (
|
|
334
|
+
<>
|
|
335
|
+
<div className={classNameCartFormGroup}>
|
|
336
|
+
<label>{labelGeoSuggest}</label>
|
|
337
|
+
<div className="merchi-cart-address-search" style={{ position: 'relative' }}>
|
|
338
|
+
<input
|
|
339
|
+
autoComplete="new-password"
|
|
340
|
+
ref={inputRef}
|
|
341
|
+
type="text"
|
|
342
|
+
name="address-suggestion"
|
|
343
|
+
className={classNameCartFormInput}
|
|
344
|
+
placeholder={placeholder}
|
|
345
|
+
value={inputValue}
|
|
346
|
+
onChange={handleInputChange}
|
|
347
|
+
onKeyDown={handleKeyDown}
|
|
348
|
+
onBlur={handleInputBlur}
|
|
349
|
+
onFocus={handleInputFocus}
|
|
350
|
+
style={{ paddingRight: loading || inputValue ? '40px' : undefined }}
|
|
351
|
+
/>
|
|
352
|
+
{loading && (
|
|
353
|
+
<div
|
|
354
|
+
className="merchi-cart-address-search__spinner"
|
|
355
|
+
style={{
|
|
356
|
+
position: 'absolute',
|
|
357
|
+
right: '10px',
|
|
358
|
+
top: '50%',
|
|
359
|
+
transform: 'translateY(-50%)',
|
|
360
|
+
}}
|
|
361
|
+
>
|
|
362
|
+
<FontAwesomeIcon icon={faSpinner} spin />
|
|
363
|
+
</div>
|
|
364
|
+
)}
|
|
365
|
+
{inputValue && !loading && (
|
|
366
|
+
<button
|
|
367
|
+
type="button"
|
|
368
|
+
className="btn btn-sm merchi-cart-address-search__clear"
|
|
369
|
+
style={{
|
|
370
|
+
position: 'absolute',
|
|
371
|
+
right: '5px',
|
|
372
|
+
top: '50%',
|
|
373
|
+
transform: 'translateY(-50%)',
|
|
374
|
+
border: 'none',
|
|
375
|
+
background: 'transparent',
|
|
376
|
+
padding: '2px 5px',
|
|
377
|
+
}}
|
|
378
|
+
onClick={clearInput}
|
|
379
|
+
>
|
|
380
|
+
<FontAwesomeIcon icon={faTimes} />
|
|
381
|
+
</button>
|
|
382
|
+
)}
|
|
383
|
+
{showSuggestions && suggestions.length > 0 && (
|
|
384
|
+
<div
|
|
385
|
+
ref={suggestionsRef}
|
|
386
|
+
className={classNameCartGoogleSuggestList}
|
|
387
|
+
role="listbox"
|
|
388
|
+
>
|
|
389
|
+
{suggestions.map((suggestion, index) => (
|
|
390
|
+
<div
|
|
391
|
+
key={suggestion.placeId}
|
|
392
|
+
className={`${classNameCartGoogleSuggestListItem}${
|
|
393
|
+
index === selectedIndex ? ' active' : ''
|
|
394
|
+
}`}
|
|
395
|
+
role="option"
|
|
396
|
+
onMouseDown={(e: React.MouseEvent) => {
|
|
397
|
+
e.preventDefault();
|
|
398
|
+
handleSuggestionSelect(suggestion);
|
|
399
|
+
}}
|
|
400
|
+
onMouseEnter={() => setSelectedIndex(index)}
|
|
401
|
+
>
|
|
402
|
+
<strong>
|
|
403
|
+
{suggestion.structuredFormatting?.main_text ||
|
|
404
|
+
suggestion.description}
|
|
405
|
+
</strong>
|
|
406
|
+
{suggestion.structuredFormatting?.secondary_text && (
|
|
407
|
+
<div className="text-muted small">
|
|
408
|
+
{suggestion.structuredFormatting.secondary_text}
|
|
409
|
+
</div>
|
|
410
|
+
)}
|
|
411
|
+
</div>
|
|
412
|
+
))}
|
|
413
|
+
</div>
|
|
414
|
+
)}
|
|
415
|
+
</div>
|
|
416
|
+
</div>
|
|
417
|
+
<Collapse isOpen={addressFieldsOpen}>{addressForm}</Collapse>
|
|
418
|
+
<div className="d-flex align-items-center">
|
|
419
|
+
{hasErrors && (
|
|
420
|
+
<div className="text-danger">
|
|
421
|
+
<FontAwesomeIcon icon={faExclamationTriangle} /> Invalid address!
|
|
422
|
+
</div>
|
|
423
|
+
)}
|
|
424
|
+
<a
|
|
425
|
+
className={`ml-auto btn btn-sm btn-link ${
|
|
426
|
+
hasErrors ? 'text-danger' : ''
|
|
427
|
+
}`}
|
|
428
|
+
onClick={toggleAddressFieldsOpen}
|
|
429
|
+
>
|
|
430
|
+
<FontAwesomeIcon icon={addressFieldsOpen ? faTimes : faEdit} />{' '}
|
|
431
|
+
{addressFieldsOpen ? 'Close' : 'Edit fields'}
|
|
432
|
+
</a>
|
|
433
|
+
</div>
|
|
434
|
+
</>
|
|
435
|
+
);
|
|
436
|
+
}
|
|
437
|
+
|
|
438
|
+
export default InputsAddress;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import FormCustomerNew from "./FormNewCustomer";
|
|
2
|
+
import FormReturningCustomer from "./FormReturningCustomer";
|
|
3
|
+
import FormShipmentAddressAndNotes, { ActiveFormShipmentAddressAndNotes } from "./FormShipmentAddressAndNotes";
|
|
4
|
+
import FormSquarePayment from "./FormSquarePayment";
|
|
5
|
+
import FormStripePayment from "./FormStripePayment";
|
|
6
|
+
import FormWhatsappCustomer from "./FormWhatsappCustomer";
|
|
7
|
+
import CustomerCheckoutMethodTabs from "../components/CustomerCheckoutMethodTabs";
|
|
8
|
+
|
|
9
|
+
export {
|
|
10
|
+
ActiveFormShipmentAddressAndNotes,
|
|
11
|
+
CustomerCheckoutMethodTabs,
|
|
12
|
+
FormCustomerNew,
|
|
13
|
+
FormReturningCustomer,
|
|
14
|
+
FormShipmentAddressAndNotes,
|
|
15
|
+
FormSquarePayment,
|
|
16
|
+
FormStripePayment,
|
|
17
|
+
FormWhatsappCustomer,
|
|
18
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import Cart, { CartComponents } from './Cart';
|
|
2
|
+
import { MerchiCartModal, MerchiShoppingCartModal } from './modals';
|
|
3
|
+
import { ButtonOpenCart, ButtonListWrappedOpenCart } from './buttons/ButtonOpenCartMerchiCartModal';
|
|
4
|
+
import * as components from './components';
|
|
5
|
+
import CartProvider, { useCartContext } from './CartProvider';
|
|
6
|
+
import CartAlert from './CartAlert';
|
|
7
|
+
import CartHeader from './CartHeader';
|
|
8
|
+
import CartTotals from './CartTotals';
|
|
9
|
+
import * as buttons from './buttons';
|
|
10
|
+
import * as forms from './forms';
|
|
11
|
+
import * as panels from './panels';
|
|
12
|
+
import * as utilities from './utilities';
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
buttons,
|
|
16
|
+
ButtonOpenCart,
|
|
17
|
+
ButtonListWrappedOpenCart,
|
|
18
|
+
Cart,
|
|
19
|
+
CartComponents,
|
|
20
|
+
CartAlert,
|
|
21
|
+
CartHeader,
|
|
22
|
+
CartProvider,
|
|
23
|
+
CartTotals,
|
|
24
|
+
components,
|
|
25
|
+
forms,
|
|
26
|
+
MerchiCartModal,
|
|
27
|
+
MerchiShoppingCartModal,
|
|
28
|
+
panels,
|
|
29
|
+
useCartContext,
|
|
30
|
+
utilities,
|
|
31
|
+
};
|