@lancom/shared 0.0.424 → 0.0.427

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.
Files changed (38) hide show
  1. package/assets/js/api/admin.js +7 -33
  2. package/assets/js/api/index.js +3 -17
  3. package/components/common/coupon_select/coupon-select.vue +2 -12
  4. package/components/common/phone_input/phone-input.vue +3 -15
  5. package/components/common/postcode_select/postcode-select.vue +1 -3
  6. package/components/customer/customer.vue +2 -2
  7. package/components/customer/customer_navigation_menu/customer-navigation-menu.vue +7 -11
  8. package/components/editor/editor_layers/editor-layers.vue +13 -1
  9. package/components/editor/editor_layers/editor_layers_layer/editor-layers-layer.scss +20 -2
  10. package/components/editor/editor_layers/editor_layers_layer/editor-layers-layer.vue +22 -4
  11. package/components/editor/editor_workspace/editor_workspace_side/editor-workspace-side.vue +7 -19
  12. package/components/pages/customer/sign_in/sign-in.vue +2 -2
  13. package/components/product/editor_pricing/editor-pricing.vue +16 -10
  14. package/components/product/product.vue +12 -0
  15. package/components/product/product_reviews/product-reviews.vue +6 -6
  16. package/components/product/related_products/related-products.vue +4 -4
  17. package/package.json +1 -1
  18. package/routes/index.js +0 -10
  19. package/store/auth.js +0 -1
  20. package/store/index.js +3 -12
  21. package/store/product.js +37 -1
  22. package/assets/js/utils/share-promises/index.js +0 -76
  23. package/components/customer/customer_preferences_form/customer-preferences-form.scss +0 -12
  24. package/components/customer/customer_preferences_form/customer-preferences-form.vue +0 -87
  25. package/components/pages/customer/preferences/preferences.vue +0 -79
  26. package/components/resource/resource_view/resource-view.mixin.js +0 -74
  27. package/components/resource/resource_view/resource-view.scss +0 -13
  28. package/components/resource/resource_view/resource-view.vue +0 -97
  29. package/components/resource/resource_view/resource_view_prints/resource-view-prints.scss +0 -7
  30. package/components/resource/resource_view/resource_view_prints/resource-view-prints.vue +0 -42
  31. package/components/resource/resource_view/resource_view_prints/resource_view_print/resource-view-print.scss +0 -5
  32. package/components/resource/resource_view/resource_view_prints/resource_view_print/resource-view-print.vue +0 -54
  33. package/components/resource/resource_view/resource_view_prints/resource_view_print/resource_view_print_products/resource-view-print-products.scss +0 -0
  34. package/components/resource/resource_view/resource_view_prints/resource_view_print/resource_view_print_products/resource-view-print-products.vue +0 -45
  35. package/components/resource/resource_view/resource_view_prints/resource_view_print/resource_view_print_products/resource_view_print_product/resource-view-print-product.scss +0 -0
  36. package/components/resource/resource_view/resource_view_prints/resource_view_print/resource_view_print_products/resource_view_print_product/resource-view-print-product.vue +0 -44
  37. package/pages/customer/preferences.vue +0 -33
  38. package/pages/order/_token/resource/_resource.vue +0 -53
package/store/index.js CHANGED
@@ -4,13 +4,9 @@ import { getAuthToken } from '@lancom/shared/assets/js/utils/auth';
4
4
  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
- import { getSharePromise, clearAllSharePromises } from '@lancom/shared/assets/js/utils/share-promises';
8
-
9
7
  const cookieparser = process.server ? require('cookieparser') : undefined;
10
8
  const CLOSED_NOTIFICATION = 'lancom-closed-notification-1.0';
11
9
 
12
- const shareShopInfo = getSharePromise(60 * 1000);
13
-
14
10
  export const state = () => ({
15
11
  googleClickId: null,
16
12
  stockCountry: null,
@@ -73,14 +69,9 @@ export const actions = {
73
69
  await commit('setShop', shop);
74
70
  }
75
71
  },
76
- async nuxtServerInit({ commit }, { req, query }) {
77
- if (query?.cache === 'false') {
78
- clearAllSharePromises();
79
- await api.clearAllSharePromises();
80
- }
81
-
82
- const shop = await shareShopInfo.share(process.env.HOST_NAME, () => api.fetchShopByUrl(process.env.HOST_NAME));
83
- const menus = await shareShopInfo.share(`menus_${shop._id}`, () => api.fetchMenus(shop._id));
72
+ async nuxtServerInit({ commit }, { req }) {
73
+ const shop = await api.fetchShopByUrl(process.env.HOST_NAME);
74
+ const menus = await api.fetchMenus(shop._id);
84
75
  commit('setMenus', menus);
85
76
  commit('setShop', shop);
86
77
  // if (req.headers.cookie) {
package/store/product.js CHANGED
@@ -45,6 +45,7 @@ export const state = () => ({
45
45
  selectedPrintUnderbases: {},
46
46
  selectedPrintUnderbase: false,
47
47
  editModeSelectedLayer: false,
48
+ offsetWarningVisible: false,
48
49
  selectedPrintAreas: {},
49
50
  productPricing: null,
50
51
  selectedTab: null,
@@ -77,7 +78,7 @@ export const getters = {
77
78
  usedBigSizeSimpleProductsQuantity: (state, { usedSimpleProducts }) => filterBigSize(usedSimpleProducts).reduce((sum, { amount }) => sum + amount, 0),
78
79
  defaultSimpleProduct: ({ productDetails, editableColor }) => {
79
80
  return editableColor && (
80
- productDetails.simpleProducts.find(({ color, size }) => color._id === editableColor._id && size?.alias === 'small')
81
+ productDetails.simpleProducts.find(({ color, size }) => color._id === editableColor._id && size.alias === 'small')
81
82
  || productDetails.simpleProducts.find(({ color }) => color._id === editableColor._id)
82
83
  );
83
84
  },
@@ -162,6 +163,22 @@ export const getters = {
162
163
  const price = pricing?.prints?.prints?.reduce((sum , print) => sum + (+print.priceWithoutTax || 0), 0) || maxPrintsPrice;
163
164
  return price;
164
165
  },
166
+ offsetWarningVisible: ({ offsetWarningVisible }) => offsetWarningVisible,
167
+ showRecommendationToUseLargerImage: ({ selectedLayer }) => {
168
+ return (
169
+ selectedLayer &&
170
+ selectedLayer.type === 'art' &&
171
+ selectedLayer.dpi >= 75 &&
172
+ selectedLayer.dpi <= 100
173
+ );
174
+ },
175
+ showErrorAboutSmallImage: ({ selectedLayer }) => {
176
+ return (
177
+ selectedLayer &&
178
+ selectedLayer.type === 'art' &&
179
+ selectedLayer.dpi < 75
180
+ );
181
+ }
165
182
  };
166
183
 
167
184
  export const actions = {
@@ -319,6 +336,9 @@ export const mutations = {
319
336
  setPriceIncludeGST(state, priceIncludeGST) {
320
337
  state.priceIncludeGST = priceIncludeGST;
321
338
  },
339
+ setOffsetWarningVisible(state, offsetWarningVisible) {
340
+ state.offsetWarningVisible = offsetWarningVisible;
341
+ },
322
342
  setLoadError(state, error) {
323
343
  state.loadError = error;
324
344
  },
@@ -439,6 +459,22 @@ export const mutations = {
439
459
  state.isPrintPricing = false;
440
460
  }
441
461
  },
462
+ moveUpTemplateLayer(state, layer) {
463
+ const index = state.template.layers.findIndex(({ createdAt }) => createdAt === layer.createdAt);
464
+ if (index > 0) {
465
+ const layers = state.template.layers;
466
+ const [layerToMove] = layers.splice(index, 1);
467
+ layers.splice(index - 1, 0, layerToMove);
468
+ }
469
+ },
470
+ moveDownTemplateLayer(state, layer) {
471
+ const index = state.template.layers.findIndex(({ createdAt }) => createdAt === layer.createdAt);
472
+ if (index < state.template.layers.length - 1) {
473
+ const layers = state.template.layers;
474
+ const [layerToMove] = layers.splice(index, 1);
475
+ layers.splice(index + 1, 0, layerToMove);
476
+ }
477
+ },
442
478
  updateTemplateLayer(state, layer) {
443
479
  const index = state.template.layers.findIndex(({ createdAt, _id }) => createdAt === layer.createdAt || (_id && _id === layer._id));
444
480
  Vue.set(state.template.layers, index, layer);
@@ -1,76 +0,0 @@
1
- const MAX_PROMISES_COUNT = 1000;
2
- const DEFAULT_SHARE_LIFETIME = 10 * 1000;
3
-
4
- export class SharePromises {
5
- constructor(clearSharesTimeoutDelay) {
6
- this.promises = new Map();
7
- this.clearSharesTimeout = null;
8
- this.clearSharesTimeoutDelay = clearSharesTimeoutDelay || DEFAULT_SHARE_LIFETIME;
9
- }
10
-
11
- startClearTimeout(key) {
12
- const promise = this.promises.get(key);
13
- if (promise) {
14
- clearTimeout(promise.timeout);
15
- promise.timeout = setTimeout(() => {
16
- this.promises.delete(key);
17
- }, this.clearSharesTimeoutDelay);
18
- }
19
- }
20
-
21
- share(keyObj, promiseFactory) {
22
- const key = `${keyObj}`;
23
- let promise = this.promises.get(key);
24
- if (!promise) {
25
- this.checkMaxPromisesCount();
26
-
27
- promise = {
28
- promise: promiseFactory(),
29
- timeout: null
30
- };
31
-
32
- this.promises.set(key, promise);
33
-
34
- this.startClearTimeout(key);
35
- }
36
-
37
- promise.promise = promise.promise.then((result) => result);
38
-
39
- return promise.promise;
40
- }
41
-
42
- checkMaxPromisesCount() {
43
- if (this.promises.size >= MAX_PROMISES_COUNT) {
44
- this.clear();
45
- }
46
- }
47
-
48
- clear() {
49
- this.promises.forEach(promise => {
50
- clearTimeout(promise.timeout);
51
- });
52
- this.promises.clear();
53
- }
54
-
55
- clearPromise(keyObj) {
56
- const key = `${keyObj}`;
57
- let promise = this.promises.get(key);
58
- if (promise) {
59
- clearTimeout(promise.timeout);
60
- this.promises.delete(key);
61
- }
62
- }
63
- }
64
-
65
- const allSharePromises = [];
66
- export function getSharePromise(timeout) {
67
- const sharePromise = new SharePromises(timeout);
68
- allSharePromises.push(sharePromise);
69
- return sharePromise;
70
- }
71
-
72
- export function clearAllSharePromises() {
73
- for (const sharePromise of allSharePromises) {
74
- sharePromise.clear();
75
- }
76
- }
@@ -1,12 +0,0 @@
1
- @import "@/assets/scss/variables";
2
-
3
- .CustomerPreferencesForm {
4
- &__error {
5
- font-weight: bold;
6
- font-size: 14px;
7
- padding: 18px 10px;
8
- text-align: center;
9
- color: $white;
10
- background: #EA3434;
11
- }
12
- }
@@ -1,87 +0,0 @@
1
- <template>
2
- <div class="form__wrapper CustomerFrom__wrapper">
3
- <validation-observer ref="form">
4
- <div class="mt-10">
5
- <div
6
- class="row"
7
- style="margin-top: -20px">
8
- <div class="col-12">
9
- <div class="form-row">
10
- <label class="form-label">
11
- <checkbox v-model="customer.signUpForNewsletter" />
12
- <span class="lc_regular12 lc__grey1">
13
- Sign up for newsletter
14
- </span>
15
- </label>
16
- </div>
17
- </div>
18
- </div>
19
- </div>
20
- <div class="form__footer mt-5">
21
- <div
22
- v-if="errorMessage"
23
- class="CustomerForm__error">
24
- {{ errorMessage }}
25
- </div>
26
- <div class="form-actions full">
27
- <btn
28
- class="btn btn-black"
29
- :btn-processing="processing"
30
- :btn-disabled="processing"
31
- :btn-label="customer._id ? 'Save' : 'Create Account'"
32
- @onclick="submit()">
33
- </btn>
34
- </div>
35
- </div>
36
- </validation-observer>
37
- </div>
38
- </template>
39
-
40
- <script>
41
- import { mapGetters } from 'vuex';
42
- import api from '@lancom/shared/assets/js/api';
43
-
44
- export default {
45
- name: 'CustomerPreferencesForm',
46
- props: {
47
- customer: {
48
- type: Object,
49
- required: true
50
- }
51
- },
52
- data() {
53
- return {
54
- errorMessage: null,
55
- processing: false
56
- };
57
- },
58
- computed: {
59
- ...mapGetters(['shop'])
60
- },
61
- methods: {
62
- async submit() {
63
- this.errorMessage = null;
64
-
65
- const isValid = await this.$refs.form.validate();
66
- if (!isValid) {
67
- return;
68
- }
69
-
70
- try {
71
- this.processing = true;
72
- const result = await api.saveCustomer(this.customer, this.shop._id);
73
- this.$emit('save', result);
74
- } catch ({ response }) {
75
- const { data } = response || {};
76
- this.errorMessage = data && data.error;
77
- } finally {
78
- this.processing = false;
79
- }
80
- }
81
- }
82
- };
83
- </script>
84
-
85
- <style lang="scss" scoped>
86
- @import 'customer-preferences-form.scss';
87
- </style>
@@ -1,79 +0,0 @@
1
- <template>
2
- <div class="CustomerPreferences__wrapper">
3
- <customer-preferences-form
4
- v-if="customer"
5
- ref="customerForm"
6
- :customer="customer"
7
- @save="onSave"
8
- @customer-loaded="onCustomerLoaded" />
9
- </div>
10
- </template>
11
-
12
- <script>
13
- import api from '@lancom/shared/assets/js/api';
14
- import { mapGetters, mapActions } from 'vuex';
15
- import CustomerPreferencesForm from '@lancom/shared/components/customer/customer_preferences_form/customer-preferences-form';
16
-
17
- export default {
18
- name: 'CustomerPreferences',
19
- components: {
20
- CustomerPreferencesForm
21
- },
22
- data() {
23
- return {
24
- customer: null,
25
- loading: false,
26
- error: null
27
- };
28
- },
29
- computed: {
30
- ...mapGetters(['shop']),
31
- ...mapGetters('auth', ['user'])
32
- },
33
- async created() {
34
- await this.loadCustomerData();
35
- },
36
- methods: {
37
- ...mapActions('auth', ['update_user']),
38
- async loadCustomerData() {
39
- try {
40
- this.processing = true;
41
- const customer = await api.fetchCustomer(this.user.accessToken, this.shop._id);
42
- console.log('customer: ', customer);
43
- this.customer = customer;
44
- } catch (e) {
45
- console.log(e);
46
- const errorMessage = e?.response?.data?.error;
47
- this.$toastr.e(errorMessage || 'Customer failed to load');
48
- } finally {
49
- this.processing = false;
50
- }
51
- },
52
- onSave({ customer: user, token }) {
53
- this.$toastr.s('Customer successfully saved');
54
- this.update_user({ user, token });
55
- },
56
- onCustomerLoaded(customer) {
57
- this.customer = customer;
58
- }
59
- }
60
- };
61
- </script>
62
-
63
- <style lang="scss" scoped>
64
- .loading-message {
65
- text-align: center;
66
- padding: 2rem;
67
- font-size: 1.1rem;
68
- color: #666;
69
- }
70
-
71
- .error-message {
72
- text-align: center;
73
- padding: 2rem;
74
- color: #d32f2f;
75
- background-color: #ffebee;
76
- border-radius: 4px;
77
- margin: 1rem 0;
78
- }
79
- </style>
@@ -1,74 +0,0 @@
1
- import api from '@lancom/shared/assets/js/api';
2
-
3
- const ORDER_RESOURCE_STATUS = {
4
- PENDING_APPROVAL: 'pending approval',
5
- APPROVED: 'approved',
6
- NOT_APPROVED: 'not approved'
7
- };
8
-
9
- export default {
10
- props: {
11
- order: {
12
- type: Object,
13
- required: true
14
- },
15
- resource: {
16
- type: Object,
17
- required: true
18
- }
19
- },
20
- data() {
21
- return {
22
- processing: false
23
- };
24
- },
25
- computed: {
26
- file() {
27
- return this.resource.file;
28
- },
29
- isNotApproved() {
30
- return this.resource.status === ORDER_RESOURCE_STATUS.NOT_APPROVED;
31
- },
32
- isApproved() {
33
- return this.resource.status === ORDER_RESOURCE_STATUS.APPROVED;
34
- },
35
- isAvailableForApprove() {
36
- const statuses = [
37
- ORDER_RESOURCE_STATUS.APPROVED,
38
- ORDER_RESOURCE_STATUS.NOT_APPROVED,
39
- ORDER_RESOURCE_STATUS.PENDING_APPROVAL
40
- ];
41
- return statuses.includes(this.resource.status);
42
- },
43
- isValidStatus() {
44
- const statuses = [
45
- ORDER_RESOURCE_STATUS.APPROVED,
46
- ORDER_RESOURCE_STATUS.NOT_APPROVED
47
- ];
48
- return statuses.includes(this.resource.status);
49
- }
50
- },
51
- mounted() {
52
- console.log('this.resource: ', this.resource);
53
- console.log('this.order: ', this.order);
54
- },
55
- methods: {
56
- approveMockup() {
57
- this.resource.status = 'approved';
58
- },
59
- notApproveMockup() {
60
- this.resource.status = 'not approved';
61
- },
62
- async submitApproval() {
63
- this.processing = true;
64
- try {
65
- await api.approveOrderMockup(this.order, this.resource);
66
- this.processing = false;
67
- this.$toastr.s('Approval submitted successfully.');
68
- } catch (error) {
69
- this.processing = false;
70
- this.$toastr.e('Failed to submit approval.');
71
- }
72
- }
73
- }
74
- };
@@ -1,13 +0,0 @@
1
- .ResourceView {
2
- &__wrapper {
3
- margin-top: 50px;
4
- }
5
- &__approve-btn {
6
- height: 42px;
7
- }
8
- &__approve {
9
- margin-top: 30px;
10
- border: 1px solid #f1f1f1;
11
- padding: 10px;
12
- }
13
- }
@@ -1,97 +0,0 @@
1
- <template>
2
- <div class="ResourceView__wrapper">
3
- <div class="row">
4
- <div class="col-6">
5
- <div class="ResourceView__code lc_h3">
6
- {{ order.code }}
7
- </div>
8
- <div>
9
- <div>
10
- <div class="ResourceView__code lc_h5">
11
- Approve Mockup
12
- </div>
13
- <div
14
- v-if="file"
15
- class="lc_regular16">
16
- <span>
17
- Mockup:
18
- </span>
19
- <a
20
- :href="file.origin"
21
- target="_blank"
22
- class="lc_black">
23
- {{ file.fileName }}
24
- </a>
25
- </div>
26
- </div>
27
- <div class="ResourceView__approve">
28
- <div>
29
- <btn
30
- :btn-class="isApproved ? 'purple' : 'white'"
31
- :btn-disabled="!isAvailableForApprove || processing"
32
- :btn-processing="processing"
33
- btn-label="Approved"
34
- class="ResourceView__approve-btn"
35
- @onclick="approveMockup()">
36
- </btn>
37
- <btn
38
- :btn-class="isNotApproved ? 'purple' : 'white'"
39
- :btn-disabled="!isAvailableForApprove"
40
- :btn-processing="processing"
41
- btn-label="Not Approved"
42
- class="ResourceView__approve-btn"
43
- @onclick="notApproveMockup()">
44
- </btn>
45
- </div>
46
- <div class="mt-10">
47
- <validation-provider
48
- tag="div"
49
- name="Comment"
50
- class="mb-5 mt-5">
51
- <textarea
52
- id="timeline_message"
53
- v-model="resource.comment"
54
- name="comment"
55
- style="height: 140px"
56
- placeholder="Comment"
57
- class="form-field no-label"></textarea>
58
- </validation-provider>
59
- </div>
60
- <div class="mt-10">
61
- <btn
62
- btn-class="green"
63
- :btn-disabled="!isValidStatus || processing"
64
- :btn-processing="processing"
65
- btn-label="Save"
66
- class="ResourceView__approve-btn"
67
- @onclick="submitApproval()">
68
- </btn>
69
- </div>
70
- </div>
71
- </div>
72
- </div>
73
- <div class="col-6">
74
- <resource-view-prints
75
- :order="order"
76
- :resource="resource" />
77
- </div>
78
- </div>
79
- </div>
80
- </template>
81
-
82
- <script>
83
- import ResourceViewMixin from './resource-view.mixin';
84
- import ResourceViewPrints from './resource_view_prints/resource-view-prints';
85
-
86
- export default {
87
- name: 'LancomResourceView',
88
- components: {
89
- ResourceViewPrints
90
- },
91
- mixins: [ResourceViewMixin]
92
- };
93
- </script>
94
-
95
- <style lang="scss" scoped>
96
- @import 'resource-view.scss';
97
- </style>
@@ -1,7 +0,0 @@
1
- .ResourceViewPrints {
2
- &__print {
3
- margin-bottom: 10px;
4
- padding-left: 10px;
5
- border-left: 4px solid #d8d8d8;
6
- }
7
- }
@@ -1,42 +0,0 @@
1
- <template>
2
- <div class="ResourceViewPrints__wrapper">
3
- <resource-view-print
4
- v-for="print in prints"
5
- :key="print._id"
6
- :order="order"
7
- :resource="resource"
8
- :print="print"
9
- class="ResourceViewPrints__print" />
10
- </div>
11
- </template>
12
-
13
- <script>
14
- import ResourceViewPrint from './resource_view_print/resource-view-print';
15
-
16
- export default {
17
- name: 'LancomResourceViewPrints',
18
- components: {
19
- ResourceViewPrint
20
- },
21
- props: {
22
- order: {
23
- type: Object,
24
- required: true
25
- },
26
- resource: {
27
- type: Object,
28
- required: true
29
- }
30
- },
31
- computed: {
32
- prints() {
33
- const productsPrints = this.order.products.reduce((prints, product) => [...prints, ...product.prints], []);
34
- return [...this.order.prints, ...productsPrints];
35
- }
36
- }
37
- };
38
- </script>
39
-
40
- <style lang="scss" scoped>
41
- @import 'resource-view-prints.scss';
42
- </style>
@@ -1,5 +0,0 @@
1
- .ResourceViewPrint {
2
- &__products {
3
- margin-top: 5px;
4
- }
5
- }
@@ -1,54 +0,0 @@
1
- <template>
2
- <div class="ResourceViewPrint__wrapper">
3
- <div class="lc_regular12">
4
- <div v-if="print.printType">
5
- <b class="lc_bold">Print Type:</b> {{ print.printType.name }}
6
- </div>
7
- <div v-if="print.printArea">
8
- <b class="lc_bold">Print Area:</b> {{ print.printArea.name }}
9
- </div>
10
- <div v-if="print.printSize">
11
- <b class="lc_bold">Print Size:</b> {{ print.printSize.name }}
12
- </div>
13
- </div>
14
- <div class="ResourceViewPrint__products">
15
- <resource-view-print-products
16
- :order="order"
17
- :resource="resource"
18
- :print="print" />
19
- </div>
20
- </div>
21
- </template>
22
-
23
- <script>
24
- import ResourceViewPrintProducts from './resource_view_print_products/resource-view-print-products';
25
-
26
- export default {
27
- name: 'LancomResourceViewPrint',
28
- components: {
29
- ResourceViewPrintProducts
30
- },
31
- props: {
32
- order: {
33
- type: Object,
34
- required: true
35
- },
36
- resource: {
37
- type: Object,
38
- required: true
39
- },
40
- print: {
41
- type: Object,
42
- required: true
43
- }
44
- },
45
- mounted() {
46
- console.log('');
47
- console.log('this.print: ', this.print);
48
- }
49
- };
50
- </script>
51
-
52
- <style lang="scss" scoped>
53
- @import 'resource-view-print.scss';
54
- </style>