@lancom/shared 0.0.173 → 0.0.175
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 +2 -2
- package/assets/js/api/helpers.js +1 -1
- package/assets/js/utils/prints.js +9 -2
- package/package.json +1 -1
- package/store/cart.js +13 -9
- package/store/index.js +7 -0
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);
|
|
@@ -62,8 +62,15 @@ export function getPrintsFromLayers(layers, product) {
|
|
|
62
62
|
return [...prints.values()];
|
|
63
63
|
}
|
|
64
64
|
|
|
65
|
-
export function getPrintTypeSizePricing(printType, sizeId) {
|
|
66
|
-
|
|
65
|
+
export function getPrintTypeSizePricing(printType, sizeId, coupon) {
|
|
66
|
+
let couponPrintArea = null;
|
|
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
|
+
return couponPrintArea || (printType?.printAreas || [])
|
|
67
74
|
.find(({ printSizes }) => {
|
|
68
75
|
return printSizes.map(size => size?._id || size).includes(sizeId);
|
|
69
76
|
}) || (printType?.printAreas || [])[0];
|
package/package.json
CHANGED
package/store/cart.js
CHANGED
|
@@ -218,17 +218,21 @@ function generateCalculatePriceData(entities, suburb, suppliersWithRates, coupon
|
|
|
218
218
|
entities: entities.map(({ _id, guid, prints, simpleProducts, product }) => ({
|
|
219
219
|
_id,
|
|
220
220
|
guid,
|
|
221
|
+
name: product.name,
|
|
221
222
|
brand: getSimpleObj(product.brand),
|
|
222
|
-
simpleProducts: simpleProducts.map(({ _id, guid, amount, pricing, unprintedPricing, weight = 0 }) =>
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
223
|
+
simpleProducts: simpleProducts.map(({ _id, guid, amount, pricing, unprintedPricing, weight = 0 }) => {
|
|
224
|
+
const couponProduct = (coupon?.products || []).find(({ products }) => products.includes(product._id));
|
|
225
|
+
return {
|
|
226
|
+
amount,
|
|
227
|
+
pricing: couponProduct?.pricing || ((prints || []).length > 0 ? pricing : unprintedPricing),
|
|
228
|
+
weight: product.weight,
|
|
229
|
+
volume: product.volume,
|
|
230
|
+
guid,
|
|
231
|
+
_id
|
|
232
|
+
};
|
|
233
|
+
}).filter(({ amount }) => +amount > 0),
|
|
230
234
|
prints: (prints || []).map(print => {
|
|
231
|
-
const { setupCost, freeSetupOver, printCost } = getPrintTypeSizePricing(print.printType, print.printSize?._id) || {};
|
|
235
|
+
const { setupCost, freeSetupOver, printCost } = getPrintTypeSizePricing(print.printType, print.printSize?._id, coupon) || {};
|
|
232
236
|
return {
|
|
233
237
|
costType: print.printType.costType,
|
|
234
238
|
setupCost,
|
package/store/index.js
CHANGED
|
@@ -56,6 +56,13 @@ export const actions = {
|
|
|
56
56
|
if (state.cart?.id) {
|
|
57
57
|
const cart = await api.fetchCartById(shop._id, state.cart?.id);
|
|
58
58
|
commit('cart/setCart', cart);
|
|
59
|
+
if (state.cart?.coupon) {
|
|
60
|
+
try {
|
|
61
|
+
const code = state.cart?.coupon.code || state.cart?.coupon;
|
|
62
|
+
const coupon = await api.fetchCouponByCode(shop._id, code);
|
|
63
|
+
commit('cart/setCoupon', coupon);
|
|
64
|
+
} catch (e) {}
|
|
65
|
+
}
|
|
59
66
|
dispatch('cart/calculateCartPrice', { shop });
|
|
60
67
|
}
|
|
61
68
|
}
|