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.
Files changed (90) hide show
  1. package/package.json +3 -4
  2. package/src/Cart.tsx +0 -100
  3. package/src/CartAlert.tsx +0 -34
  4. package/src/CartHeader.tsx +0 -27
  5. package/src/CartProvider.tsx +0 -386
  6. package/src/CartTotals.tsx +0 -106
  7. package/src/assets/merchi-monster-loader.gif +0 -0
  8. package/src/assets/merchi-swipe-outline.png +0 -0
  9. package/src/assets/product-not-found.png +0 -0
  10. package/src/buttons/Button.tsx +0 -35
  11. package/src/buttons/ButtonBack.tsx +0 -37
  12. package/src/buttons/ButtonClearCart.tsx +0 -18
  13. package/src/buttons/ButtonInvoiceDownload.tsx +0 -63
  14. package/src/buttons/ButtonNext.tsx +0 -38
  15. package/src/buttons/ButtonNextDynamic.tsx +0 -31
  16. package/src/buttons/ButtonPay.tsx +0 -32
  17. package/src/buttons/ButtonShipmentTabNext.tsx +0 -25
  18. package/src/buttons/index.ts +0 -15
  19. package/src/components/Alert.tsx +0 -31
  20. package/src/components/CartBody.tsx +0 -16
  21. package/src/components/CartClient.tsx +0 -48
  22. package/src/components/CartFooter.tsx +0 -15
  23. package/src/components/CartItemRow.tsx +0 -145
  24. package/src/components/CartPaymentSettingsInvalid.tsx +0 -12
  25. package/src/components/CartShipment.tsx +0 -55
  26. package/src/components/CartTabContent.tsx +0 -15
  27. package/src/components/CartTabPanel.tsx +0 -25
  28. package/src/components/CartTableContainer.tsx +0 -15
  29. package/src/components/Collapse.tsx +0 -23
  30. package/src/components/LoadingTemplate.tsx +0 -22
  31. package/src/components/NoCartItems.tsx +0 -15
  32. package/src/components/ShipmentGroupCard.tsx +0 -156
  33. package/src/components/Table.tsx +0 -14
  34. package/src/components/Title.tsx +0 -22
  35. package/src/components/containers.tsx +0 -40
  36. package/src/components/index.ts +0 -30
  37. package/src/forms/FormNewCustomer.tsx +0 -119
  38. package/src/forms/FormReturningCustomer.tsx +0 -70
  39. package/src/forms/FormShipmentAddressAndNotes.tsx +0 -142
  40. package/src/forms/FormSquarePayment.tsx +0 -14
  41. package/src/forms/FormStripePayment.tsx +0 -14
  42. package/src/forms/InputAcceptUserTermsAndConditions.tsx +0 -43
  43. package/src/forms/InputError.tsx +0 -23
  44. package/src/forms/InputSelect.tsx +0 -58
  45. package/src/forms/InputText.tsx +0 -56
  46. package/src/forms/InputsAddress.tsx +0 -205
  47. package/src/index.tsx +0 -13
  48. package/src/panels/PanelCartItems.tsx +0 -61
  49. package/src/panels/PanelCartShipment.tsx +0 -89
  50. package/src/panels/PanelClearCart.tsx +0 -47
  51. package/src/panels/PanelClientCheckout.tsx +0 -92
  52. package/src/panels/PanelEditCartItem.tsx +0 -58
  53. package/src/panels/PanelPaymentSuccess.tsx +0 -69
  54. package/src/panels/index.ts +0 -15
  55. package/src/slices/sliceCart.ts +0 -159
  56. package/src/slices/sliceCartAlert.ts +0 -39
  57. package/src/slices/sliceCartItem.ts +0 -29
  58. package/src/slices/sliceCartPayment.ts +0 -45
  59. package/src/slices/sliceCartShipment.ts +0 -67
  60. package/src/slices/sliceFormReturningCustomer.ts +0 -25
  61. package/src/slices/sliceNewCustomerForm.ts +0 -24
  62. package/src/square/SquareCard.tsx +0 -58
  63. package/src/square/actions.ts +0 -40
  64. package/src/square/slices/reducersSquare.ts +0 -9
  65. package/src/square/slices/sliceSquareAlerts.ts +0 -29
  66. package/src/square/slices/sliceSquareForm.ts +0 -29
  67. package/src/store.ts +0 -499
  68. package/src/stripe/StripeCardFields.tsx +0 -164
  69. package/src/stripe/StripeCardForm.tsx +0 -86
  70. package/src/stripe/StripePaymentButtons.tsx +0 -117
  71. package/src/stripe/actions.ts +0 -94
  72. package/src/stripe/slices/sliceStripeAlerts.ts +0 -29
  73. package/src/stripe/slices/sliceStripeCardForm.ts +0 -9
  74. package/src/stripe/slices/sliceStripeForm.ts +0 -56
  75. package/src/stripe/utils.ts +0 -21
  76. package/src/styles/globals.css +0 -191
  77. package/src/styles/globals.css.map +0 -1
  78. package/src/styles/globals.scss +0 -197
  79. package/src/tabs/CartNav.tsx +0 -20
  80. package/src/tabs/NavTab.tsx +0 -38
  81. package/src/utilities/address.ts +0 -351
  82. package/src/utilities/cart.ts +0 -73
  83. package/src/utilities/company.ts +0 -8
  84. package/src/utilities/cookie.ts +0 -54
  85. package/src/utilities/currency.ts +0 -216
  86. package/src/utilities/helpers.ts +0 -209
  87. package/src/utilities/invoice.ts +0 -60
  88. package/src/utilities/product.ts +0 -7
  89. package/src/utilities/user.ts +0 -38
  90. package/src/utilities/variations.ts +0 -56
@@ -1,35 +0,0 @@
1
- import * as React from 'react';
2
- import { useCartContext } from "../CartProvider";
3
-
4
- interface Props {
5
- children: any;
6
- className?: string;
7
- disabled?: boolean;
8
- form?: string;
9
- onClick?: () => void;
10
- type?: string;
11
- }
12
-
13
- type ButtonType = "button" | "reset" | "submit" | undefined;
14
-
15
- export default function Button({
16
- children,
17
- className = '',
18
- disabled,
19
- form,
20
- onClick,
21
- type = 'button',
22
- }: Props) {
23
- const { classNameBtn } = useCartContext();
24
- return (
25
- <button
26
- className={`${classNameBtn} ${className}`}
27
- disabled={disabled}
28
- form={form}
29
- onClick={onClick}
30
- type={(type as ButtonType)}
31
- >
32
- {children}
33
- </button>
34
- );
35
- }
@@ -1,37 +0,0 @@
1
- import * as React from 'react';
2
- import { useSelector } from 'react-redux';
3
- import { useCartContext } from '../CartProvider';
4
- import { setActiveTab } from '../store';
5
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
6
- import { faArrowLeft } from '@fortawesome/free-solid-svg-icons';
7
- import Button from './Button';
8
-
9
- interface Props {
10
- text?: string;
11
- }
12
-
13
- function ButtonBack({ text }: Props) {
14
- const { classNameBtnBack, onClickClose } = useCartContext();
15
- const { activeTab, tabs } = useSelector((s: any) => s.stateCart);
16
- const currentTabIndex = tabs.findIndex((t: any) => t.tabId === activeTab);
17
- let nextTab = null;
18
- if (currentTabIndex > 0) {
19
- nextTab = tabs[currentTabIndex - 1];
20
- }
21
- const nextTabId = nextTab ? nextTab.tabId : 0;
22
- return (
23
- <Button
24
- className={classNameBtnBack}
25
- onClick={activeTab === 0 ?
26
- onClickClose
27
- :
28
- () => setActiveTab(nextTabId)
29
- }
30
- >
31
- <FontAwesomeIcon icon={faArrowLeft} />
32
- {text ? ` ${text}` : ''}
33
- </Button>
34
- );
35
- }
36
-
37
- export default ButtonBack;
@@ -1,18 +0,0 @@
1
- import { useCartContext } from '../CartProvider';
2
- import { tabIdClearCart } from '../slices/sliceCart';
3
- import { setActiveTab } from '../store';
4
- import Button from './Button';
5
-
6
- function ButtonClearCart() {
7
- const { classNameBtnCartClear } = useCartContext();
8
- return (
9
- <Button
10
- className={classNameBtnCartClear}
11
- onClick={() => setActiveTab(tabIdClearCart)}
12
- >
13
- Clear cart
14
- </Button>
15
- );
16
- }
17
-
18
- export default ButtonClearCart;
@@ -1,63 +0,0 @@
1
- import * as React from 'react';
2
- import { useSelector } from 'react-redux';
3
- import { useCartContext } from '../CartProvider';
4
- import { generatePublicInvoicePdf } from '../utilities/invoice';
5
- import { useState } from 'react';
6
- import { CgSpinner } from 'react-icons/cg';
7
- import { FaFileInvoiceDollar } from 'react-icons/fa';
8
- import { alertError } from '../store';
9
-
10
- function ButtonInvoiceDownload() {
11
- const {
12
- classNameBtnDownloadInvoice,
13
- urlApi,
14
- } = useCartContext();
15
- const {
16
- invoice = {},
17
- } = useSelector((s: any) => s.stateCartPayment);
18
- const { unpaid } = invoice;
19
- const [loading, setLoading] = useState(false);
20
- async function generate(receipt?: boolean) {
21
- setLoading(true);
22
- try {
23
- await generatePublicInvoicePdf((urlApi as string), invoice, receipt);
24
- setLoading(false);
25
- } catch (e: any) {
26
- alertError(e.message);
27
- setLoading(false);
28
- }
29
- }
30
- return (
31
- <>
32
- {unpaid ? (
33
- <button
34
- className={classNameBtnDownloadInvoice}
35
- disabled={loading}
36
- onClick={() => generate(false)}
37
- >
38
- {loading ? (
39
- <CgSpinner fontSize='1.1rem' className='animate_spin mr-2' />
40
- ) : (
41
- <FaFileInvoiceDollar fontSize='1.1rem' className='mr-2' />
42
- )}
43
- Download Invoice
44
- </button>
45
- ) : (
46
- <button
47
- className={classNameBtnDownloadInvoice}
48
- disabled={loading}
49
- onClick={() => generate(true)}
50
- >
51
- {loading ? (
52
- <CgSpinner fontSize='1.1rem' className='animate_spin mr-2' />
53
- ) : (
54
- <FaFileInvoiceDollar fontSize='1.1rem' className='mr-2' />
55
- )}
56
- Download Receipt
57
- </button>
58
- )}
59
- </>
60
- );
61
- }
62
-
63
- export default ButtonInvoiceDownload;
@@ -1,38 +0,0 @@
1
- import * as React from 'react';
2
- import { useSelector } from 'react-redux';
3
- import { tabIdCheckout } from '../slices/sliceCart';
4
- import { setActiveTab } from '../store';
5
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
6
- import { faArrowRight, faCircleNotch, faCreditCard } from '@fortawesome/free-solid-svg-icons';
7
- import Button from './Button';
8
- import { useCartContext } from '../CartProvider';
9
-
10
- function ButtonNext() {
11
- const {
12
- classNameBtnNext,
13
- classNameBtnNextComplete,
14
- } = useCartContext();
15
- const {
16
- activeTab,
17
- loading,
18
- tabs,
19
- } = useSelector((s: any) => s.stateCart);
20
- const currentTabIndex = tabs.findIndex((t: any) => t.tabId === activeTab);
21
- const nextTab = tabs[currentTabIndex + 1];
22
- const isCheckoutTabOpen = activeTab === tabIdCheckout;
23
- const icon = loading ? faCircleNotch : isCheckoutTabOpen ? faCreditCard : faArrowRight;
24
- return (
25
- <Button
26
- className={isCheckoutTabOpen ? classNameBtnNextComplete : classNameBtnNext}
27
- onClick={nextTab ? () => setActiveTab(nextTab.tabId) : undefined}
28
- disabled={loading}
29
- >
30
- <FontAwesomeIcon icon={icon} spin={loading} />
31
- <span style={{marginLeft: '5px'}}>
32
- {loading ? 'Loading...' : 'Next'}
33
- </span>
34
- </Button>
35
- );
36
- }
37
-
38
- export default ButtonNext;
@@ -1,31 +0,0 @@
1
- import * as React from 'react';
2
- import { useSelector } from 'react-redux';
3
- import {
4
- tabIdCheckout,
5
- tabIdItems,
6
- tabIdPaymentSuccess,
7
- tabIdShipment,
8
- } from '../slices/sliceCart';
9
- import ButtonNext from './ButtonNext';
10
- import ButtonShipmentTabNext from './ButtonShipmentTabNext';
11
-
12
- function ButtonNextDynamic() {
13
- const { cart, activeTab } = useSelector((s: any) => s.stateCart);
14
- const cartItems = cart.cartItems;
15
- const hasCartItems = cartItems && cartItems.length;
16
- const isCartItemsTabActive = activeTab === tabIdItems;
17
- const isShipmentTabActive = activeTab === tabIdShipment;
18
- const isCheckoutTabOpen = activeTab === tabIdCheckout;
19
- const isPaymentSuccessOpen = activeTab === tabIdPaymentSuccess;
20
- return isCheckoutTabOpen || isPaymentSuccessOpen ? (
21
- <></>
22
- ) : isShipmentTabActive ? (
23
- <ButtonShipmentTabNext />
24
- ) : isCartItemsTabActive && !hasCartItems ? (
25
- <></>
26
- ) : (
27
- <ButtonNext />
28
- );
29
- }
30
-
31
- export default ButtonNextDynamic;
@@ -1,32 +0,0 @@
1
- import * as React from 'react';
2
- import { useCartContext } from '../CartProvider';
3
- import { currencyMap } from '../utilities/currency';
4
- import Button from './Button';
5
-
6
- interface Props {
7
- cart: any;
8
- loading: boolean;
9
- }
10
-
11
- function ButtonPay({ cart, loading }: Props) {
12
- const { classNameBtnPay } = useCartContext();
13
- const { currency, totalCost } = cart;
14
- return (
15
- <Button
16
- className={classNameBtnPay}
17
- disabled={loading}
18
- type='submit'
19
- >
20
- {loading ? (
21
- <span>Loading...</span>
22
- ) : (
23
- <span>
24
- Pay {currencyMap[currency]}
25
- {totalCost}<small> / inc tax</small>
26
- </span>
27
- )}
28
- </Button>
29
- );
30
- }
31
-
32
- export default ButtonPay;
@@ -1,25 +0,0 @@
1
- import * as React from 'react';
2
- import { useSelector } from 'react-redux';
3
- import { shipmentFormId } from '../slices/sliceCartShipment';
4
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
5
- import { faArrowRight, faCircleNotch } from '@fortawesome/free-solid-svg-icons';
6
- import Button from './Button';
7
- import { useCartContext } from '../CartProvider';
8
-
9
- export default function ButtonShipmentTabNext() {
10
- const { classNameBtnNext } = useCartContext();
11
- const { savingShipmentAddress } = useSelector((s: any) => s.stateCartShipment);
12
- const icon = savingShipmentAddress ? faCircleNotch : faArrowRight;
13
- return (
14
- <Button
15
- className={classNameBtnNext}
16
- form={shipmentFormId}
17
- disabled={savingShipmentAddress}
18
- >
19
- <FontAwesomeIcon icon={icon} spin={savingShipmentAddress} />
20
- <span style={{marginLeft: '5px'}}>
21
- {savingShipmentAddress ? 'Loading...' : 'Next'}
22
- </span>
23
- </Button>
24
- );
25
- }
@@ -1,15 +0,0 @@
1
- import Button from './Button';
2
- import ButtonBack from './ButtonBack';
3
- import ButtonClearCart from './ButtonClearCart';
4
- import ButtonInvoiceDownload from './ButtonInvoiceDownload';
5
- import ButtonNextDynamic from './ButtonNextDynamic';
6
- import ButtonPay from './ButtonPay';
7
-
8
- export {
9
- Button,
10
- ButtonBack,
11
- ButtonClearCart,
12
- ButtonNextDynamic,
13
- ButtonPay,
14
- ButtonInvoiceDownload,
15
- };
@@ -1,31 +0,0 @@
1
- import * as React from 'react';
2
- import { useCartContext } from '../CartProvider';
3
-
4
- interface Props {
5
- alertType?: 'success' | 'danger' | 'warning' | 'info';
6
- children: any;
7
- }
8
-
9
- export default function Alert({ alertType, children }: Props) {
10
- const {
11
- classNameAlertError,
12
- classNameAlertInfo,
13
- classNameAlertSuccess,
14
- classNameAlertWarning,
15
- } = useCartContext();
16
- let className = classNameAlertInfo;
17
- if (alertType === 'success') {
18
- className = classNameAlertSuccess;
19
- }
20
- if (alertType === 'danger') {
21
- className = classNameAlertError;
22
- }
23
- if (alertType === 'warning') {
24
- className = classNameAlertWarning;
25
- }
26
- return (
27
- <div className={className}>
28
- {children}
29
- </div>
30
- );
31
- }
@@ -1,16 +0,0 @@
1
- import * as React from 'react';
2
- import { useCartContext } from '../CartProvider';
3
-
4
- interface Props {
5
- children: any;
6
- style?: any;
7
- }
8
-
9
- export default function CartBody({ children, style }: Props) {
10
- const { classNameCartBody } = useCartContext();
11
- return (
12
- <div className={classNameCartBody} style={style}>
13
- {children}
14
- </div>
15
- );
16
- }
@@ -1,48 +0,0 @@
1
- import * as React from 'react';
2
- import { useDispatch } from 'react-redux';
3
- import { axtionSetCartClient } from '../store';
4
- import {
5
- primaryEmail,
6
- primaryPhone,
7
- } from '../utilities/user';
8
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
9
- import { faUserCircle, faUserTimes } from '@fortawesome/free-solid-svg-icons';
10
- import Button from '../buttons/Button';
11
- import Title from './Title';
12
- import { useCartContext } from '../CartProvider';
13
-
14
- export function ClientInfo({ client }: any) {
15
- const { classNameListClientInfo } = useCartContext();
16
- const { name = 'Returning customer' } = client;
17
- const emailAddress = primaryEmail(client) || 'Email not shown';
18
- const phoneNumber = primaryPhone(client) || 'Phone number not shown';
19
- return (
20
- <ul className={classNameListClientInfo}>
21
- <li>{name}</li>
22
- <li>{emailAddress}</li>
23
- <li>{phoneNumber}</li>
24
- </ul>
25
- );
26
- }
27
-
28
- interface Props {
29
- client: any;
30
- }
31
-
32
- function CartClient({ client }: Props) {
33
- const dispatch = useDispatch();
34
- function clearClient() {
35
- axtionSetCartClient(null);
36
- }
37
- return (
38
- <div>
39
- <Title icon={faUserCircle} Title='Checkout as' />
40
- <ClientInfo client={client} />
41
- <Button onClick={clearClient}>
42
- <FontAwesomeIcon icon={faUserTimes} /> Change
43
- </Button>
44
- </div>
45
- );
46
- }
47
-
48
- export default CartClient;
@@ -1,15 +0,0 @@
1
- import * as React from 'react';
2
- import { useCartContext } from "../CartProvider";
3
-
4
- interface Props {
5
- children: any;
6
- }
7
-
8
- export default function CartFooter({ children }: Props) {
9
- const { classNameCartFooter } = useCartContext();
10
- return (
11
- <div className={classNameCartFooter}>
12
- {children}
13
- </div>
14
- );
15
- }
@@ -1,145 +0,0 @@
1
- import * as React from 'react';
2
- import { cartItemCurrencyAndCost } from '../utilities/currency';
3
- import { productFeatureImageUrl } from '../utilities/product';
4
- import { valueString } from '../utilities/variations';
5
- import { actionDeleteCartItem, setCartItem } from '../store';
6
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
7
- import { faCircleNotch, faEdit, faTrashAlt } from '@fortawesome/free-solid-svg-icons';
8
- import { Button } from '../buttons';
9
- import { useCartContext } from '../CartProvider';
10
-
11
- interface VariationListItemProps {
12
- variation: any;
13
- }
14
-
15
- function VariationListItem(props: VariationListItemProps) {
16
- const { variation } = props;
17
- const { variationField: field } = variation;
18
- return (
19
- <li>{`${field.name}: ${valueString(variation)}`}</li>
20
- );
21
- }
22
-
23
- interface VariationListProps {
24
- variations: any[];
25
- }
26
-
27
- function VariationList({ variations }: VariationListProps) {
28
- const { classNameVariationsList } = useCartContext();
29
- return (
30
- <ul className={classNameVariationsList}>
31
- {variations.map((v: any, index: number) =>
32
- <VariationListItem
33
- key={`${index}-variation`}
34
- variation={v}
35
- />
36
- )}
37
- </ul>
38
- );
39
- }
40
-
41
- interface GroupVariationItemsProps {
42
- count: number;
43
- group: any;
44
- }
45
-
46
- function GroupVariationItems(props: GroupVariationItemsProps) {
47
- const { count, group } = props;
48
- return (
49
- <li>
50
- Group {count} Quantity: {group.quantity}
51
- <VariationList variations={group.variations} />
52
- </li>
53
- );
54
- }
55
-
56
- interface VariationsGroupsListProps {
57
- groups: any[];
58
- }
59
-
60
- function VariationsGroupsList({ groups }: VariationsGroupsListProps) {
61
- const { classNameVariationsList } = useCartContext();
62
- return (
63
- <ul className={classNameVariationsList}>
64
- {groups.map((group: any, index: number) =>
65
- <GroupVariationItems
66
- key={`${index}-group-variations`}
67
- group={group}
68
- count={index + 1}
69
- />
70
- )}
71
- </ul>
72
- );
73
- }
74
-
75
- interface Props {
76
- cartItem: any;
77
- index: number;
78
- loading: boolean;
79
- }
80
-
81
- function CartItemRow({ cartItem, index, loading }: Props) {
82
- const {
83
- classNameBtnLink,
84
- classNameCartItemFeatureImage,
85
- classNameCartItemInfo,
86
- classNameCartItemInfoCell,
87
- classNameCartItemInfoCellRight,
88
- classNameCartItemInfoContainer,
89
- } = useCartContext();
90
- const {
91
- product,
92
- quantity,
93
- variations,
94
- variationsGroups,
95
- } = cartItem;
96
- const { name } = product;
97
- return (
98
- <tr>
99
- <th scope='row' className={classNameCartItemInfoCell}>
100
- <img
101
- src={productFeatureImageUrl(product)}
102
- alt={name}
103
- width='70'
104
- className={classNameCartItemFeatureImage}
105
- />
106
- <div className={classNameCartItemInfoContainer}>
107
- <div className={classNameCartItemInfo}>
108
- <h5 style={{display: 'inline'}}>
109
- {name}
110
- </h5>
111
- {variations && <VariationList variations={variations} />}
112
- </div>
113
- <div className={classNameCartItemInfo}>
114
- {variationsGroups && <VariationsGroupsList groups={variationsGroups} />}
115
- </div>
116
- </div>
117
- </th>
118
- <td className={classNameCartItemInfoCellRight}>
119
- <strong>{quantity}</strong>
120
- </td>
121
- <td className={classNameCartItemInfoCellRight}>
122
- <strong>{cartItemCurrencyAndCost(cartItem)}</strong>
123
- </td>
124
- <td className={classNameCartItemInfoCellRight}>
125
- <Button
126
- className={classNameBtnLink}
127
- onClick={() => setCartItem(cartItem, index)}
128
- >
129
- <FontAwesomeIcon icon={faEdit} />
130
- </Button>
131
- <Button
132
- className={classNameBtnLink}
133
- onClick={() => actionDeleteCartItem(index)}
134
- >
135
- <FontAwesomeIcon
136
- icon={loading ? faCircleNotch : faTrashAlt}
137
- spin={loading}
138
- />
139
- </Button>
140
- </td>
141
- </tr>
142
- );
143
- }
144
-
145
- export default CartItemRow;
@@ -1,12 +0,0 @@
1
- import * as React from 'react';
2
-
3
- export default function CartPaymentSettingsInvalid() {
4
- return (
5
- <div className='merchi-loading-container'>
6
- <div className='merchi-payment-gateway-inactive' />
7
- <p className="merchi-loading-container-text">
8
- Payment gateway is currently inactive.
9
- </p>
10
- </div>
11
- );
12
- }
@@ -1,55 +0,0 @@
1
- import { useDispatch } from 'react-redux';
2
- import Title from './Title';
3
- import { sliceCart, tabIdShipment } from '../slices/sliceCart';
4
- import { addressInOneLine } from '../utilities/address';
5
- import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
6
- import { faEdit, faTruck } from '@fortawesome/free-solid-svg-icons';
7
- import { Button } from '../buttons';
8
- import { useCartContext } from '../CartProvider';
9
-
10
- interface Props {
11
- cart: any;
12
- }
13
-
14
- function CartShipment({ cart }: Props) {
15
- const {
16
- classNameBtnDefault,
17
- classNameListContainer,
18
- classNameListUnstyled,
19
- } = useCartContext();
20
- const { receiverAddress, receiverNotes } = cart;
21
- const address = receiverAddress ? receiverAddress : null;
22
- const dispatch = useDispatch();
23
- function openShipmentTab() {
24
- dispatch(sliceCart.actions.setActiveTab(tabIdShipment));
25
- }
26
- return (
27
- <div className={classNameListContainer}>
28
- <Title
29
- icon={faTruck}
30
- Title='Ship to'
31
- />
32
- <ul
33
- className={classNameListUnstyled}
34
- style={{fontSize: '15px', marginBottom: '1rem'}}
35
- >
36
- <li>
37
- <span style={{display: 'inline-block', marginLeft: 28}}>
38
- {address ? addressInOneLine(address) : 'Shipping address not set'}
39
- </span>
40
- </li>
41
- <li>
42
- {receiverNotes}
43
- </li>
44
- </ul>
45
- <Button
46
- onClick={openShipmentTab}
47
- className={classNameBtnDefault}
48
- >
49
- <FontAwesomeIcon icon={faEdit} /> {address ? ' Change' : ' Set'}
50
- </Button>
51
- </div>
52
- );
53
- }
54
-
55
- export default CartShipment;
@@ -1,15 +0,0 @@
1
- import * as React from 'react';
2
- import { useCartContext } from '../CartProvider';
3
-
4
- interface Props {
5
- children?: any;
6
- }
7
-
8
- export default function CartTabContent({ children }: Props) {
9
- const { classNameCartTab } = useCartContext();
10
- return (
11
- <div className={classNameCartTab}>
12
- {children}
13
- </div>
14
- );
15
- }
@@ -1,25 +0,0 @@
1
- import { useSelector } from 'react-redux';
2
- import { useCartContext } from '../CartProvider';
3
-
4
- interface Props {
5
- children: any;
6
- tabId: number;
7
- }
8
-
9
- export default function CartTabPanel({ children, tabId }: Props) {
10
- const { activeTab, tabs } = useSelector((s: any) => s.stateCart);
11
- const { classNameCartTabPanel } = useCartContext();
12
- const activeTabValues = tabs[activeTab];
13
- const display = tabId === -1 && activeTab === -1
14
- ? 'block'
15
- : tabId === -2 && activeTab === -2
16
- ? 'block'
17
- : activeTabValues && tabId === activeTabValues.tabId
18
- ? 'block'
19
- : 'none';
20
- return (
21
- <div className={classNameCartTabPanel} style={{ display }}>
22
- {children}
23
- </div>
24
- );
25
- }
@@ -1,15 +0,0 @@
1
- import * as React from 'react';
2
- import { useCartContext } from '../CartProvider';
3
-
4
- interface Props {
5
- children: any;
6
- }
7
-
8
- export default function CartTableContainer({ children }: Props) {
9
- const { classNameTableContainer } = useCartContext();
10
- return (
11
- <div className={classNameTableContainer}>
12
- {children}
13
- </div>
14
- );
15
- }