merchi_cart 0.0.7-e → 0.0.7
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/package.json +3 -4
- package/src/Cart.tsx +0 -100
- package/src/CartAlert.tsx +0 -34
- package/src/CartHeader.tsx +0 -27
- package/src/CartProvider.tsx +0 -386
- package/src/CartTotals.tsx +0 -106
- 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/buttons/Button.tsx +0 -35
- package/src/buttons/ButtonBack.tsx +0 -37
- package/src/buttons/ButtonClearCart.tsx +0 -18
- package/src/buttons/ButtonInvoiceDownload.tsx +0 -63
- package/src/buttons/ButtonNext.tsx +0 -38
- package/src/buttons/ButtonNextDynamic.tsx +0 -31
- package/src/buttons/ButtonPay.tsx +0 -32
- package/src/buttons/ButtonShipmentTabNext.tsx +0 -25
- package/src/buttons/index.ts +0 -15
- package/src/components/Alert.tsx +0 -31
- package/src/components/CartBody.tsx +0 -16
- package/src/components/CartClient.tsx +0 -48
- package/src/components/CartFooter.tsx +0 -15
- package/src/components/CartItemRow.tsx +0 -145
- package/src/components/CartPaymentSettingsInvalid.tsx +0 -12
- package/src/components/CartShipment.tsx +0 -55
- package/src/components/CartTabContent.tsx +0 -15
- package/src/components/CartTabPanel.tsx +0 -25
- package/src/components/CartTableContainer.tsx +0 -15
- package/src/components/Collapse.tsx +0 -23
- package/src/components/LoadingTemplate.tsx +0 -22
- package/src/components/NoCartItems.tsx +0 -15
- package/src/components/ShipmentGroupCard.tsx +0 -156
- package/src/components/Table.tsx +0 -14
- package/src/components/Title.tsx +0 -22
- package/src/components/containers.tsx +0 -40
- package/src/components/index.ts +0 -30
- package/src/forms/FormNewCustomer.tsx +0 -119
- package/src/forms/FormReturningCustomer.tsx +0 -70
- package/src/forms/FormShipmentAddressAndNotes.tsx +0 -142
- package/src/forms/FormSquarePayment.tsx +0 -14
- package/src/forms/FormStripePayment.tsx +0 -14
- package/src/forms/InputAcceptUserTermsAndConditions.tsx +0 -43
- package/src/forms/InputError.tsx +0 -23
- package/src/forms/InputSelect.tsx +0 -58
- package/src/forms/InputText.tsx +0 -56
- package/src/forms/InputsAddress.tsx +0 -205
- package/src/index.tsx +0 -13
- package/src/panels/PanelCartItems.tsx +0 -61
- package/src/panels/PanelCartShipment.tsx +0 -89
- package/src/panels/PanelClearCart.tsx +0 -47
- package/src/panels/PanelClientCheckout.tsx +0 -92
- package/src/panels/PanelEditCartItem.tsx +0 -58
- package/src/panels/PanelPaymentSuccess.tsx +0 -69
- package/src/panels/index.ts +0 -15
- package/src/slices/sliceCart.ts +0 -159
- package/src/slices/sliceCartAlert.ts +0 -39
- package/src/slices/sliceCartItem.ts +0 -29
- package/src/slices/sliceCartPayment.ts +0 -45
- package/src/slices/sliceCartShipment.ts +0 -67
- package/src/slices/sliceFormReturningCustomer.ts +0 -25
- package/src/slices/sliceNewCustomerForm.ts +0 -24
- package/src/square/SquareCard.tsx +0 -58
- package/src/square/actions.ts +0 -40
- package/src/square/slices/reducersSquare.ts +0 -9
- package/src/square/slices/sliceSquareAlerts.ts +0 -29
- package/src/square/slices/sliceSquareForm.ts +0 -29
- package/src/store.ts +0 -499
- package/src/stripe/StripeCardFields.tsx +0 -164
- package/src/stripe/StripeCardForm.tsx +0 -86
- package/src/stripe/StripePaymentButtons.tsx +0 -117
- package/src/stripe/actions.ts +0 -94
- package/src/stripe/slices/sliceStripeAlerts.ts +0 -29
- package/src/stripe/slices/sliceStripeCardForm.ts +0 -9
- package/src/stripe/slices/sliceStripeForm.ts +0 -56
- package/src/stripe/utils.ts +0 -21
- package/src/styles/globals.css +0 -191
- package/src/styles/globals.css.map +0 -1
- package/src/styles/globals.scss +0 -197
- package/src/tabs/CartNav.tsx +0 -20
- package/src/tabs/NavTab.tsx +0 -38
- package/src/utilities/address.ts +0 -351
- package/src/utilities/cart.ts +0 -73
- package/src/utilities/company.ts +0 -8
- package/src/utilities/cookie.ts +0 -54
- package/src/utilities/currency.ts +0 -216
- package/src/utilities/helpers.ts +0 -209
- package/src/utilities/invoice.ts +0 -60
- package/src/utilities/product.ts +0 -7
- package/src/utilities/user.ts +0 -38
- package/src/utilities/variations.ts +0 -56
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useState, useRef, useEffect } from 'react';
|
|
3
|
-
|
|
4
|
-
function Collapse({ isOpen, children }: any) {
|
|
5
|
-
const [height, setHeight] = useState(isOpen ? 'auto' : '0');
|
|
6
|
-
const ref = useRef(null);
|
|
7
|
-
|
|
8
|
-
useEffect(() => {
|
|
9
|
-
setHeight(isOpen ? `${(ref as any).current.scrollHeight}px` : '0');
|
|
10
|
-
}, [isOpen]);
|
|
11
|
-
|
|
12
|
-
return (
|
|
13
|
-
<div
|
|
14
|
-
className={`merchi-collapse ${isOpen ? 'show' : ''}`}
|
|
15
|
-
ref={ref}
|
|
16
|
-
style={{ transition: 'height 0.35s ease', overflow: 'hidden', height }}
|
|
17
|
-
>
|
|
18
|
-
{children}
|
|
19
|
-
</div>
|
|
20
|
-
);
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export default Collapse;
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { useCartContext } from "../CartProvider";
|
|
2
|
-
|
|
3
|
-
interface Props {
|
|
4
|
-
height?: number;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export default function LoadingTemplate({ height }: Props) {
|
|
8
|
-
const {
|
|
9
|
-
classNameLoadingTemplate,
|
|
10
|
-
classNameLoadingTemplateContainer,
|
|
11
|
-
} = useCartContext();
|
|
12
|
-
const style = height ? { height } : {};
|
|
13
|
-
return (
|
|
14
|
-
<div className={classNameLoadingTemplateContainer} style={style}>
|
|
15
|
-
<div className={classNameLoadingTemplate} />
|
|
16
|
-
</div>
|
|
17
|
-
);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export function LoadingTemplateSm() {
|
|
21
|
-
return <LoadingTemplate height={300} />;
|
|
22
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useCartContext } from '../CartProvider';
|
|
3
|
-
import pngProductNotFound from '../assets/product-not-found.png';
|
|
4
|
-
|
|
5
|
-
function NoCartItems() {
|
|
6
|
-
const { classNameNoItems } = useCartContext();
|
|
7
|
-
return (
|
|
8
|
-
<div className={classNameNoItems}>
|
|
9
|
-
<img src={pngProductNotFound.src} width={276} height={215} />
|
|
10
|
-
<p>No cart items.</p>
|
|
11
|
-
</div>
|
|
12
|
-
);
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export default NoCartItems;
|
|
@@ -1,156 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useSelector } from 'react-redux';
|
|
3
|
-
import { setSelectedShipmentQuote } from '../store';
|
|
4
|
-
import { addressInOneLine } from '../utilities/address';
|
|
5
|
-
import { currencyTaxAndCost } from '../utilities/currency';
|
|
6
|
-
import { useCartContext } from '../CartProvider';
|
|
7
|
-
import pngProductNotFound from '../assets/product-not-found.png';
|
|
8
|
-
|
|
9
|
-
function NoCartShipmentOptionsFound() {
|
|
10
|
-
const { classNameNoItems } = useCartContext();
|
|
11
|
-
return (
|
|
12
|
-
<div className={classNameNoItems}>
|
|
13
|
-
<img src={pngProductNotFound.src} width={276} height={215} />
|
|
14
|
-
<p>No cart items.</p>
|
|
15
|
-
</div>
|
|
16
|
-
);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
interface PropsPickupInfo {
|
|
20
|
-
originAddress: any;
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
function PickupInfo({ originAddress }: PropsPickupInfo) {
|
|
24
|
-
return (
|
|
25
|
-
<small>
|
|
26
|
-
Pick up from: {addressInOneLine(originAddress)}
|
|
27
|
-
</small>
|
|
28
|
-
);
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
function ShipmentPrice({ quote }: any) {
|
|
32
|
-
const { shipmentMethod, taxType, totalCost } = quote;
|
|
33
|
-
const { currency } = shipmentMethod;
|
|
34
|
-
return (
|
|
35
|
-
<div>
|
|
36
|
-
<small>
|
|
37
|
-
<strong>
|
|
38
|
-
{totalCost > 0 ? currencyTaxAndCost(currency, taxType, totalCost) : ''}
|
|
39
|
-
</strong>
|
|
40
|
-
</small>
|
|
41
|
-
</div>
|
|
42
|
-
);
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
interface PropsShipmentOptionInfo {
|
|
46
|
-
quote: any;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function ShipmentOptionInfo({ quote }: PropsShipmentOptionInfo) {
|
|
50
|
-
const { classNameShipmentOption } = useCartContext();
|
|
51
|
-
const { name, shipmentMethod } = quote;
|
|
52
|
-
const { originAddress, pickUp, transportCompanyName } = shipmentMethod;
|
|
53
|
-
return (
|
|
54
|
-
<div className={classNameShipmentOption}>
|
|
55
|
-
{
|
|
56
|
-
!name ?
|
|
57
|
-
<>
|
|
58
|
-
{transportCompanyName &&
|
|
59
|
-
<p className='mb-0'>
|
|
60
|
-
{shipmentMethod.name}
|
|
61
|
-
</p>
|
|
62
|
-
}
|
|
63
|
-
{
|
|
64
|
-
pickUp ?
|
|
65
|
-
<PickupInfo originAddress={originAddress} />
|
|
66
|
-
:
|
|
67
|
-
<small>{transportCompanyName}</small>
|
|
68
|
-
}
|
|
69
|
-
</>
|
|
70
|
-
:
|
|
71
|
-
<>
|
|
72
|
-
<p className='m-0'>{name}</p>
|
|
73
|
-
{pickUp && <PickupInfo originAddress={originAddress} />}
|
|
74
|
-
</>
|
|
75
|
-
}
|
|
76
|
-
<ShipmentPrice quote={quote} />
|
|
77
|
-
</div>
|
|
78
|
-
);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
interface ShipmentOptionProps {
|
|
82
|
-
groupIndex: number;
|
|
83
|
-
quote: any;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
function ShipmentQuote({ groupIndex, quote }: ShipmentOptionProps) {
|
|
87
|
-
const { classNameListItem } = useCartContext();
|
|
88
|
-
const { selectedQuotes } = useSelector((s: any) => s.stateCartShipment);
|
|
89
|
-
const isSelected = selectedQuotes[groupIndex].id === quote.id;
|
|
90
|
-
function doClick() {
|
|
91
|
-
setSelectedShipmentQuote(groupIndex, quote);
|
|
92
|
-
}
|
|
93
|
-
const icon = isSelected ? 'far fa-check-square' : 'far fa-square';
|
|
94
|
-
return (
|
|
95
|
-
<div
|
|
96
|
-
className={classNameListItem}
|
|
97
|
-
onClick={doClick}
|
|
98
|
-
style={{cursor: 'pointer'}}
|
|
99
|
-
>
|
|
100
|
-
<div
|
|
101
|
-
style={{
|
|
102
|
-
alignItems: 'center',
|
|
103
|
-
display: 'flex',
|
|
104
|
-
justifyContent: 'space-between',
|
|
105
|
-
}}
|
|
106
|
-
>
|
|
107
|
-
<ShipmentOptionInfo quote={quote} />
|
|
108
|
-
<div>
|
|
109
|
-
<i className={icon} />
|
|
110
|
-
</div>
|
|
111
|
-
</div>
|
|
112
|
-
</div>
|
|
113
|
-
)
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
interface Props {
|
|
117
|
-
group: any;
|
|
118
|
-
groupIndex: number;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
function ShipmentGroupCard({ group, groupIndex }: Props) {
|
|
122
|
-
const {
|
|
123
|
-
classNameList,
|
|
124
|
-
classNameListInline,
|
|
125
|
-
} = useCartContext();
|
|
126
|
-
const { cartItems, quotes = [] } = group;
|
|
127
|
-
return (
|
|
128
|
-
<div>
|
|
129
|
-
<ul className={classNameListInline}>
|
|
130
|
-
<li>
|
|
131
|
-
<strong>Shipment {groupIndex + 1} contents:</strong>
|
|
132
|
-
</li>
|
|
133
|
-
{cartItems.map((item: any, index: number) =>
|
|
134
|
-
<li key={index}>
|
|
135
|
-
{item.product.name}
|
|
136
|
-
</li>
|
|
137
|
-
)}
|
|
138
|
-
</ul>
|
|
139
|
-
{quotes.length ? (
|
|
140
|
-
<div className={classNameList}>
|
|
141
|
-
{quotes.map((q: any, i: number) =>
|
|
142
|
-
<ShipmentQuote
|
|
143
|
-
key={`${i}-group`}
|
|
144
|
-
quote={q}
|
|
145
|
-
groupIndex={groupIndex}
|
|
146
|
-
/>
|
|
147
|
-
)}
|
|
148
|
-
</div>
|
|
149
|
-
) : (
|
|
150
|
-
<NoCartShipmentOptionsFound />
|
|
151
|
-
)}
|
|
152
|
-
</div>
|
|
153
|
-
);
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
export default ShipmentGroupCard;
|
package/src/components/Table.tsx
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useCartContext } from "../CartProvider";
|
|
2
|
-
|
|
3
|
-
interface Props {
|
|
4
|
-
children: any;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export default function Table({ children }: Props) {
|
|
8
|
-
const { classNameTable } = useCartContext();
|
|
9
|
-
return (
|
|
10
|
-
<table className={classNameTable}>
|
|
11
|
-
{children}
|
|
12
|
-
</table>
|
|
13
|
-
);
|
|
14
|
-
}
|
package/src/components/Title.tsx
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
|
|
3
|
-
import { useCartContext } from '../CartProvider';
|
|
4
|
-
|
|
5
|
-
export default function Title({ icon, title }: any) {
|
|
6
|
-
const {
|
|
7
|
-
classNameCartTitle,
|
|
8
|
-
} = useCartContext();
|
|
9
|
-
return (
|
|
10
|
-
<div className={classNameCartTitle}>
|
|
11
|
-
{typeof icon === 'string' ? (
|
|
12
|
-
<i className={`${icon} fa-2x`}></i>
|
|
13
|
-
) : (
|
|
14
|
-
<FontAwesomeIcon icon={icon} size='2x' />
|
|
15
|
-
)}
|
|
16
|
-
<br />
|
|
17
|
-
<div style={{ marginTop: '1rem' }}>
|
|
18
|
-
<strong>{title}</strong>
|
|
19
|
-
</div>
|
|
20
|
-
</div>
|
|
21
|
-
);
|
|
22
|
-
}
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
|
|
3
|
-
interface CheckoutContainerProps {
|
|
4
|
-
children: any;
|
|
5
|
-
textAlign?: any;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function CheckoutContainer({ children, textAlign = 'center' }: CheckoutContainerProps) {
|
|
9
|
-
return (
|
|
10
|
-
<div
|
|
11
|
-
style={{
|
|
12
|
-
display: 'flex',
|
|
13
|
-
justifyContent: 'center',
|
|
14
|
-
textAlign: textAlign,
|
|
15
|
-
}}
|
|
16
|
-
>
|
|
17
|
-
{children}
|
|
18
|
-
</div>
|
|
19
|
-
);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
interface InnerProps {
|
|
23
|
-
children: any;
|
|
24
|
-
paddingBottom?: string;
|
|
25
|
-
paddingTop?: string;
|
|
26
|
-
width?: number;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export function InnerContainer({ children, paddingBottom, paddingTop, width = 400 }: InnerProps) {
|
|
30
|
-
return (
|
|
31
|
-
<div style={{
|
|
32
|
-
padding: '3rem',
|
|
33
|
-
paddingBottom: paddingBottom,
|
|
34
|
-
paddingTop: paddingTop,
|
|
35
|
-
width: width,
|
|
36
|
-
}}>
|
|
37
|
-
{children}
|
|
38
|
-
</div>
|
|
39
|
-
);
|
|
40
|
-
}
|
package/src/components/index.ts
DELETED
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import Alert from './Alert';
|
|
2
|
-
import CartBody from './CartBody';
|
|
3
|
-
import CartFooter from './CartFooter';
|
|
4
|
-
import CartPaymentSettingsInvalid from './CartPaymentSettingsInvalid';
|
|
5
|
-
import CartTabContent from './CartTabContent';
|
|
6
|
-
import CartTableContainer from './CartTableContainer';
|
|
7
|
-
import CartTabPanel from './CartTabPanel';
|
|
8
|
-
import Collapse from './Collapse';
|
|
9
|
-
import LoadingTemplate, { LoadingTemplateSm } from './LoadingTemplate';
|
|
10
|
-
import NoCartItems from './NoCartItems';
|
|
11
|
-
import ShipmentGroupCard from './ShipmentGroupCard';
|
|
12
|
-
import Table from './Table';
|
|
13
|
-
import Title from './Title';
|
|
14
|
-
|
|
15
|
-
export {
|
|
16
|
-
Alert,
|
|
17
|
-
CartBody,
|
|
18
|
-
CartFooter,
|
|
19
|
-
CartPaymentSettingsInvalid,
|
|
20
|
-
CartTabContent,
|
|
21
|
-
CartTableContainer,
|
|
22
|
-
CartTabPanel,
|
|
23
|
-
Collapse,
|
|
24
|
-
LoadingTemplate,
|
|
25
|
-
LoadingTemplateSm,
|
|
26
|
-
NoCartItems,
|
|
27
|
-
ShipmentGroupCard,
|
|
28
|
-
Table,
|
|
29
|
-
Title,
|
|
30
|
-
};
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import { useForm } from 'react-hook-form';
|
|
3
|
-
import { useSelector } from 'react-redux';
|
|
4
|
-
import InputAcceptUserTermsAndConditions from './InputAcceptUserTermsAndConditions';
|
|
5
|
-
import { actionCreateNewCustomer } from '../store';
|
|
6
|
-
import { Button } from '../buttons';
|
|
7
|
-
import InputSelect from './InputSelect';
|
|
8
|
-
import InputText from './InputText';
|
|
9
|
-
import { useCartContext } from '../CartProvider';
|
|
10
|
-
import { phoneOptions } from '../utilities/helpers';
|
|
11
|
-
import InputError from './InputError';
|
|
12
|
-
|
|
13
|
-
export const emailValidation = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]/i;
|
|
14
|
-
|
|
15
|
-
export function FormCustomerNew() {
|
|
16
|
-
const {
|
|
17
|
-
classNameBtnPrimary,
|
|
18
|
-
classNameCartFormGroup,
|
|
19
|
-
showUserTermsAndConditions,
|
|
20
|
-
urlApi,
|
|
21
|
-
} = useCartContext();
|
|
22
|
-
const {
|
|
23
|
-
creatingNewCustomer: loading,
|
|
24
|
-
serverError: error,
|
|
25
|
-
} = useSelector((s: any) => s.stateNewCustomerForm);
|
|
26
|
-
const [acceptConditions, setAcceptConditions] = React.useState(true);
|
|
27
|
-
|
|
28
|
-
const { control, handleSubmit, watch } = useForm({
|
|
29
|
-
defaultValues: {
|
|
30
|
-
emailAddresses: [{ emailAddress: '' }],
|
|
31
|
-
name: '',
|
|
32
|
-
phoneNumbers: [{ code: 'AU', number: '' }],
|
|
33
|
-
registeredAsGuest: false,
|
|
34
|
-
},
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
async function onSubmit(values: any) {
|
|
38
|
-
await actionCreateNewCustomer((urlApi as string), { ...values });
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// Basic validation for phone. Checking that phone is a number. Can make more complex if we want.
|
|
42
|
-
function validatePhone() {
|
|
43
|
-
const phone = watch('phoneNumbers.0.number');
|
|
44
|
-
if (isNaN(phone as any)) return 'Phone number must be a number';
|
|
45
|
-
else return true;
|
|
46
|
-
}
|
|
47
|
-
return (
|
|
48
|
-
<form onSubmit={handleSubmit(onSubmit)}>
|
|
49
|
-
<InputText
|
|
50
|
-
control={control}
|
|
51
|
-
label='Full Name'
|
|
52
|
-
name='name'
|
|
53
|
-
placeholder='John Smith'
|
|
54
|
-
rules={{ required: 'Full name is required.' }}
|
|
55
|
-
/>
|
|
56
|
-
<InputText
|
|
57
|
-
control={control}
|
|
58
|
-
label='Email'
|
|
59
|
-
name='emailAddresses[0].emailAddress'
|
|
60
|
-
placeholder='john@example.com'
|
|
61
|
-
rules={{
|
|
62
|
-
required: 'Email is required.',
|
|
63
|
-
validate: emailValidation,
|
|
64
|
-
}}
|
|
65
|
-
/>
|
|
66
|
-
<div style={{ display: 'flex', gap: '1rem' }}>
|
|
67
|
-
<div style={{ flexGrow: 1 }}>
|
|
68
|
-
<InputSelect
|
|
69
|
-
control={control}
|
|
70
|
-
label='Country Code'
|
|
71
|
-
name='phoneNumbers[0].code'
|
|
72
|
-
options={phoneOptions}
|
|
73
|
-
/>
|
|
74
|
-
</div>
|
|
75
|
-
<div style={{ flexGrow: 1 }}>
|
|
76
|
-
<InputText
|
|
77
|
-
control={control}
|
|
78
|
-
label='Phone Number'
|
|
79
|
-
name='phoneNumbers[0].number'
|
|
80
|
-
placeholder='0400 000 000'
|
|
81
|
-
rules={{
|
|
82
|
-
required: 'Phone number is required',
|
|
83
|
-
validate: validatePhone,
|
|
84
|
-
}}
|
|
85
|
-
type='phone'
|
|
86
|
-
/>
|
|
87
|
-
</div>
|
|
88
|
-
</div>
|
|
89
|
-
{showUserTermsAndConditions && (
|
|
90
|
-
<div className={classNameCartFormGroup}>
|
|
91
|
-
<InputAcceptUserTermsAndConditions
|
|
92
|
-
isChecked={acceptConditions}
|
|
93
|
-
setIsChecked={setAcceptConditions}
|
|
94
|
-
/>
|
|
95
|
-
{!acceptConditions && (
|
|
96
|
-
<InputError
|
|
97
|
-
error={{
|
|
98
|
-
message:
|
|
99
|
-
'You must agree to the user profile terms and conditions to proceed.',
|
|
100
|
-
}}
|
|
101
|
-
/>
|
|
102
|
-
)}
|
|
103
|
-
</div>
|
|
104
|
-
)}
|
|
105
|
-
<InputError error={error || {}} />
|
|
106
|
-
<div className={classNameCartFormGroup}>
|
|
107
|
-
<Button
|
|
108
|
-
className={classNameBtnPrimary}
|
|
109
|
-
disabled={loading}
|
|
110
|
-
type='submit'
|
|
111
|
-
>
|
|
112
|
-
{loading ? 'Loading...' : 'Submit'}
|
|
113
|
-
</Button>
|
|
114
|
-
</div>
|
|
115
|
-
</form>
|
|
116
|
-
);
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
export default FormCustomerNew;
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import { useSelector } from 'react-redux';
|
|
2
|
-
import { useForm } from 'react-hook-form';
|
|
3
|
-
import { tryReturningCustomer } from '../store';
|
|
4
|
-
import { Button } from '../buttons';
|
|
5
|
-
import InputError from './InputError';
|
|
6
|
-
import { useCartContext } from '../CartProvider';
|
|
7
|
-
|
|
8
|
-
const emailValidation = /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]/i;
|
|
9
|
-
|
|
10
|
-
function FormReturningCustomer() {
|
|
11
|
-
const {
|
|
12
|
-
classNameBtnPrimary,
|
|
13
|
-
classNameCartFormGroup,
|
|
14
|
-
classNameCartFormInput,
|
|
15
|
-
urlApi
|
|
16
|
-
} = useCartContext();
|
|
17
|
-
const {
|
|
18
|
-
returningCustomerError,
|
|
19
|
-
returningCustomerLoading,
|
|
20
|
-
} = useSelector((s: any) => s.stateFormReturningCustomer);
|
|
21
|
-
const hookForm = useForm({ defaultValues: { emailAddress: '' } });
|
|
22
|
-
const {
|
|
23
|
-
handleSubmit,
|
|
24
|
-
formState: { errors },
|
|
25
|
-
getValues,
|
|
26
|
-
register,
|
|
27
|
-
} = hookForm;
|
|
28
|
-
async function submit() {
|
|
29
|
-
const values = getValues();
|
|
30
|
-
await tryReturningCustomer(
|
|
31
|
-
(urlApi as string),
|
|
32
|
-
values.emailAddress
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
return (
|
|
36
|
-
<form onSubmit={handleSubmit(submit)}>
|
|
37
|
-
<div className={classNameCartFormGroup}>
|
|
38
|
-
<input
|
|
39
|
-
className={classNameCartFormInput}
|
|
40
|
-
placeholder='info@example.com'
|
|
41
|
-
type='email'
|
|
42
|
-
{...register('emailAddress', {
|
|
43
|
-
required: 'Email address required',
|
|
44
|
-
pattern: {
|
|
45
|
-
value: emailValidation,
|
|
46
|
-
message: 'Invalid email address'
|
|
47
|
-
}
|
|
48
|
-
})}
|
|
49
|
-
/>
|
|
50
|
-
<small>
|
|
51
|
-
If you are a returning customer please use the same email
|
|
52
|
-
which you used previously.
|
|
53
|
-
</small>
|
|
54
|
-
<InputError error={errors.emailAddress} />
|
|
55
|
-
{returningCustomerError && <InputError error={returningCustomerError} />}
|
|
56
|
-
</div>
|
|
57
|
-
<div className={classNameCartFormGroup}>
|
|
58
|
-
<Button
|
|
59
|
-
className={classNameBtnPrimary}
|
|
60
|
-
disabled={returningCustomerLoading}
|
|
61
|
-
type='submit'
|
|
62
|
-
>
|
|
63
|
-
{returningCustomerLoading ? 'Loading...' : 'Submit'}
|
|
64
|
-
</Button>
|
|
65
|
-
</div>
|
|
66
|
-
</form>
|
|
67
|
-
);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export default FormReturningCustomer;
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { useDispatch, useSelector } from 'react-redux';
|
|
2
|
-
import { useForm } from 'react-hook-form';
|
|
3
|
-
import InputsAddress from './InputsAddress';
|
|
4
|
-
import {
|
|
5
|
-
CheckoutContainer,
|
|
6
|
-
InnerContainer,
|
|
7
|
-
} from '../components/containers';
|
|
8
|
-
import { Title } from '../components';
|
|
9
|
-
import {
|
|
10
|
-
updateCartShipmentAddress,
|
|
11
|
-
saveCartShipmentAddressAndGoToNextTab,
|
|
12
|
-
} from '../store';
|
|
13
|
-
import { shipmentFormId, sliceCartShipment } from '../slices/sliceCartShipment';
|
|
14
|
-
import { faMapMarkerAlt } from '@fortawesome/free-solid-svg-icons';
|
|
15
|
-
import { useCartContext } from '../CartProvider';
|
|
16
|
-
|
|
17
|
-
interface PropsAddress {
|
|
18
|
-
defaultAddress?: any;
|
|
19
|
-
labelGeoSuggest?: string;
|
|
20
|
-
hookForm: any;
|
|
21
|
-
name?: string;
|
|
22
|
-
placeholder?: string;
|
|
23
|
-
updateAddress: (address: any) => void;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
const AddressGeoSuggestInput = (props: PropsAddress) => (
|
|
27
|
-
<InputsAddress {...props} name='receiverAddress' />
|
|
28
|
-
);
|
|
29
|
-
|
|
30
|
-
interface Props {
|
|
31
|
-
address?: any;
|
|
32
|
-
addressFieldsOpen: boolean;
|
|
33
|
-
formId: string;
|
|
34
|
-
notes?: string;
|
|
35
|
-
showIcon?: boolean;
|
|
36
|
-
deliveryNomenclature?: boolean;
|
|
37
|
-
showHeadings?: boolean;
|
|
38
|
-
setCartShipmentAddress: (values: any) => void;
|
|
39
|
-
toggleAddressFields: () => void;
|
|
40
|
-
updateCartShipmentAddress: (address: any) => void;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
function FormShipmentAddressAndNotes({
|
|
44
|
-
address = {},
|
|
45
|
-
formId,
|
|
46
|
-
notes = '',
|
|
47
|
-
showIcon = true,
|
|
48
|
-
deliveryNomenclature = false,
|
|
49
|
-
showHeadings = true,
|
|
50
|
-
setCartShipmentAddress,
|
|
51
|
-
updateCartShipmentAddress,
|
|
52
|
-
}: Props) {
|
|
53
|
-
const { classNameCartFormGroup } = useCartContext();
|
|
54
|
-
const hookForm = useForm({
|
|
55
|
-
defaultValues: {
|
|
56
|
-
receiverAddress: address,
|
|
57
|
-
receiverNotes: notes,
|
|
58
|
-
},
|
|
59
|
-
});
|
|
60
|
-
const {
|
|
61
|
-
getValues,
|
|
62
|
-
handleSubmit,
|
|
63
|
-
register,
|
|
64
|
-
reset,
|
|
65
|
-
} = hookForm;
|
|
66
|
-
|
|
67
|
-
function onSubmit() {
|
|
68
|
-
setCartShipmentAddress(getValues());
|
|
69
|
-
}
|
|
70
|
-
function updateAddress(addr: any) {
|
|
71
|
-
const oldAddresses: any = getValues();
|
|
72
|
-
const newAddress = addr ? {...addr} : {};
|
|
73
|
-
oldAddresses['receiverAddress'] = newAddress;
|
|
74
|
-
reset(oldAddresses);
|
|
75
|
-
updateCartShipmentAddress(newAddress)
|
|
76
|
-
}
|
|
77
|
-
return (
|
|
78
|
-
<form
|
|
79
|
-
id={formId}
|
|
80
|
-
onSubmit={handleSubmit(onSubmit)}
|
|
81
|
-
>
|
|
82
|
-
{showHeadings &&
|
|
83
|
-
<CheckoutContainer>
|
|
84
|
-
<InnerContainer paddingBottom='1rem'>
|
|
85
|
-
<Title
|
|
86
|
-
icon={showIcon ? faMapMarkerAlt : null}
|
|
87
|
-
Title='Delivery / billing address'
|
|
88
|
-
/>
|
|
89
|
-
</InnerContainer>
|
|
90
|
-
</CheckoutContainer>
|
|
91
|
-
}
|
|
92
|
-
<AddressGeoSuggestInput
|
|
93
|
-
defaultAddress={address}
|
|
94
|
-
hookForm={hookForm}
|
|
95
|
-
labelGeoSuggest={`Enter your ${deliveryNomenclature ? 'delivery' : 'shipping'} address`}
|
|
96
|
-
name='receiverAddress'
|
|
97
|
-
updateAddress={updateAddress}
|
|
98
|
-
/>
|
|
99
|
-
<div className={classNameCartFormGroup}>
|
|
100
|
-
<label>{deliveryNomenclature ? 'Delivery' : 'Shipment'} notes</label>
|
|
101
|
-
<textarea
|
|
102
|
-
className='form-control input'
|
|
103
|
-
defaultValue={notes}
|
|
104
|
-
placeholder='Example - Leave at top of stairs'
|
|
105
|
-
rows={4}
|
|
106
|
-
{...register('receiverNotes')}
|
|
107
|
-
>
|
|
108
|
-
</textarea>
|
|
109
|
-
</div>
|
|
110
|
-
</form>
|
|
111
|
-
);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export function ActiveFormShipmentAddressAndNotes() {
|
|
115
|
-
const dispatch = useDispatch();
|
|
116
|
-
const {
|
|
117
|
-
addressFieldsOpen,
|
|
118
|
-
receiverAddress,
|
|
119
|
-
receiverNotes,
|
|
120
|
-
} = useSelector((s: any) => s.stateCartShipment);
|
|
121
|
-
function toggleAddressFieldsOpen() {
|
|
122
|
-
dispatch(sliceCartShipment.actions.toggleAddressFields());
|
|
123
|
-
}
|
|
124
|
-
function actionUpdateCartShipmentAddress(address: any) {
|
|
125
|
-
dispatch(sliceCartShipment.actions.
|
|
126
|
-
updateShipmentAddress(address));
|
|
127
|
-
updateCartShipmentAddress();
|
|
128
|
-
}
|
|
129
|
-
return (
|
|
130
|
-
<FormShipmentAddressAndNotes
|
|
131
|
-
address={receiverAddress}
|
|
132
|
-
addressFieldsOpen={addressFieldsOpen}
|
|
133
|
-
formId={shipmentFormId}
|
|
134
|
-
notes={receiverNotes}
|
|
135
|
-
setCartShipmentAddress={saveCartShipmentAddressAndGoToNextTab}
|
|
136
|
-
toggleAddressFields={toggleAddressFieldsOpen}
|
|
137
|
-
updateCartShipmentAddress={actionUpdateCartShipmentAddress}
|
|
138
|
-
/>
|
|
139
|
-
);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
export default FormShipmentAddressAndNotes;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useSelector } from 'react-redux';
|
|
2
|
-
import SquareCard from '../square/SquareCard';
|
|
3
|
-
|
|
4
|
-
function FormSquarePayment() {
|
|
5
|
-
const { cart } = useSelector((s: any) => s.stateCart);
|
|
6
|
-
const company = cart && cart.domain && cart.domain.company;
|
|
7
|
-
return (
|
|
8
|
-
<>
|
|
9
|
-
{Boolean(company) && company.acceptSquare && <SquareCard />}
|
|
10
|
-
</>
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default FormSquarePayment;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { useSelector } from 'react-redux';
|
|
2
|
-
import StripeCardForm from '../stripe/StripeCardForm';
|
|
3
|
-
|
|
4
|
-
function FormStripePayment() {
|
|
5
|
-
const { cart } = useSelector((s: any) => s.stateCart);
|
|
6
|
-
const company = cart && cart.domain && cart.domain.company;
|
|
7
|
-
return (
|
|
8
|
-
<>
|
|
9
|
-
{Boolean(company) && <StripeCardForm />}
|
|
10
|
-
</>
|
|
11
|
-
);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export default FormStripePayment;
|