@lancom/shared 0.0.84 → 0.0.85

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.
@@ -45,8 +45,8 @@ const api = {
45
45
  fetchPricingProducts(shop) {
46
46
  return _get(`shop/${shop}/products/pricing-products`);
47
47
  },
48
- fetchProduct(shop, alias) {
49
- return _get(`shop/${shop}/products/${alias}`);
48
+ fetchProduct(shop, alias, print) {
49
+ return _get(`shop/${shop}/products/${alias}?print=${print || ''}`);
50
50
  },
51
51
  fetchMenus(shop) {
52
52
  return _get(`shop/${shop}/menus`);
@@ -14,6 +14,7 @@ export class Layer {
14
14
  left = null;
15
15
  centeredScaling = true;
16
16
  lockUniScaling = true;
17
+ required = false;
17
18
 
18
19
  // selection style
19
20
  rotatingPointOffset = 30;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.84",
3
+ "version": "0.0.85",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {
package/store/product.js CHANGED
@@ -10,6 +10,7 @@ import { sortByName } from '../assets/js/utils/filters';
10
10
 
11
11
  export const state = () => ({
12
12
  product: null,
13
+ preSetPrint: null,
13
14
  loadError: null,
14
15
  productDetails: null,
15
16
  editorSize: {
@@ -40,6 +41,7 @@ export const state = () => ({
40
41
 
41
42
  export const getters = {
42
43
  product: ({ product }) => product,
44
+ preSetPrint: ({ preSetPrint }) => preSetPrint,
43
45
  loadError: ({ loadError }) => loadError,
44
46
  productDetails: ({ productDetails }) => productDetails,
45
47
  productDetailsLoaded: ({ productDetails }) => !!productDetails,
@@ -115,12 +117,14 @@ export const getters = {
115
117
  };
116
118
 
117
119
  export const actions = {
118
- async fetchProduct({ commit }, { shop, slug }) {
120
+ async fetchProduct({ commit }, { shop, slug, print }) {
119
121
  try {
120
122
  commit('setLoadError', null);
121
- const response = await api.fetchProduct(shop, slug);
123
+ const response = await api.fetchProduct(shop, slug, print);
122
124
  commit('setProduct', response);
125
+ commit('setPreSetPrint', (response.prints || []).find(({ _id }) => _id === print));
123
126
  } catch (e) {
127
+ console.log(e);
124
128
  const { status, data } = e?.response || {};
125
129
  const statusCode = status || 500;
126
130
  commit('setLoadError', {
@@ -210,6 +214,8 @@ export const mutations = {
210
214
  state.loadError = error;
211
215
  },
212
216
  setProductDetails(state, simpleProducts) {
217
+ const { preSetPrint } = state;
218
+ simpleProducts = simpleProducts.filter(sp => !preSetPrint || (preSetPrint.colors || []).includes(sp.color._id) )
213
219
  state.productDetails = { simpleProducts };
214
220
  const availableSizes = [];
215
221
  const sizesPerColor = simpleProducts.reduce((map, { color, size }) => {
@@ -287,6 +293,7 @@ export const mutations = {
287
293
  ...(state.template.layers || []).filter(l => l.guid !== layer.guid),
288
294
  layer
289
295
  ];
296
+ console.log('addTemplateLayer: ', layer);
290
297
  Vue.set(state.template, 'layers', layers);
291
298
  },
292
299
  removeTemplateLayer(state, layer) {
@@ -363,6 +370,9 @@ export const mutations = {
363
370
  },
364
371
  setVisibleSteps(state, visibleSteps) {
365
372
  state.template.visibleSteps = visibleSteps;
373
+ },
374
+ setPreSetPrint(state, preSetPrint) {
375
+ state.preSetPrint = preSetPrint;
366
376
  }
367
377
  };
368
378