@lancom/shared 0.0.465 → 0.0.467
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/assets/js/api/admin.js +7 -1
- package/assets/js/constants/print-type.js +2 -1
- package/components/checkout/cart/cart.mixin.js +5 -1
- package/components/checkout/cart/cart.vue +2 -2
- package/components/checkout/order/order.vue +2 -2
- package/components/order/order_view/order-view.vue +6 -2
- package/components/product/wizard/wizard_print/wizard-print.vue +1 -1
- package/components/products/products_link/products-link.vue +3 -3
- package/mixins/product-preview.js +4 -0
- package/package.json +1 -1
- package/plugins/save-state.js +0 -1
- package/store/cart.js +28 -19
- package/store/index.js +34 -10
package/assets/js/api/admin.js
CHANGED
|
@@ -128,6 +128,9 @@ export default {
|
|
|
128
128
|
orderSubOrders(body) {
|
|
129
129
|
return _post('admin/sub-orders/ordered', body);
|
|
130
130
|
},
|
|
131
|
+
saveSubOrder(subOrder) {
|
|
132
|
+
return _put(`admin/sub-order/${subOrder._id}`, subOrder);
|
|
133
|
+
},
|
|
131
134
|
generateOrderPickPDF(orderId) {
|
|
132
135
|
return _post(`admin/order/${orderId}/pick-pdf`);
|
|
133
136
|
},
|
|
@@ -152,6 +155,9 @@ export default {
|
|
|
152
155
|
markShipmentAsDispatched(order, shipment) {
|
|
153
156
|
return _post(`admin/shop/${order.shop?._id || order.shop}/order/${order._id}/shipment/${shipment._id || shipment.guid}/dispatched`, shipment);
|
|
154
157
|
},
|
|
158
|
+
markLabelsPrinted(order) {
|
|
159
|
+
return _post(`admin/order/${order._id}/mark-labels-printed`);
|
|
160
|
+
},
|
|
155
161
|
markShipmentAsHasException(order, shipment) {
|
|
156
162
|
return _post(`admin/shop/${order.shop?._id || order.shop}/order/${order._id}/shipment/${shipment._id || shipment.guid}/has-exception`, shipment);
|
|
157
163
|
},
|
|
@@ -312,7 +318,7 @@ export default {
|
|
|
312
318
|
return _delete(`admin/inventory-history/${id}`);
|
|
313
319
|
},
|
|
314
320
|
fetchInventory(params) {
|
|
315
|
-
return _get('admin/inventory');
|
|
321
|
+
return _get('admin/inventory', params);
|
|
316
322
|
},
|
|
317
323
|
fetchProducts(params) {
|
|
318
324
|
return _get('admin/products', params);
|
|
@@ -2,7 +2,8 @@ export const PRINT_TYPES = {
|
|
|
2
2
|
BLACK: 'black print',
|
|
3
3
|
FULL_COLOUR: 'full colour print',
|
|
4
4
|
EMBROIDERY: 'embroidery',
|
|
5
|
-
SCREEN: 'screen print'
|
|
5
|
+
SCREEN: 'screen print',
|
|
6
|
+
REFLECTIVE: 'reflective'
|
|
6
7
|
};
|
|
7
8
|
|
|
8
9
|
export const PRINT_TYPES_LIST = Object.keys(PRINT_TYPES).map(k => PRINT_TYPES[k]);
|
|
@@ -16,6 +16,7 @@ export default {
|
|
|
16
16
|
...mapGetters(['shop', 'country', 'currency']),
|
|
17
17
|
...mapGetters('auth', ['user']),
|
|
18
18
|
...mapGetters('cart', [
|
|
19
|
+
'loadingCart',
|
|
19
20
|
'needToPickup',
|
|
20
21
|
'needToPickupWithoutErrors',
|
|
21
22
|
'entities',
|
|
@@ -60,7 +61,10 @@ export default {
|
|
|
60
61
|
}
|
|
61
62
|
},
|
|
62
63
|
mounted() {
|
|
63
|
-
|
|
64
|
+
// console.log('this.loadingCart: ', this.loadingCart);
|
|
65
|
+
// if (!this.loadingCart) {
|
|
66
|
+
// this.calculateCartPriceWithDebounce({ shop: this.shop, country: this.country, currency: this.currency });
|
|
67
|
+
// }
|
|
64
68
|
if (!this.suburb && this.user?.suburb) {
|
|
65
69
|
this.handleSuburbChange(this.user.suburb);
|
|
66
70
|
}
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
<div
|
|
78
78
|
v-else
|
|
79
79
|
class="lc_caption lc_text-centered Cart__no-entities">
|
|
80
|
-
Your cart is empty.
|
|
80
|
+
{{ loadingCart ? 'Your cart is loading...' : 'Your cart is empty.' }}
|
|
81
81
|
</div>
|
|
82
82
|
</div>
|
|
83
83
|
</template>
|
|
@@ -115,7 +115,7 @@ export default {
|
|
|
115
115
|
},
|
|
116
116
|
computed: {
|
|
117
117
|
...mapGetters(['MESSAGES', 'SETTINGS', 'currency', 'country']),
|
|
118
|
-
...mapGetters('cart', ['isEmpty', 'cartPricingError', 'cartPricing', 'cartPricingCalculating', 'entities', 'entitiesWithoutFreeProducts']),
|
|
118
|
+
...mapGetters('cart', ['isEmpty', 'cartPricingError', 'cartPricing', 'cartPricingCalculating', 'entities', 'entitiesWithoutFreeProducts', 'loadingCart']),
|
|
119
119
|
productsEntities() {
|
|
120
120
|
return this.entitiesWithoutFreeProducts.filter(e => !e.productsKit);
|
|
121
121
|
},
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
<div
|
|
31
31
|
v-else
|
|
32
32
|
class="lc_caption lc_text-centered Cart__no-entities">
|
|
33
|
-
Your cart is empty.
|
|
33
|
+
{{ loadingCart ? 'Your cart is loading...' : 'Your cart is empty.' }}
|
|
34
34
|
</div>
|
|
35
35
|
</div>
|
|
36
36
|
</template>
|
|
@@ -83,7 +83,7 @@ export default {
|
|
|
83
83
|
},
|
|
84
84
|
computed: {
|
|
85
85
|
...mapGetters('country'),
|
|
86
|
-
...mapGetters('cart', ['isEmpty']),
|
|
86
|
+
...mapGetters('cart', ['isEmpty', 'loadingCart']),
|
|
87
87
|
...mapGetters('order', ['orderData']),
|
|
88
88
|
...mapGetters('auth', ['isAuthenticated', 'user']),
|
|
89
89
|
steps() {
|
|
@@ -181,7 +181,9 @@
|
|
|
181
181
|
<div class="lc_regular16">
|
|
182
182
|
Total inc {{ taxName }}: <b>{{ model.totalGST | price(order.currency) }}</b>
|
|
183
183
|
</div>
|
|
184
|
-
<div
|
|
184
|
+
<div
|
|
185
|
+
class="lc_regular16"
|
|
186
|
+
style="background-color: #000; color: #fff; padding: 4px 8px; display: inline-block;">
|
|
185
187
|
{{ isPaid ? 'Paid' : 'Pending Payment' }}: <b>{{ model.totalGST | price(order.currency) }}</b>
|
|
186
188
|
</div>
|
|
187
189
|
</div>
|
|
@@ -229,7 +231,9 @@
|
|
|
229
231
|
<div class="lc_regular16">
|
|
230
232
|
Total inc {{ taxName }}: <b>{{ model.totalGST | price(order.currency) }}</b>
|
|
231
233
|
</div>
|
|
232
|
-
<div
|
|
234
|
+
<div
|
|
235
|
+
class="lc_regular16"
|
|
236
|
+
style="background-color: #000; color: #fff; padding: 4px 8px; display: inline-block;">
|
|
233
237
|
{{ isPaid ? 'Paid' : 'Pending Payment' }}: <b>{{ model.totalGST | price(order.currency) }}</b>
|
|
234
238
|
</div>
|
|
235
239
|
</div>
|
package/package.json
CHANGED
package/plugins/save-state.js
CHANGED
package/store/cart.js
CHANGED
|
@@ -11,6 +11,7 @@ export const state = () => ({
|
|
|
11
11
|
id: null,
|
|
12
12
|
entities: [],
|
|
13
13
|
needToPickup: false,
|
|
14
|
+
loadingCart: false,
|
|
14
15
|
suburb: null,
|
|
15
16
|
coupon: null,
|
|
16
17
|
cartPricingCalculating: false,
|
|
@@ -103,6 +104,7 @@ export const getters = {
|
|
|
103
104
|
return freeProducts.length > 0 ? sum + amount : sum;
|
|
104
105
|
}, 0);
|
|
105
106
|
},
|
|
107
|
+
loadingCart: ({ loadingCart }) => loadingCart,
|
|
106
108
|
coupon: ({ coupon }) => coupon,
|
|
107
109
|
needToPickup: ({ needToPickup }) => needToPickup,
|
|
108
110
|
needToPickupWithoutErrors: (state, { notValidProductsPickup }) => state.needToPickup && notValidProductsPickup?.length === 0,
|
|
@@ -229,25 +231,28 @@ export const actions = {
|
|
|
229
231
|
await api.saveCart(payload, shop._id);
|
|
230
232
|
commit('setCartSaving', false);
|
|
231
233
|
},
|
|
232
|
-
async calculateCartPrice({ state: { suburb, entities, coupon, cartPricing }, getters: { needToPickup }, commit }, { shop, country, currency }) {
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
savedSuppliersWithRates =
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
234
|
+
async calculateCartPrice({ state: { suburb, entities, coupon, cartPricing, loadingCart }, getters: { needToPickup }, commit }, { shop, country, currency }) {
|
|
235
|
+
if (!loadingCart) {
|
|
236
|
+
console.trace();
|
|
237
|
+
let savedSuppliersWithRates = null;
|
|
238
|
+
try {
|
|
239
|
+
savedSuppliersWithRates = JSON.parse(localStorage.getItem(SUPPLIERS_WITH_RATES_KEY));
|
|
240
|
+
} catch (e) {}
|
|
241
|
+
const selectedSuppliersWithRates = cartPricing?.shipping?.suppliersWithRates || savedSuppliersWithRates;
|
|
242
|
+
const payload = generateCalculatePriceData(entities, suburb, null, coupon, selectedSuppliersWithRates, country, currency);
|
|
243
|
+
console.log('calculateCartPrice:payload: ', payload)
|
|
244
|
+
try {
|
|
245
|
+
commit('setCartPricingCalculating', true);
|
|
246
|
+
const response = await api.calculateProductPrice({ ...payload, needToPickup }, shop._id);
|
|
247
|
+
commit('setCartPricing', response);
|
|
248
|
+
commit('setCartPricingError', null);
|
|
249
|
+
} catch (e) {
|
|
250
|
+
const { error = 'Error calculate pricing' } = e.response?.data || {};
|
|
251
|
+
commit('setCartPricingError', error);
|
|
252
|
+
commit('setCartPricing', null);
|
|
253
|
+
} finally {
|
|
254
|
+
commit('setCartPricingCalculating', false);
|
|
255
|
+
}
|
|
251
256
|
}
|
|
252
257
|
},
|
|
253
258
|
async setSimpleProductAmount({ state, commit }, { guid, amount, shop, currency }) {
|
|
@@ -310,6 +315,10 @@ export const actions = {
|
|
|
310
315
|
};
|
|
311
316
|
|
|
312
317
|
export const mutations = {
|
|
318
|
+
setLoadingCart(state, loadingCart) {
|
|
319
|
+
state.loadingCart = loadingCart;
|
|
320
|
+
console.log('state.loadingCart: ', state.loadingCart);
|
|
321
|
+
},
|
|
313
322
|
setCart(state, cart) {
|
|
314
323
|
state.id = cart?._id;
|
|
315
324
|
state.entities = cart?.entities || [];
|
package/store/index.js
CHANGED
|
@@ -5,7 +5,18 @@ import { getShopCountrySettings } from '@lancom/shared/assets/js/utils/shop';
|
|
|
5
5
|
import { MESSAGES, COUNTRIES_MESSAGES } from '@/messages';
|
|
6
6
|
import { SETTINGS, COUNTRIES_SETTINGS } from '@/settings';
|
|
7
7
|
const cookieparser = process.server ? require('cookieparser') : undefined;
|
|
8
|
+
const Cookies = process.browser ? require('js-cookie') : undefined;
|
|
8
9
|
const CLOSED_NOTIFICATION = 'lancom-closed-notification-1.0';
|
|
10
|
+
const GCLID_COOKIE = 'gclid';
|
|
11
|
+
const GCLID_EXPIRE_DAYS = 90;
|
|
12
|
+
|
|
13
|
+
function getGclidCookie() {
|
|
14
|
+
return Cookies?.get(GCLID_COOKIE) || null;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function setGclidCookie(value) {
|
|
18
|
+
Cookies?.set(GCLID_COOKIE, value, { expires: GCLID_EXPIRE_DAYS, path: '/' });
|
|
19
|
+
}
|
|
9
20
|
|
|
10
21
|
export const state = () => ({
|
|
11
22
|
googleClickId: null,
|
|
@@ -108,6 +119,7 @@ export const actions = {
|
|
|
108
119
|
}
|
|
109
120
|
},
|
|
110
121
|
async loadState({ dispatch, commit, state: { shop, currency, country, notificationBar } }, query) {
|
|
122
|
+
console.log('loadState...', query);
|
|
111
123
|
const state = await loadState(query);
|
|
112
124
|
if (state) {
|
|
113
125
|
commit('setState', state);
|
|
@@ -116,19 +128,31 @@ export const actions = {
|
|
|
116
128
|
currency: currency?._id,
|
|
117
129
|
country: country?._id
|
|
118
130
|
};
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
131
|
+
commit('cart/setLoadingCart', true);
|
|
132
|
+
try {
|
|
133
|
+
const cart = await api.fetchCartById(shop._id, state.cart?.id, params);
|
|
134
|
+
commit('cart/setCart', cart);
|
|
135
|
+
if (state.cart?.coupon) {
|
|
136
|
+
try {
|
|
137
|
+
const code = state.cart?.coupon.code || state.cart?.coupon;
|
|
138
|
+
const coupon = await api.fetchCouponByCode(shop._id, code);
|
|
139
|
+
commit('cart/setCoupon', coupon);
|
|
140
|
+
} catch (e) {}
|
|
141
|
+
}
|
|
142
|
+
dispatch('cart/calculateCartPrice', { shop, country });
|
|
143
|
+
} catch (e) {
|
|
144
|
+
} finally {
|
|
145
|
+
commit('cart/setLoadingCart', false);
|
|
127
146
|
}
|
|
128
|
-
dispatch('cart/calculateCartPrice', { shop, country });
|
|
129
147
|
}
|
|
130
148
|
}
|
|
131
|
-
|
|
149
|
+
|
|
150
|
+
const cookieGclid = getGclidCookie();
|
|
151
|
+
const googleClickId = query.gclid || cookieGclid || null;
|
|
152
|
+
commit('setGoogleClickId', googleClickId);
|
|
153
|
+
if (query.gclid) {
|
|
154
|
+
setGclidCookie(query.gclid);
|
|
155
|
+
}
|
|
132
156
|
|
|
133
157
|
const closedNotification = localStorage.getItem(CLOSED_NOTIFICATION);
|
|
134
158
|
if (notificationBar?.text === closedNotification) {
|