merchi_cart 0.0.3-c → 0.0.3-e
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/lib/Cart.js +2 -1
- package/lib/index.js +1 -1
- package/lib/panels/PanelCartItems.js +3 -4
- package/lib/panels/PanelCartShipment.js +8 -9
- package/lib/panels/PanelClientCheckout.js +6 -7
- package/lib/store.js +3 -6
- package/lib/styles/globals.css +7 -0
- package/lib/styles/globals.css.map +1 -1
- package/package.json +1 -1
package/lib/Cart.js
CHANGED
|
@@ -15,6 +15,7 @@ import { Provider, useSelector } from 'react-redux';
|
|
|
15
15
|
import { store } from './store';
|
|
16
16
|
import CartAlert from './CartAlert';
|
|
17
17
|
import CartHeader from './CartHeader';
|
|
18
|
+
import CartNav from './tabs/CartNav';
|
|
18
19
|
import CartTotals from './CartTotals';
|
|
19
20
|
import CartProvider, { useCartContext } from './CartProvider';
|
|
20
21
|
import { ButtonBack, ButtonClearCart, ButtonNextDynamic, } from './buttons';
|
|
@@ -34,7 +35,7 @@ function CartComponents() {
|
|
|
34
35
|
initMerchiCart(domainId);
|
|
35
36
|
}
|
|
36
37
|
}, [domainId, includeTheme, initialiseCart]);
|
|
37
|
-
return (_jsxs(_Fragment, { children: [_jsx(CartHeader, {}), _jsx(CartAlert, {}), fetchingCart ? (_jsx(LoadingTemplate, {})) : cartSettingsInvalid ? (_jsx(CartPaymentSettingsInvalid, {})) : (_jsxs("div", { className: 'merchi-tab-pane', children: [_jsx(PanelClearCart, {}), _jsx(PanelEditCartItem, {}), _jsx(PanelCartItems, {}), _jsx(PanelCartShipment, {}), _jsx(PanelClientCheckout, {}), _jsx(PanelPaymentSuccess, {}), ![tabIdItem, tabIdClearCart, tabIdPaymentSuccess].includes(activeTab) &&
|
|
38
|
+
return (_jsxs(_Fragment, { children: [_jsx(CartHeader, {}), _jsx(CartAlert, {}), _jsx(CartNav, {}), fetchingCart ? (_jsx(LoadingTemplate, {})) : cartSettingsInvalid ? (_jsx(CartPaymentSettingsInvalid, {})) : (_jsxs("div", { className: 'merchi-tab-pane', children: [_jsx(PanelClearCart, {}), _jsx(PanelEditCartItem, {}), _jsx(PanelCartItems, {}), _jsx(PanelCartShipment, {}), _jsx(PanelClientCheckout, {}), _jsx(PanelPaymentSuccess, {}), ![tabIdItem, tabIdClearCart, tabIdPaymentSuccess].includes(activeTab) &&
|
|
38
39
|
_jsxs(_Fragment, { children: [_jsx(CartFooter, { children: _jsx(CartTotals, {}) }), _jsxs(CartFooter, { children: [_jsx(ButtonClearCart, {}), _jsx(ButtonBack, {}), _jsx(ButtonNextDynamic, {})] })] })] }))] }));
|
|
39
40
|
}
|
|
40
41
|
export default function Cart(props) {
|
package/lib/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import Cart from './Cart';
|
|
2
|
-
import { getMerchiCart, getMerchiCartValues, isMerchiCartFetching, } from './store';
|
|
2
|
+
import { actionGetMerchiCart as getMerchiCart, getMerchiCartValues, isMerchiCartFetching, } from './store';
|
|
3
3
|
export { getMerchiCart, getMerchiCartValues, isMerchiCartFetching, };
|
|
4
4
|
export default Cart;
|
|
@@ -2,14 +2,13 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
|
2
2
|
import { useSelector } from 'react-redux';
|
|
3
3
|
import CartItemRow from '../components/CartItemRow';
|
|
4
4
|
import { tabIdItems } from '../slices/sliceCart';
|
|
5
|
-
import CartNav from '../tabs/CartNav';
|
|
6
5
|
import { CartBody, CartTabContent, CartTableContainer, CartTabPanel, NoCartItems, Table, } from '../components';
|
|
7
6
|
function PanelCartItems() {
|
|
8
7
|
var _a = useSelector(function (s) { return s.stateCart; }), cart = _a.cart, deletingCartItemIndex = _a.deletingCartItemIndex;
|
|
9
8
|
var cartItems = cart.cartItems ? cart.cartItems : [];
|
|
10
9
|
var hasItems = cartItems.length > 0;
|
|
11
|
-
return (_jsx(CartTabPanel, { tabId: tabIdItems, children:
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
return (_jsx(CartTabPanel, { tabId: tabIdItems, children: _jsx(CartBody, { children: _jsx(CartTabContent, { children: hasItems ? (_jsx(CartTableContainer, { children: _jsxs(Table, { children: [_jsx("thead", { children: _jsxs("tr", { children: [_jsx("th", { scope: 'col', className: 'merchi-cart-item-table-head', children: "Product" }), _jsx("th", { scope: 'col', className: 'merchi-cart-item-table-head-right', children: "Quantity" }), _jsx("th", { scope: 'col', className: 'merchi-cart-item-table-head-right', children: "Price" }), _jsx("th", { scope: 'col', className: 'merchi-cart-item-table-head-right', children: "Actions" })] }) }), _jsx("tbody", { children: cartItems.map(function (cartItem, index) {
|
|
11
|
+
return _jsx(CartItemRow, { cartItem: cartItem, index: index, loading: deletingCartItemIndex === index }, cartItem.id);
|
|
12
|
+
}) })] }) })) : (_jsx(NoCartItems, {})) }) }) }));
|
|
14
13
|
}
|
|
15
14
|
export default PanelCartItems;
|
|
@@ -5,16 +5,15 @@ import { ActiveFormShipmentAddressAndNotes } from '../forms/FormShipmentAddressA
|
|
|
5
5
|
import { CheckoutContainer, InnerContainer, } from '../components/containers';
|
|
6
6
|
import { Alert, CartBody, CartTabPanel, LoadingTemplateSm, ShipmentGroupCard, Title, } from '../components';
|
|
7
7
|
import { tabIdShipment } from '../slices/sliceCart';
|
|
8
|
-
import CartNav from '../tabs/CartNav';
|
|
9
8
|
function PanelCartShipment() {
|
|
10
9
|
var _a = useSelector(function (s) { return s.stateCartShipment; }), fetchingShipmentGroups = _a.fetchingShipmentGroups, shipmentGroups = _a.shipmentGroups;
|
|
11
|
-
return (
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
10
|
+
return (_jsx(CartTabPanel, { tabId: tabIdShipment, children: _jsx(CartBody, { style: { paddingTop: '2rem' }, children: _jsxs("div", { className: 'merchi-cart-tab-content', children: [_jsx(CheckoutContainer, { textAlign: 'left', children: _jsx(InnerContainer, { width: 700, paddingBottom: '3rem', children: _jsx(ActiveFormShipmentAddressAndNotes, {}) }) }), fetchingShipmentGroups ? (_jsx(CheckoutContainer, { children: _jsxs(InnerContainer, { width: 700, children: [_jsx(LoadingTemplateSm, {}), _jsx("p", { children: "Fetching shipping options." })] }) })) : (_jsxs(_Fragment, { children: [_jsx(CheckoutContainer, { textAlign: 'left', children: _jsx(InnerContainer, { paddingBottom: '1rem', width: 700, children: _jsx(Title, { icon: faTruck, title: shipmentGroups.length > 1 ?
|
|
11
|
+
'Select shipment methods'
|
|
12
|
+
: shipmentGroups.length ?
|
|
13
|
+
'Select a shipment method'
|
|
14
|
+
: '' }) }) }), _jsx(CheckoutContainer, { textAlign: 'left', children: _jsxs(InnerContainer, { paddingBottom: '1rem', width: 700, children: [shipmentGroups.length > 1 &&
|
|
15
|
+
_jsx(Alert, { alertType: 'warning', children: "Items within this cart are warehoused in different locations and will be shipped separately. Please select how you would like your items to be shipped." }), shipmentGroups.map(function (group, index) {
|
|
16
|
+
return _jsx(ShipmentGroupCard, { group: group, groupIndex: index }, "".concat(index, "-shipment-group"));
|
|
17
|
+
})] }) })] }))] }) }) }));
|
|
19
18
|
}
|
|
20
19
|
export default PanelCartShipment;
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { useSelector } from 'react-redux';
|
|
3
3
|
import { tabIdCheckout } from '../slices/sliceCart';
|
|
4
|
-
import CartNav from '../tabs/CartNav';
|
|
5
4
|
import { CheckoutContainer, InnerContainer, } from '../components/containers';
|
|
6
5
|
import CartClient from '../components/CartClient';
|
|
7
6
|
import CartShipment from '../components/CartShipment';
|
|
@@ -15,11 +14,11 @@ function PanelClientCheckout() {
|
|
|
15
14
|
var _a = useSelector(function (s) { return s.stateCart; }), cart = _a.cart, needsShipping = _a.needsShipping;
|
|
16
15
|
var client = cart.client, domain = cart.domain;
|
|
17
16
|
var company = domain && domain.company;
|
|
18
|
-
return (
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
17
|
+
return (_jsx(CartTabPanel, { tabId: tabIdCheckout, children: _jsx(CartBody, { style: { paddingTop: '2rem' }, children: client && client.id > -1 ?
|
|
18
|
+
_jsxs(_Fragment, { children: [_jsx(CheckoutContainer, { children: _jsx(InnerContainer, { paddingBottom: '3rem', children: _jsx(CartClient, { client: client }) }) }), needsShipping &&
|
|
19
|
+
_jsx(CheckoutContainer, { children: _jsx(InnerContainer, { paddingBottom: '3rem', children: _jsx(CartShipment, { cart: cart }) }) }), Boolean(company) && company.acceptSquare &&
|
|
20
|
+
_jsx(CheckoutContainer, { children: _jsx(InnerContainer, { paddingBottom: '3rem', children: _jsx(FormSquarePayment, {}) }) }), _jsx(CheckoutContainer, { children: _jsx(InnerContainer, { children: _jsx(FormStripePayment, {}) }) })] })
|
|
21
|
+
:
|
|
22
|
+
_jsxs(_Fragment, { children: [_jsx(CheckoutContainer, { children: _jsxs(InnerContainer, { paddingBottom: '3rem', children: [_jsx(Title, { icon: faUserPlus, Title: 'Checkout as new customer' }), _jsx(FormNewCustomer, {})] }) }), _jsx(CheckoutContainer, { children: _jsxs(InnerContainer, { paddingBottom: '3rem', children: [_jsx(Title, { icon: faUserTag, Title: 'Checkout as returning customer' }), _jsx(FormReturningCustomer, {})] }) })] }) }) }));
|
|
24
23
|
}
|
|
25
24
|
export default PanelClientCheckout;
|
package/lib/store.js
CHANGED
|
@@ -148,7 +148,6 @@ function cartAndCookie(domainId) {
|
|
|
148
148
|
return __awaiter(this, void 0, void 0, function () {
|
|
149
149
|
var cart;
|
|
150
150
|
return __generator(this, function (_a) {
|
|
151
|
-
console.log(domainId, 'what is this thing in cartAndCookie');
|
|
152
151
|
cart = makeCart({ domain: { id: domainId } }, true);
|
|
153
152
|
return [2 /*return*/, cart.create({ embed: cartEmbed })
|
|
154
153
|
.then(function (c) {
|
|
@@ -483,7 +482,7 @@ function getCart(domainId, cartIdAndToken) {
|
|
|
483
482
|
createAndSetNewCartCookie(domainId);
|
|
484
483
|
});
|
|
485
484
|
}
|
|
486
|
-
export function
|
|
485
|
+
export function actionGetMerchiCart(domainId) {
|
|
487
486
|
return __awaiter(this, void 0, void 0, function () {
|
|
488
487
|
var cartIdAndToken;
|
|
489
488
|
return __generator(this, function (_a) {
|
|
@@ -492,11 +491,9 @@ export function getMerchiCart(domainId) {
|
|
|
492
491
|
case 1:
|
|
493
492
|
cartIdAndToken = _a.sent();
|
|
494
493
|
if (cartIdAndToken) {
|
|
495
|
-
console.log('try get', domainId);
|
|
496
494
|
getCart(domainId, cartIdAndToken);
|
|
497
495
|
}
|
|
498
496
|
else {
|
|
499
|
-
console.log('try create', domainId);
|
|
500
497
|
createAndSetNewCartCookie(domainId);
|
|
501
498
|
}
|
|
502
499
|
return [2 /*return*/];
|
|
@@ -547,9 +544,9 @@ export function doCartComplete() {
|
|
|
547
544
|
}
|
|
548
545
|
export function initMerchiCart(domainId) {
|
|
549
546
|
dispatch(setDomainId(domainId));
|
|
550
|
-
|
|
547
|
+
actionGetMerchiCart(domainId);
|
|
551
548
|
if (window && window !== undefined) {
|
|
552
|
-
window.getCart = function () { return
|
|
549
|
+
window.getCart = function () { return actionGetMerchiCart(domainId); };
|
|
553
550
|
window.isMerchiCartFetching = isMerchiCartFetching;
|
|
554
551
|
window.getMerchiCartValues = getMerchiCartValues;
|
|
555
552
|
}
|
package/lib/styles/globals.css
CHANGED
|
@@ -1,3 +1,7 @@
|
|
|
1
|
+
.merchi-cart-header {
|
|
2
|
+
margin-bottom: 1rem;
|
|
3
|
+
}
|
|
4
|
+
|
|
1
5
|
.merchi-cart-body {
|
|
2
6
|
display: block;
|
|
3
7
|
min-height: 100px;
|
|
@@ -120,6 +124,9 @@
|
|
|
120
124
|
cursor: pointer;
|
|
121
125
|
display: block;
|
|
122
126
|
padding: 0.5rem 1rem;
|
|
127
|
+
width: 100%;
|
|
128
|
+
border: 0px;
|
|
129
|
+
border-radius: 0.375rem;
|
|
123
130
|
}
|
|
124
131
|
|
|
125
132
|
.merchi-nav-link:hover, .merchi-nav-link:focus {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sourceRoot":"","sources":["../../src/styles/globals.scss"],"names":[],"mappings":"AAAA;EACE;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAGF;AACA;EACE;EACA;;;AAGF;EACE;IACE;;EAGF;IACE;IACA;;EAGF;IACE;IACA;;;AAIJ;EACE;;;AAGF;EACE;;;AAGF;EACE;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;;;AAGF;EACE;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;;;AAGF;EACE;EACA;EACA;;;AAGF;AAAA;EAEE;EACA;EACA;;;AAGF;EACE;;;AAGF;AAAA;EAEE;EACA;;;AAGF;EACE;EACA;;;AAEF;EACE;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA","file":"globals.css"}
|
|
1
|
+
{"version":3,"sourceRoot":"","sources":["../../src/styles/globals.scss"],"names":[],"mappings":"AAAA;EACE;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;EACA;EACA;EACA;EACA;;;AAEF;EACE;EACA;EACA;;;AAGF;AACA;EACE;EACA;;;AAGF;EACE;IACE;;EAGF;IACE;IACA;;EAGF;IACE;IACA;;;AAIJ;EACE;;;AAGF;EACE;;;AAGF;EACE;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA;EACA;;;AAGF;EACE;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;;;AAGF;EACE;;;AAGF;EACE;EACA;EACA;;;AAGF;EACE;;;AAGF;EACE;EACA;EACA;;;AAGF;AAAA;EAEE;EACA;EACA;;;AAGF;EACE;;;AAGF;AAAA;EAEE;EACA;;;AAGF;EACE;EACA;;;AAEF;EACE;EACA;EACA;EACA;EACA;;;AAGF;EACE;EACA;EACA;EACA;EACA","file":"globals.css"}
|