@lancom/shared 0.0.177 → 0.0.178
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
CHANGED
|
@@ -85,8 +85,8 @@ export default {
|
|
|
85
85
|
savePurchaseOrder(purchaseOrder) {
|
|
86
86
|
return purchaseOrder._id ? _put(`admin/purchase-order/${purchaseOrder._id}`, purchaseOrder) : _post('admin/purchase-order', purchaseOrder);
|
|
87
87
|
},
|
|
88
|
-
savePurchaseOrderShipment(purchaseOrder, shipment) {
|
|
89
|
-
return _put(`admin/purchase-order/${purchaseOrder._id}/shipments/${shipment._id}`, shipment);
|
|
88
|
+
savePurchaseOrderShipment(purchaseOrder, shipment, params) {
|
|
89
|
+
return _put(`admin/purchase-order/${purchaseOrder._id}/shipments/${shipment._id}`, shipment, params);
|
|
90
90
|
},
|
|
91
91
|
fetchPurchaseOrderWoTasks(purchaseOrderId) {
|
|
92
92
|
return _get(`admin/purchase-order/${purchaseOrderId}/wo-tasks`);
|
package/assets/js/api/helpers.js
CHANGED
|
@@ -38,6 +38,6 @@ export const prepareHeaders = method => {
|
|
|
38
38
|
|
|
39
39
|
export const _post = (url, data, config) => axiosApiInstance.post(buildPath(url), data, { ...config, headers: prepareHeaders() }).then(response => response.data);
|
|
40
40
|
export const _get = (url, params) => axiosApiInstance.get(buildPath(url), { params, headers: prepareHeaders('get') }).then(response => response.data);
|
|
41
|
-
export const _put = (url, data) => axiosApiInstance.put(buildPath(url), { ...data, __v: undefined }, { headers: prepareHeaders() }).then(response => response.data);
|
|
41
|
+
export const _put = (url, data, params) => axiosApiInstance.put(buildPath(url), { ...data, __v: undefined }, { params, headers: prepareHeaders() }).then(response => response.data);
|
|
42
42
|
export const _patch = (url, data) => axiosApiInstance.patch(buildPath(url), { ...data, __v: undefined }, { headers: prepareHeaders() }).then(response => response.data);
|
|
43
43
|
export const _delete = (url, data) => axiosApiInstance.delete(buildPath(url), { data, headers: prepareHeaders() }).then(response => response.data);
|
package/assets/js/utils/gtm.js
CHANGED
|
@@ -28,23 +28,25 @@ const gtm = {
|
|
|
28
28
|
});
|
|
29
29
|
},
|
|
30
30
|
viewCart(entities, pricing) {
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
31
|
+
if (pricing) {
|
|
32
|
+
this.push({
|
|
33
|
+
event: 'view_cart',
|
|
34
|
+
value: pricing.totalPriceWithoutTax,
|
|
35
|
+
currency: 'AUD',
|
|
36
|
+
coupon: pricing.coupon?.code,
|
|
37
|
+
items: entities.reduce((products, { guid: productGuid, product, simpleProducts }) => {
|
|
38
|
+
return [
|
|
39
|
+
...products,
|
|
40
|
+
...simpleProducts
|
|
41
|
+
.filter(({ amount }) => amount > 0)
|
|
42
|
+
.map((sp) => ({
|
|
43
|
+
...getOrderItem(product, sp),
|
|
44
|
+
price: pricing.products[productGuid]?.products[sp.guid]?.priceWithoutTax
|
|
45
|
+
}))
|
|
46
|
+
];
|
|
47
|
+
}, [])
|
|
48
|
+
});
|
|
49
|
+
}
|
|
48
50
|
},
|
|
49
51
|
removeFromCart(simpleProducts, pricing) {
|
|
50
52
|
const removeSimpleProducts = simpleProducts.filter(({ amount }) => amount > 0);
|
|
@@ -64,12 +64,12 @@ export function getPrintsFromLayers(layers, product) {
|
|
|
64
64
|
|
|
65
65
|
export function getPrintTypeSizePricing(printType, sizeId, coupon) {
|
|
66
66
|
let couponPrintArea = null;
|
|
67
|
-
(coupon?.prints || [])
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
67
|
+
// (coupon?.prints || [])
|
|
68
|
+
// .forEach(({ printAreas, printTypes }) => {
|
|
69
|
+
// if (printTypes.includes(printType._id)) {
|
|
70
|
+
// couponPrintArea = couponPrintArea || printAreas.find(({ printSizes }) => printSizes.includes(sizeId))
|
|
71
|
+
// }
|
|
72
|
+
// });
|
|
73
73
|
return couponPrintArea || (printType?.printAreas || [])
|
|
74
74
|
.find(({ printSizes }) => {
|
|
75
75
|
return printSizes.map(size => size?._id || size).includes(sizeId);
|
|
@@ -24,6 +24,10 @@
|
|
|
24
24
|
filled: code
|
|
25
25
|
}"
|
|
26
26
|
@keydown.enter="validateCoupon" />
|
|
27
|
+
<span
|
|
28
|
+
v-if="value"
|
|
29
|
+
class="CouponSelect__clear"
|
|
30
|
+
@click="clearCoupon()">remove coupon</span>
|
|
27
31
|
</div>
|
|
28
32
|
<div class="col-5">
|
|
29
33
|
<btn
|
|
@@ -44,19 +48,24 @@
|
|
|
44
48
|
Not valid coupon
|
|
45
49
|
</span>
|
|
46
50
|
</validation-provider>
|
|
47
|
-
<div v-if="value">
|
|
51
|
+
<div v-if="value && pricing">
|
|
48
52
|
<div
|
|
49
53
|
v-if="isValidPricing"
|
|
50
54
|
class="lc_h4">
|
|
51
55
|
<span v-if="value.showCouponIsApplied">
|
|
52
56
|
COUPON APPLIED
|
|
57
|
+
<span v-if="pricing.totalsWithoutCoupon">
|
|
58
|
+
: {{ pricing.totalsWithoutCoupon.totalPrice - pricing.totalPrice | price }} OFF
|
|
59
|
+
</span>
|
|
53
60
|
</span>
|
|
54
61
|
<span v-else>
|
|
55
62
|
{{ value.value | price }} OFF
|
|
56
63
|
</span>
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
</div>
|
|
65
|
+
<div
|
|
66
|
+
v-else-if="pricing.couponError"
|
|
67
|
+
class="lc_caption form-help is-danger">
|
|
68
|
+
{{ pricing.couponError }}
|
|
60
69
|
</div>
|
|
61
70
|
<div
|
|
62
71
|
v-else
|
|
@@ -99,7 +108,7 @@ export default {
|
|
|
99
108
|
computed: {
|
|
100
109
|
...mapGetters(['shop']),
|
|
101
110
|
isValidPricing() {
|
|
102
|
-
return !this.value
|
|
111
|
+
return !this.value?.minOrderValue || this.pricing.coupon;
|
|
103
112
|
},
|
|
104
113
|
model: {
|
|
105
114
|
get() {
|
package/package.json
CHANGED
package/store/cart.js
CHANGED
|
@@ -9,6 +9,7 @@ export const state = () => ({
|
|
|
9
9
|
entities: [],
|
|
10
10
|
suburb: null,
|
|
11
11
|
coupon: null,
|
|
12
|
+
cartPricingCalculating: false,
|
|
12
13
|
cartPricing: null,
|
|
13
14
|
cartPricingError: null
|
|
14
15
|
});
|
|
@@ -44,6 +45,7 @@ const getPrintsQuantities = entities => {
|
|
|
44
45
|
export const getters = {
|
|
45
46
|
entities: ({ entities }) => entities,
|
|
46
47
|
coupon: ({ coupon }) => coupon,
|
|
48
|
+
cartPricingCalculating: ({ cartPricingCalculating }) => cartPricingCalculating,
|
|
47
49
|
simpleProducts: ({ entities }) => entities.reduce((simpleProducts, entity) => [...simpleProducts, ...(entity.simpleProducts || [])], []),
|
|
48
50
|
notEmptySimpleProducts: (state, { simpleProducts }) => simpleProducts.filter(e => e.amount > 0),
|
|
49
51
|
simpleProductsQuantity: (state, { notEmptySimpleProducts }) => notEmptySimpleProducts.reduce((quantity, sp) => quantity + sp.amount, 0),
|
|
@@ -128,6 +130,7 @@ export const actions = {
|
|
|
128
130
|
const selectedSuppliersWithRates = cartPricing?.shipping?.suppliersWithRates;
|
|
129
131
|
const payload = generateCalculatePriceData(entities, suburb, null, coupon, selectedSuppliersWithRates);
|
|
130
132
|
try {
|
|
133
|
+
commit('setCartPricingCalculating', true);
|
|
131
134
|
const response = await api.calculateProductPrice(payload, shop._id);
|
|
132
135
|
commit('setCartPricing', response);
|
|
133
136
|
commit('setCartPricingError', null);
|
|
@@ -135,6 +138,8 @@ export const actions = {
|
|
|
135
138
|
const { error = 'Error calculate pricing' } = e.response?.data || {};
|
|
136
139
|
commit('setCartPricingError', error);
|
|
137
140
|
commit('setCartPricing', null);
|
|
141
|
+
} finally {
|
|
142
|
+
commit('setCartPricingCalculating', false);
|
|
138
143
|
}
|
|
139
144
|
},
|
|
140
145
|
async setSimpleProductAmount({ state, commit }, { guid, amount, shop }) {
|
|
@@ -165,6 +170,7 @@ export const actions = {
|
|
|
165
170
|
}));
|
|
166
171
|
const payload = generateCalculatePriceData(entities, suburb, suppliersWithRates, coupon);
|
|
167
172
|
try {
|
|
173
|
+
commit('setCartPricingCalculating', true);
|
|
168
174
|
const response = await api.calculateProductPrice(payload, shop._id);
|
|
169
175
|
commit('setCartPricing', response);
|
|
170
176
|
commit('setCartPricingError', null);
|
|
@@ -172,6 +178,8 @@ export const actions = {
|
|
|
172
178
|
const { error = 'Error calculate pricing' } = e.response?.data || {};
|
|
173
179
|
commit('setCartPricingError', error);
|
|
174
180
|
commit('setCartPricing', null);
|
|
181
|
+
} finally {
|
|
182
|
+
commit('setCartPricingCalculating', false);
|
|
175
183
|
}
|
|
176
184
|
}
|
|
177
185
|
};
|
|
@@ -196,6 +204,9 @@ export const mutations = {
|
|
|
196
204
|
setCartPricing(state, price) {
|
|
197
205
|
state.cartPricing = price;
|
|
198
206
|
},
|
|
207
|
+
setCartPricingCalculating(state, calculating) {
|
|
208
|
+
state.cartPricingCalculating = calculating;
|
|
209
|
+
},
|
|
199
210
|
setCartPricingError(state, error) {
|
|
200
211
|
state.cartPricingError = error;
|
|
201
212
|
},
|
|
@@ -218,13 +229,14 @@ function generateCalculatePriceData(entities, suburb, suppliersWithRates, coupon
|
|
|
218
229
|
entities: entities.map(({ _id, guid, prints, simpleProducts, product }) => ({
|
|
219
230
|
_id,
|
|
220
231
|
guid,
|
|
232
|
+
productId: product._id,
|
|
221
233
|
name: product.name,
|
|
222
234
|
brand: getSimpleObj(product.brand),
|
|
223
235
|
simpleProducts: simpleProducts.map(({ _id, guid, amount, pricing, unprintedPricing, weight = 0 }) => {
|
|
224
|
-
const couponProduct = (coupon?.products || []).find(({ products }) => products.includes(product._id));
|
|
236
|
+
// const couponProduct = (coupon?.products || []).find(({ products, onlyPrinted }) => products.includes(product._id) && (!onlyPrinted || (prints || []).length > 0));
|
|
225
237
|
return {
|
|
226
238
|
amount,
|
|
227
|
-
pricing:
|
|
239
|
+
pricing: ((prints || []).length > 0 ? pricing : unprintedPricing),
|
|
228
240
|
weight: product.weight,
|
|
229
241
|
volume: product.volume,
|
|
230
242
|
guid,
|