@lancom/shared 0.0.68 → 0.0.72

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.
@@ -4,11 +4,11 @@ export function convertQuoteToOrder(quote, option) {
4
4
  billingAddress: quote.address,
5
5
  shippingAddress: quote.address,
6
6
  products: option.products,
7
- price: option.total,
8
7
  total: option.total,
9
- productsTotal: option.total,
10
- printsTotal: option.total,
11
- shippingTotal: option.total,
8
+ totalGST: option.totalGST,
9
+ productsTotal: option.productsTotal,
10
+ printsTotal: option.printsTotal,
11
+ shippingTotal: option.shippingTotal,
12
12
  adminShippingTotal: option.adminShippingTotal
13
13
  };
14
14
  }
@@ -1,6 +1,6 @@
1
1
  <template>
2
2
  <div class="Payment__wrapper">
3
- <div v-if="processing || loading">
3
+ <div v-if="(hasSpinner && processing) || loading">
4
4
  <spinner />
5
5
  </div>
6
6
  <div
@@ -95,6 +95,10 @@ export default {
95
95
  },
96
96
  amount: {
97
97
  type: Number
98
+ },
99
+ hasSpinner: {
100
+ type: Boolean,
101
+ default: true
98
102
  }
99
103
  },
100
104
  data() {
@@ -105,11 +109,19 @@ export default {
105
109
  };
106
110
  },
107
111
  mounted() {
108
- this.initHostedPayment();
112
+ this.loading = true;
113
+ if (window.HostedFields) {
114
+ this.initHostedPayment();
115
+ } else {
116
+ window.addEventListener('load', () => {
117
+ if (!this.fields) {
118
+ this.initHostedPayment();
119
+ }
120
+ });
121
+ }
109
122
  },
110
123
  methods: {
111
124
  initHostedPayment() {
112
- this.loading = true;
113
125
  this.fields = window.HostedFields.create({
114
126
  sandbox: process.env.IS_PROD !== 'true',
115
127
  styles: {
@@ -17,7 +17,7 @@
17
17
  <slot name="back-btn">
18
18
  <btn
19
19
  btn-class="green PaymentSuccess__btn"
20
- btn-label="Back to editor"
20
+ :btn-label="btnLabel"
21
21
  @onclick="$emit('close')" />
22
22
  </slot>
23
23
  </div>
@@ -30,6 +30,10 @@ export default {
30
30
  order: {
31
31
  type: Object,
32
32
  required: true
33
+ },
34
+ btnLabel: {
35
+ type: String,
36
+ default: 'Back to editor'
33
37
  }
34
38
  }
35
39
  };
@@ -0,0 +1,13 @@
1
+ @import "@/assets/scss/variables";
2
+
3
+ .OrderPayment {
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
+ margin-bottom: 10px;
12
+ }
13
+ }
@@ -0,0 +1,114 @@
1
+ <template>
2
+ <div class="OrderPayment__wrapper">
3
+ <h4 class="lc_h1 mt-10 mb-10">
4
+ Payment Order #{{order.code}}
5
+ </h4>
6
+ <payment-success
7
+ v-if="order.paid"
8
+ :order="order">
9
+ <template slot="back-btn">
10
+ <div class="d-flex">
11
+ <btn
12
+ btn-class="green PaymentSuccess__btn"
13
+ btn-label="GO HOME"
14
+ to="/" />
15
+ <!-- <btn
16
+ btn-class="green PaymentSuccess__btn"
17
+ btn-label="VIEW ORDER"
18
+ :to="`/order/${order.token}`" /> -->
19
+ </div>
20
+ </template>
21
+ </payment-success>
22
+ <div v-else>
23
+ <div
24
+ v-if="processing"
25
+ class="OrderPayment__spinner">
26
+ <spinner />
27
+ </div>
28
+ <div class="OrderPrice__content">
29
+ <div>
30
+ <payment-cart
31
+ ref="paymentCart"
32
+ :amount="order.totalGST"
33
+ :has-spinner="false"
34
+ :payment-data="order.billingAddress">
35
+ </payment-cart>
36
+ <div
37
+ v-if="errorMessage"
38
+ class="OrderPayment__error">
39
+ {{ errorMessage }}
40
+ </div>
41
+ <btn
42
+ class="lc_uppercase"
43
+ btn-class="green"
44
+ btn-label="MAKE PAYMENT"
45
+ :btn-block="true"
46
+ :btn-processing="processing"
47
+ @onclick="makePayment" />
48
+ </div>
49
+ </div>
50
+ </div>
51
+ </div>
52
+ </template>
53
+
54
+ <script>
55
+ import { mapGetters } from 'vuex';
56
+ import api from '@lancom/shared/assets/js/api';
57
+ import PaymentCart from '@lancom/shared/components/checkout/payment/payment-cart/payment-cart';
58
+ import PaymentSuccess from '@lancom/shared/components/checkout/payment/payment_success/payment-success';
59
+
60
+ export default {
61
+ name: 'OrderPayment',
62
+ components: {
63
+ PaymentCart,
64
+ PaymentSuccess
65
+ },
66
+ props: {
67
+ order: {
68
+ type: Object,
69
+ required: true
70
+ }
71
+ },
72
+ data() {
73
+ return {
74
+ processing: false,
75
+ errorMessage: null
76
+ };
77
+ },
78
+ computed: {
79
+ ...mapGetters(['shop'])
80
+ },
81
+ methods: {
82
+ handleErrors(err) {
83
+ // err.messages.forEach(({ message }) => this.$toastr.e(message));
84
+ const defaultMessage = 'Payment error';
85
+ this.errorMessage = (err.messages ? err.messages.map(({ message }) => message).join(', ') : (err.error_description)) || defaultMessage;
86
+ },
87
+ async makePayment() {
88
+ try {
89
+ this.errorMessage = null;
90
+ this.processing = true;
91
+ const card = await this.$refs.paymentCart.tokenize();
92
+ if (card) {
93
+ const { paid } = await api.createOrderPayment(this.order._id, card, this.shop._id);
94
+ this.order.paid = paid;
95
+ }
96
+ } catch (e) {
97
+ if (e.response) {
98
+ const { message } = (e.response && e.response.data) || e;
99
+ this.handleErrors({ messages: [{ message }] });
100
+ } else {
101
+ this.handleErrors(e);
102
+ }
103
+ } finally {
104
+ this.processing = false;
105
+ }
106
+ }
107
+ }
108
+ };
109
+
110
+ </script>
111
+
112
+ <style lang="scss" scoped>
113
+ @import 'order-payment.scss';
114
+ </style>
@@ -32,6 +32,7 @@
32
32
  display: flex;
33
33
  flex-direction: column;
34
34
  align-items: flex-end;
35
+ page-break-inside: avoid;
35
36
  }
36
37
  &__totals {
37
38
  margin: 30px 0;
@@ -17,7 +17,7 @@
17
17
  </h4>
18
18
  </div>
19
19
  <h1 class="text-secondary lc_h1">
20
- Tax invoice
20
+ {{ order.paymentMethod === 'deposit' ? 'Proforma Invoice' : 'Tax invoice' }}
21
21
  </h1>
22
22
  </div>
23
23
  <div class="OrderView__info">
@@ -96,6 +96,7 @@
96
96
  v-for="product of order.products"
97
97
  :key="product._id"
98
98
  :product="product"
99
+ :responsive="responsive"
99
100
  class="OrderView__product" />
100
101
  </div>
101
102
  <div
@@ -136,7 +137,13 @@ export default {
136
137
  components: {
137
138
  OrderViewProduct
138
139
  },
139
- mixins: [OrderViewMixin]
140
+ mixins: [OrderViewMixin],
141
+ props: {
142
+ responsive: {
143
+ type: Boolean,
144
+ default: true
145
+ }
146
+ }
140
147
  };
141
148
  </script>
142
149
 
@@ -9,34 +9,14 @@
9
9
  &__table {
10
10
  min-height: 100px;
11
11
  width: 100%;
12
- tbody {
13
- @media (max-width: $bp-small-max) {
14
- display: flex;
15
- flex-direction: column;
16
- }
17
- }
18
12
  ::v-deep {
19
13
  tr {
20
14
  height: 38px;
21
- @media (max-width: $bp-small-max) {
22
- height: auto !important;
23
- display: flex;
24
- flex-direction: row;
25
- flex-wrap: wrap;
26
- margin: 10px 0;
27
- }
28
15
  }
29
16
  td {
30
17
  border: 1px solid #efefef;
31
18
  text-align: center;
32
19
  vertical-align: middle;
33
- @media (max-width: $bp-small-max) {
34
- width: 50%;
35
- padding: 5px;
36
- &:last-child {
37
- width: 100%;
38
- }
39
- }
40
20
  strong {
41
21
  font-weight: bold;
42
22
  }
@@ -48,11 +28,6 @@
48
28
  }
49
29
  }
50
30
  }
51
- &__head {
52
- @media (max-width: $bp-small-max) {
53
- display: none !important;
54
- }
55
- }
56
31
  &__th {
57
32
  font-weight: bold !important;
58
33
  background: #efefef;
@@ -64,4 +39,42 @@
64
39
  transform: rotate(180deg);
65
40
  }
66
41
  }
42
+
43
+ &.responsive {
44
+ .OrderProductPrints {
45
+ &__table {
46
+ tbody {
47
+ @media (max-width: $bp-small-max) {
48
+ display: flex;
49
+ flex-direction: column;
50
+ }
51
+ }
52
+ ::v-deep {
53
+ tr {
54
+ @media (max-width: $bp-small-max) {
55
+ height: auto !important;
56
+ display: flex;
57
+ flex-direction: row;
58
+ flex-wrap: wrap;
59
+ margin: 10px 0;
60
+ }
61
+ }
62
+ td {
63
+ @media (max-width: $bp-small-max) {
64
+ width: 50%;
65
+ padding: 5px;
66
+ &:last-child {
67
+ width: 100%;
68
+ }
69
+ }
70
+ }
71
+ }
72
+ }
73
+ &__head {
74
+ @media (max-width: $bp-small-max) {
75
+ display: none !important;
76
+ }
77
+ }
78
+ }
79
+ }
67
80
  }
@@ -1,5 +1,9 @@
1
1
  <template>
2
- <div class="OrderProductPrints__wrapper">
2
+ <div
3
+ class="OrderProductPrints__wrapper"
4
+ :class="{
5
+ responsive
6
+ }">
3
7
  <div class="OrderProductPrints__title">
4
8
  Decoration
5
9
  </div>
@@ -32,7 +36,8 @@
32
36
  v-for="(print, index) in entity.prints"
33
37
  :key="`${entity.guid}_${index}`"
34
38
  :entity="entity"
35
- :print="print" />
39
+ :print="print"
40
+ :responsive="responsive" />
36
41
  </tbody>
37
42
  </table>
38
43
  </div>
@@ -50,6 +55,10 @@ export default {
50
55
  entity: {
51
56
  type: Object,
52
57
  required: true
58
+ },
59
+ responsive: {
60
+ type: Boolean,
61
+ default: true
53
62
  }
54
63
  }
55
64
  };
@@ -7,6 +7,9 @@
7
7
  }
8
8
  &__wrapper {
9
9
  display: contents;
10
+ .hidden {
11
+ display: none !important;
12
+ }
10
13
  }
11
14
  &__content {
12
15
  text-align: left !important;
@@ -2,31 +2,31 @@
2
2
  <div class="OrderProductPrint__wrapper">
3
3
  <tr>
4
4
  <td class="lc_body-small">
5
- <span class="hidden-md-and-up">Print Type</span>
5
+ <span :class="responsive ? 'hidden-md-and-up' : 'hidden'">Print Type</span>
6
6
  {{ print.printType.name }}
7
7
  </td>
8
8
  <td class="lc_body-small">
9
- <span class="hidden-md-and-up">Location</span>
9
+ <span :class="responsive ? 'hidden-md-and-up' : 'hidden'">Location</span>
10
10
  {{ print.printArea.name }}
11
11
  </td>
12
12
  <td class="lc_body-small">
13
- <span class="hidden-md-and-up">Size</span>
13
+ <span :class="responsive ? 'hidden-md-and-up' : 'hidden'">Size</span>
14
14
  {{ print.printSize.name }}
15
15
  </td>
16
16
  <td class="lc_body-small">
17
- <span class="hidden-md-and-up">Setup cost</span>
18
- {{ print.setupCost | price }}
17
+ <span :class="responsive ? 'hidden-md-and-up' : 'hidden'">Setup cost</span>
18
+ {{ setupCost | price }}
19
19
  </td>
20
20
  <td class="lc_body-small">
21
- <span class="hidden-md-and-up">QTY</span>
21
+ <span :class="responsive ? 'hidden-md-and-up' : 'hidden'">QTY</span>
22
22
  {{ amount }}
23
23
  </td>
24
24
  <td class="lc_body-small">
25
- <span class="hidden-md-and-up">Price</span>
26
- {{ print.printCost | price }}
25
+ <span :class="responsive ? 'hidden-md-and-up' : 'hidden'">Price</span>
26
+ {{ printCost | price }}
27
27
  </td>
28
28
  <td class="lc_body-small">
29
- <span class="hidden-md-and-up">Total</span>
29
+ <span :class="responsive ? 'hidden-md-and-up' : 'hidden'">Total</span>
30
30
  <strong>
31
31
  {{ total | price }}
32
32
  </strong>
@@ -51,6 +51,10 @@ export default {
51
51
  print: {
52
52
  type: Object,
53
53
  required: true
54
+ },
55
+ responsive: {
56
+ type: Boolean,
57
+ default: true
54
58
  }
55
59
  },
56
60
  computed: {
@@ -61,10 +65,10 @@ export default {
61
65
  return this.simpleProducts.reduce((sum, { amount }) => sum + amount, 0);
62
66
  },
63
67
  printCost() {
64
- return this.print.printCost || 0;
68
+ return this.print.costType === 'setup only' ? 0 : (this.print.printCost || 0);
65
69
  },
66
70
  setupCost() {
67
- return this.print.setupCost || 0;
71
+ return this.print.costType === 'item cost only' ? 0 : (this.print.setupCost || 0);
68
72
  },
69
73
  total() {
70
74
  return this.amount * this.printCost + this.setupCost;
@@ -38,7 +38,9 @@
38
38
  <div
39
39
  v-if="hasPrints"
40
40
  class="OrderViewProduct__decorations">
41
- <order-product-prints :entity="product" />
41
+ <order-product-prints
42
+ :entity="product"
43
+ :responsive="responsive" />
42
44
  </div>
43
45
  <div class="OrderViewProduct__subtotal lc_title">
44
46
  Subtotal: {{ totalPrice | price }}
@@ -75,6 +77,10 @@ export default {
75
77
  withDivider: {
76
78
  type: Boolean,
77
79
  default: true
80
+ },
81
+ responsive: {
82
+ type: Boolean,
83
+ default: true
78
84
  }
79
85
  },
80
86
  computed: {
@@ -95,7 +101,8 @@ export default {
95
101
  },
96
102
  totalPrice() {
97
103
  const printsTotal = (this.product.prints || []).reduce((total, print) => {
98
- const { setupCost = 0, printCost = 0 } = print;
104
+ const printCost = print.costType === 'setup only' ? 0 : print.printCost;
105
+ const setupCost = print.costType === 'item cost only' ? 0 : print.setupCost;
99
106
  return total + this.amount * printCost + setupCost;
100
107
  }, 0);
101
108
  const productsTotal = this.simpleProducts.reduce((total, { amount = 0, productCost = 0 }) => total + amount * productCost, 0);
@@ -46,7 +46,7 @@ export default {
46
46
  required: true
47
47
  },
48
48
  withGst: {
49
- type: Object,
49
+ type: Boolean,
50
50
  required: true
51
51
  },
52
52
  minPriceAttr: {
@@ -11,11 +11,11 @@
11
11
  class="form-field no-label tiny-placeholder labelless"
12
12
  @change="goToTextSearch" />
13
13
  </div>
14
- <div class="ProductsAside__item">
14
+ <!-- <div class="ProductsAside__item">
15
15
  <products-types
16
16
  :has-selected-icon="hasSelectedIcon"
17
17
  :has-thumbs="hasThumbs" />
18
- </div>
18
+ </div> -->
19
19
  <div class="ProductsAside__item">
20
20
  <products-brands
21
21
  :has-selected-icon="hasSelectedIcon" />
@@ -3,8 +3,9 @@
3
3
  <div class="ProductsAutocomplete__input">
4
4
  <input
5
5
  v-model="text"
6
+ :autofocus="autofocus"
6
7
  name="search"
7
- placeholder="Search"
8
+ placeholder="Search products"
8
9
  type="text"
9
10
  class="form-field no-label tiny-placeholder labelless"
10
11
  @input="searchWithDebounce"
@@ -42,6 +43,12 @@ export default {
42
43
  components: {
43
44
  ProductsAutocompleteItem
44
45
  },
46
+ props: {
47
+ autofocus: {
48
+ type: Boolean,
49
+ default: false
50
+ }
51
+ },
45
52
  data() {
46
53
  return {
47
54
  searching: false,
@@ -15,7 +15,7 @@
15
15
  </td>
16
16
  <td class="lc_body-small">
17
17
  <span class="hidden-md-and-up">Setup cost</span>
18
- {{ print.setupCost | price }}
18
+ {{ setupCost | price }}
19
19
  </td>
20
20
  <td class="lc_body-small">
21
21
  <span class="hidden-md-and-up">QTY</span>
@@ -23,7 +23,7 @@
23
23
  </td>
24
24
  <td class="lc_body-small">
25
25
  <span class="hidden-md-and-up">Price</span>
26
- {{ print.printCost | price }}
26
+ {{ printCost | price }}
27
27
  </td>
28
28
  <td class="lc_body-small">
29
29
  <span class="hidden-md-and-up">Total</span>
@@ -61,10 +61,10 @@ export default {
61
61
  return this.simpleProducts.reduce((sum, { amount }) => sum + amount, 0);
62
62
  },
63
63
  printCost() {
64
- return this.print.printCost || 0;
64
+ return this.print.costType === 'setup only' ? 0 : (this.print.printCost || 0);
65
65
  },
66
66
  setupCost() {
67
- return this.print.setupCost || 0;
67
+ return this.print.costType === 'item cost only' ? 0 : (this.print.setupCost || 0);
68
68
  },
69
69
  total() {
70
70
  return this.amount * this.printCost + this.setupCost;
@@ -107,7 +107,8 @@ export default {
107
107
  },
108
108
  totalPrice() {
109
109
  const printsTotal = (this.product.prints || []).reduce((total, print) => {
110
- const { setupCost = 0, printCost = 0 } = print;
110
+ const printCost = print.costType === 'setup only' ? 0 : print.printCost;
111
+ const setupCost = print.costType === 'item cost only' ? 0 : print.setupCost;
111
112
  return total + this.amount * printCost + setupCost;
112
113
  }, 0);
113
114
  const productsTotal = this.simpleProducts.reduce((total, { amount = 0, productCost = 0 }) => total + amount * productCost, 0);
@@ -117,6 +118,9 @@ export default {
117
118
  };
118
119
  </script>
119
120
 
121
+ ',
122
+ ITEM_COST_ONLY: 'item cost only
123
+
120
124
  <style lang="scss" scoped>
121
125
  @import 'quote-view-product.scss';
122
126
  </style>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.68",
3
+ "version": "0.0.72",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {