@lancom/shared 0.0.58 → 0.0.64

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.
@@ -7,6 +7,7 @@ export default {
7
7
  ],
8
8
  computed: {
9
9
  ...mapGetters(['shop']),
10
+ ...mapGetters('auth', ['user']),
10
11
  ...mapGetters('cart', [
11
12
  'entities',
12
13
  'simpleProducts',
@@ -32,6 +33,10 @@ export default {
32
33
  },
33
34
  mounted() {
34
35
  this.calculateCartPrice(this.shop);
36
+ if (!this.suburb && this.user?.suburb) {
37
+ this.handleSuburbChange(this.user.suburb);
38
+ }
39
+ console.log('user: ', this.user);
35
40
  },
36
41
  methods: {
37
42
  ...mapMutations('cart', [
@@ -259,9 +259,15 @@ export default {
259
259
  ...mapGetters(['shop']),
260
260
  ...mapGetters('cart', [
261
261
  'suburb'
262
+ ]),
263
+ ...mapGetters('auth', [
264
+ 'user'
262
265
  ])
263
266
  },
264
- mounted() {
267
+ created() {
268
+ if (!this.address.suburb && !this.suburb && this.user?.suburb) {
269
+ this.handleSuburbChange(this.user.suburb);
270
+ }
265
271
  if (!this.address.suburb) {
266
272
  this.setAddressSuburb(this.suburb);
267
273
  }
@@ -0,0 +1,9 @@
1
+ .OrderCheckoutMethod {
2
+ &__controls {
3
+ display: flex;
4
+ width: 100%;
5
+ > div {
6
+ flex-grow: 1;
7
+ }
8
+ }
9
+ }
@@ -1,11 +1,34 @@
1
1
  <template>
2
2
  <div class="OrderCheckoutMethod__wrapper">
3
- <div class="lc_h3 lc_uppercase lc_bold">
4
- Log In
3
+ <div class="row">
4
+ <div class="col-12">
5
+ <div class="OrderCheckoutMethod__controls">
6
+ <div>
7
+ <btn
8
+ :btn-class="isRegister ? 'white' : 'green'"
9
+ btn-label="LOG IN"
10
+ :btn-block="true"
11
+ @onclick="isRegister = false" />
12
+ </div>
13
+ <div>
14
+ <btn
15
+ :btn-class="isRegister ? 'green' : 'white'"
16
+ btn-label="REGISTER"
17
+ :btn-block="true"
18
+ @onclick="isRegister = true" />
19
+ </div>
20
+ </div>
21
+ </div>
5
22
  </div>
6
23
  <div class="row">
7
24
  <div class="col-12">
8
- <signin-form @signin="$emit('next')" />
25
+ <customer-form
26
+ v-if="isRegister"
27
+ :customer="customer"
28
+ @save="createdCustomer($event)" />
29
+ <signin-form
30
+ v-else
31
+ @signin="signin()" />
9
32
  </div>
10
33
  </div>
11
34
  <progress-steps-controls
@@ -16,14 +39,60 @@
16
39
  </template>
17
40
 
18
41
  <script>
42
+ import { mapActions, mapGetters } from 'vuex';
19
43
  import ProgressStepsControls from '@lancom/shared/components/common/progress_steps/progress_steps_controls/progress-steps-controls';
20
44
  import SigninForm from '@lancom/shared/components/customer/signin_form/signin-form';
45
+ import CustomerForm from '@lancom/shared/components/customer/customer_form/customer-form';
21
46
 
22
47
  export default {
23
48
  name: 'OrderCheckoutMethod',
24
49
  components: {
25
50
  ProgressStepsControls,
26
- SigninForm
51
+ SigninForm,
52
+ CustomerForm
53
+ },
54
+ props: {
55
+ order: {
56
+ type: Object,
57
+ required: true
58
+ }
59
+ },
60
+ data() {
61
+ return {
62
+ isRegister: false,
63
+ customer: {
64
+ firstName: null,
65
+ lastName: null,
66
+ email: null,
67
+ phone: null,
68
+ password: null
69
+ }
70
+ };
71
+ },
72
+ computed: {
73
+ ...mapGetters('auth', ['user'])
74
+ },
75
+ methods: {
76
+ ...mapActions('auth', ['update_user']),
77
+ createdCustomer({ customer: user, token }) {
78
+ this.update_user({ user, token });
79
+
80
+ this.updateorderData(user);
81
+
82
+ this.$emit('next');
83
+ },
84
+ signin() {
85
+ this.updateorderData(this.user);
86
+ this.$emit('next');
87
+ },
88
+ updateorderData(user) {
89
+ if (user) {
90
+ this.order.billingAddress.fullName = this.order.billingAddress.fullName || `${user.firstName} ${user.lastName}`;
91
+ this.order.billingAddress.phone = this.order.billingAddress.phone || user.phone;
92
+ this.order.billingAddress.email = this.order.billingAddress.email || user.email;
93
+ this.order.billingAddress.company = this.order.billingAddress.company || user.company;
94
+ }
95
+ }
27
96
  }
28
97
  };
29
98
  </script>
@@ -109,7 +109,8 @@ export default {
109
109
  ...(this.user ? {
110
110
  fullName: `${this.user.firstName} ${this.user.lastName}`,
111
111
  phone: this.user.phone,
112
- email: this.user.email
112
+ email: this.user.email,
113
+ company: this.user.company
113
114
  } : {})
114
115
  },
115
116
  shippingAddress: {
@@ -83,6 +83,7 @@ export default {
83
83
  height: 24px;
84
84
  background-position: top left;
85
85
  background-repeat: repeat-x;
86
+ background-size: 24px 24px;
86
87
  cursor: pointer;
87
88
  }
88
89
  &__wrapper {
@@ -0,0 +1,9 @@
1
+ .CustomerPage {
2
+ &__controls {
3
+ display: flex;
4
+ width: 100%;
5
+ > div {
6
+ flex-grow: 1;
7
+ }
8
+ }
9
+ }
@@ -0,0 +1,84 @@
1
+ <template>
2
+ <div class="CustomerPage__wrapper">
3
+ <div class="row">
4
+ <div class="col-12">
5
+ <div class="CustomerPage__controls">
6
+ <div>
7
+ <btn
8
+ :btn-class="isRegister ? 'white' : 'green'"
9
+ btn-label="LOG IN"
10
+ :btn-block="true"
11
+ @onclick="isRegister = false" />
12
+ </div>
13
+ <div>
14
+ <btn
15
+ :btn-class="isRegister ? 'green' : 'white'"
16
+ btn-label="REGISTER"
17
+ :btn-block="true"
18
+ @onclick="isRegister = true" />
19
+ </div>
20
+ </div>
21
+ </div>
22
+ </div>
23
+ <div class="row">
24
+ <div class="col-12">
25
+ <customer-form
26
+ v-if="isRegister"
27
+ :customer="customer"
28
+ @save="createdCustomer($event)" />
29
+ <signin-form
30
+ v-else
31
+ @signin="signin()" />
32
+ </div>
33
+ </div>
34
+ </div>
35
+ </template>
36
+
37
+ <script>
38
+ import { mapGetters, mapActions, mapMutations } from 'vuex';
39
+ import SigninForm from '@lancom/shared/components/customer/signin_form/signin-form';
40
+ import CustomerForm from '@lancom/shared/components/customer/customer_form/customer-form';
41
+
42
+ export default {
43
+ name: 'Customer',
44
+ components: {
45
+ SigninForm,
46
+ CustomerForm
47
+ },
48
+ props: {
49
+ activeRegister: {
50
+ type: Boolean,
51
+ default: false
52
+ }
53
+ },
54
+ data() {
55
+ return {
56
+ isRegister: this.activeRegister,
57
+ customer: {
58
+ firstName: null,
59
+ lastName: null,
60
+ email: null,
61
+ phone: null,
62
+ password: null,
63
+ company: null,
64
+ suburb: null,
65
+ signUpForNewsletter: false
66
+ }
67
+ };
68
+ },
69
+ methods: {
70
+ ...mapActions('auth', ['update_user']),
71
+ createdCustomer({ customer: user, token }) {
72
+ this.update_user({ user, token });
73
+ this.$router.push('/');
74
+ },
75
+ signin() {
76
+ this.$router.push('/');
77
+ }
78
+ }
79
+ };
80
+ </script>
81
+
82
+ <style lang="scss" scoped>
83
+ @import 'customer.scss';
84
+ </style>
@@ -0,0 +1,12 @@
1
+ @import "@/assets/scss/variables";
2
+
3
+ .CustomerForm {
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,161 +1,213 @@
1
1
  <template>
2
2
  <div class="form__wrapper CustomerFrom__wrapper">
3
3
  <validation-observer ref="form">
4
- <div
5
- v-if="errorMessage"
6
- class="alert alert-danger">
7
- Save error: {{ errorMessage }}
8
- </div>
9
4
  <div class="mt-10">
10
- <validation-provider
11
- v-slot="{ errors }"
12
- tag="div"
13
- name="First Name"
14
- rules="required"
15
- class="form-row">
16
- <label
17
- for="firstName"
18
- class="form-label">
19
- First Name
20
- </label>
21
- <input
22
- id="firstName"
23
- v-model="customer.firstName"
24
- name="firstName"
25
- type="text"
26
- class="form-field labelless"
27
- placeholder="First Name"
28
- :class="{
29
- 'is-invalid': errors.length,
30
- filled: customer.firstName
31
- }" />
32
- <span
33
- v-if="errors.length"
34
- class="form-help is-danger">
35
- {{ errors[0] }}
36
- </span>
37
- </validation-provider>
38
- <validation-provider
39
- v-slot="{ errors }"
40
- tag="div"
41
- name="Last Name"
42
- rules="required"
43
- class="form-row">
44
- <label
45
- for="lastName"
46
- class="form-label">
47
- Last Name
48
- </label>
49
- <input
50
- id="lastName"
51
- v-model="customer.lastName"
52
- name="lastName"
53
- type="text"
54
- class="form-field labelless"
55
- placeholder="Last Name"
56
- :class="{
57
- 'is-invalid': errors.length,
58
- filled: customer.lastName
59
- }" />
60
- <span
61
- v-if="errors.length"
62
- class="form-help is-danger">
63
- {{ errors[0] }}
64
- </span>
65
- </validation-provider>
66
- <validation-provider
67
- v-slot="{ errors }"
68
- tag="div"
69
- name="Phone"
70
- rules="required"
71
- class="form-row">
72
- <label
73
- for="phone"
74
- class="form-label">
75
- Phone
76
- </label>
77
- <input
78
- id="phone"
79
- v-model="customer.phone"
80
- name="phone"
81
- type="text"
82
- class="form-field labelless"
83
- placeholder="Phone"
84
- :class="{
85
- 'is-invalid': errors.length,
86
- filled: customer.phone
87
- }" />
88
- <span
89
- v-if="errors.length"
90
- class="form-help is-danger">
91
- {{ errors[0] }}
92
- </span>
93
- </validation-provider>
94
- <validation-provider
95
- v-slot="{ errors }"
96
- tag="div"
97
- name="Email"
98
- rules="required|email"
99
- class="form-row">
100
- <label
101
- for="email"
102
- class="form-label">
103
- Email
104
- </label>
105
- <input
106
- id="email"
107
- ref="email"
108
- v-model="customer.email"
109
- name="email"
110
- type="text"
111
- class="form-field labelless"
112
- placeholder="Email"
113
- :disabled="customer._id"
114
- :class="{
115
- 'is-invalid': errors.length,
116
- filled: customer.email
117
- }" />
118
- <span
119
- v-if="errors.length"
120
- class="form-help is-danger">
121
- {{ errors[0] }}
122
- </span>
123
- </validation-provider>
124
- <validation-provider
125
- v-if="!customer._id"
126
- v-slot="{ errors }"
127
- tag="div"
128
- name="Password"
129
- rules="required"
130
- class="form-row">
131
- <label
132
- for="password"
133
- class="form-label">
134
- Password
135
- </label>
136
- <input
137
- id="password"
138
- ref="password"
139
- v-model="customer.password"
140
- name="password"
141
- type="password"
142
- class="form-field labelless"
143
- placeholder="Password"
144
- :class="{
145
- 'is-invalid': errors.length,
146
- filled: customer.password
147
- }" />
148
- <span
149
- v-if="errors.length"
150
- class="form-help is-danger">
151
- {{ errors[0] }}
152
- </span>
153
- </validation-provider>
5
+ <div class="row">
6
+ <div class="col-6">
7
+ <validation-provider
8
+ v-slot="{ errors }"
9
+ tag="div"
10
+ name="Email"
11
+ rules="required|email"
12
+ class="form-row">
13
+ <label
14
+ for="email"
15
+ class="form-label">
16
+ Email
17
+ </label>
18
+ <input
19
+ id="email"
20
+ ref="email"
21
+ v-model="customer.email"
22
+ name="email"
23
+ type="text"
24
+ class="form-field labelless"
25
+ placeholder="Email"
26
+ :disabled="customer._id"
27
+ :class="{
28
+ 'is-invalid': errors.length,
29
+ filled: customer.email
30
+ }" />
31
+ <span
32
+ v-if="errors.length"
33
+ class="form-help is-danger">
34
+ {{ errors[0] }}
35
+ </span>
36
+ </validation-provider>
37
+ <validation-provider
38
+ v-slot="{ errors }"
39
+ tag="div"
40
+ name="First Name"
41
+ rules="required"
42
+ class="form-row">
43
+ <label
44
+ for="firstName"
45
+ class="form-label">
46
+ First Name
47
+ </label>
48
+ <input
49
+ id="firstName"
50
+ v-model="customer.firstName"
51
+ name="firstName"
52
+ type="text"
53
+ class="form-field labelless"
54
+ placeholder="First Name"
55
+ :class="{
56
+ 'is-invalid': errors.length,
57
+ filled: customer.firstName
58
+ }" />
59
+ <span
60
+ v-if="errors.length"
61
+ class="form-help is-danger">
62
+ {{ errors[0] }}
63
+ </span>
64
+ </validation-provider>
65
+ <validation-provider
66
+ v-slot="{ errors }"
67
+ tag="div"
68
+ name="Phone"
69
+ class="form-row">
70
+ <label
71
+ for="phone"
72
+ class="form-label">
73
+ Phone (optional)
74
+ </label>
75
+ <input
76
+ id="phone"
77
+ v-model="customer.phone"
78
+ name="phone"
79
+ type="number"
80
+ class="form-field labelless"
81
+ placeholder="Phone"
82
+ :class="{
83
+ 'is-invalid': errors.length,
84
+ filled: customer.phone
85
+ }" />
86
+ <span
87
+ v-if="errors.length"
88
+ class="form-help is-danger">
89
+ {{ errors[0] }}
90
+ </span>
91
+ </validation-provider>
92
+ </div>
93
+ <div class="col-6">
94
+ <validation-provider
95
+ v-if="!customer._id"
96
+ v-slot="{ errors }"
97
+ tag="div"
98
+ name="Password"
99
+ rules="required"
100
+ class="form-row">
101
+ <label
102
+ for="password"
103
+ class="form-label">
104
+ Password
105
+ </label>
106
+ <input
107
+ id="password"
108
+ ref="password"
109
+ v-model="customer.password"
110
+ name="password"
111
+ type="password"
112
+ class="form-field labelless"
113
+ placeholder="Password"
114
+ :class="{
115
+ 'is-invalid': errors.length,
116
+ filled: customer.password
117
+ }" />
118
+ <span
119
+ v-if="errors.length"
120
+ class="form-help is-danger">
121
+ {{ errors[0] }}
122
+ </span>
123
+ </validation-provider>
124
+ <validation-provider
125
+ v-slot="{ errors }"
126
+ tag="div"
127
+ name="Last Name"
128
+ rules="required"
129
+ class="form-row">
130
+ <label
131
+ for="lastName"
132
+ class="form-label">
133
+ Last Name
134
+ </label>
135
+ <input
136
+ id="lastName"
137
+ v-model="customer.lastName"
138
+ name="lastName"
139
+ type="text"
140
+ class="form-field labelless"
141
+ placeholder="Last Name"
142
+ :class="{
143
+ 'is-invalid': errors.length,
144
+ filled: customer.lastName
145
+ }" />
146
+ <span
147
+ v-if="errors.length"
148
+ class="form-help is-danger">
149
+ {{ errors[0] }}
150
+ </span>
151
+ </validation-provider>
152
+ <validation-provider
153
+ v-slot="{ errors }"
154
+ tag="div"
155
+ name="Company"
156
+ class="form-row">
157
+ <label
158
+ for="company"
159
+ class="form-label">
160
+ Company (optional)
161
+ </label>
162
+ <input
163
+ id="company"
164
+ v-model="customer.company"
165
+ name="company"
166
+ type="text"
167
+ class="form-field labelless"
168
+ placeholder="Company"
169
+ :class="{
170
+ 'is-invalid': errors.length,
171
+ filled: customer.company
172
+ }" />
173
+ <span
174
+ v-if="errors.length"
175
+ class="form-help is-danger">
176
+ {{ errors[0] }}
177
+ </span>
178
+ </validation-provider>
179
+ </div>
180
+ </div>
181
+ <div
182
+ class="row"
183
+ style="margin-top: -20px">
184
+ <div class="col-12">
185
+ <postcode-select
186
+ :suburb="customer.suburb"
187
+ :labelless="true"
188
+ placeholder="Suburb"
189
+ @select="handleSuburbChange">
190
+ </postcode-select>
191
+ <div class="form-row">
192
+ <label class="form-label">
193
+ <checkbox v-model="customer.signUpForNewsletter" />
194
+ <span class="lc_regular12 lc__grey1">
195
+ Sign up for newsletter
196
+ </span>
197
+ </label>
198
+ </div>
199
+ </div>
200
+ </div>
154
201
  </div>
155
202
  <div class="form__footer mt-5">
203
+ <div
204
+ v-if="errorMessage"
205
+ class="CustomerForm__error">
206
+ {{ errorMessage }}
207
+ </div>
156
208
  <div class="form-actions full">
157
209
  <btn
158
- class="btn btn-green"
210
+ class="btn btn-black"
159
211
  :btn-processing="processing"
160
212
  :btn-disabled="processing"
161
213
  :btn-label="customer._id ? 'Save' : 'Create Account'"
@@ -169,10 +221,14 @@
169
221
 
170
222
  <script>
171
223
  import { mapGetters } from 'vuex';
224
+ import PostcodeSelect from '@lancom/shared/components/common/postcode_select/postcode-select';
172
225
  import api from '@lancom/shared/assets/js/api';
173
226
 
174
227
  export default {
175
228
  name: 'CustomerForm',
229
+ components: {
230
+ PostcodeSelect
231
+ },
176
232
  props: {
177
233
  customer: {
178
234
  type: Object,
@@ -190,6 +246,8 @@ export default {
190
246
  },
191
247
  methods: {
192
248
  async submit() {
249
+ this.errorMessage = null;
250
+
193
251
  const isValid = await this.$refs.form.validate();
194
252
  if (!isValid) {
195
253
  return;
@@ -205,6 +263,9 @@ export default {
205
263
  } finally {
206
264
  this.processing = false;
207
265
  }
266
+ },
267
+ handleSuburbChange(suburb) {
268
+ this.$set(this.customer, 'suburb', suburb);
208
269
  }
209
270
  }
210
271
  };
@@ -118,6 +118,8 @@ export default {
118
118
  methods: {
119
119
  ...mapActions('auth', ['auth_request']),
120
120
  async submit() {
121
+ this.error = null;
122
+
121
123
  const isValid = await this.$refs.form.validate();
122
124
  if (!isValid) {
123
125
  return;
@@ -125,8 +127,6 @@ export default {
125
127
 
126
128
  try {
127
129
  this.processing = true;
128
-
129
- this.error = null;
130
130
  const data = { customer: this.customer, shop: this.shop };
131
131
  const customer = await this.auth_request(data);
132
132
  if (this.authStatus === 'error') {
@@ -22,7 +22,10 @@ export default {
22
22
  lastName: null,
23
23
  email: null,
24
24
  phone: null,
25
- password: null
25
+ password: null,
26
+ company: null,
27
+ suburb: null,
28
+ signUpForNewsletter: false
26
29
  }
27
30
  };
28
31
  },
@@ -35,8 +35,8 @@
35
35
  margin-bottom: 10px;
36
36
  }
37
37
  &__content {
38
- margin-top: 20px;
39
- border-top: 2px solid #F4F4F4;
38
+ // margin-top: 20px;
39
+ // border-top: 2px solid #F4F4F4;
40
40
  padding-top: 20px;
41
41
  }
42
42
  &__btn {
@@ -1,11 +1,11 @@
1
1
  <template>
2
2
  <div class="QuoteRequest__wrapper">
3
- <div class="QuoteRequest__title">
3
+ <!-- <div class="QuoteRequest__title">
4
4
  Quick Quote
5
5
  </div>
6
6
  <div class="QuoteRequest__info">
7
7
  Fill our the form below and one of our team members will respond with a Quote ASAP!
8
- </div>
8
+ </div> -->
9
9
  <div class="QuoteRequest__content">
10
10
  <validation-observer
11
11
  v-slot="{ invalid, handleSubmit, errors: submittedErrors }"
package/nuxt.config.js CHANGED
@@ -31,7 +31,7 @@ module.exports = (config, axios) => ({
31
31
  '/customer/**'
32
32
  ],
33
33
  routes: async () => {
34
- const { data } = await axios.get(`${config.API_URL}/sitemap?host=${config.HOST_NAME}`);
34
+ const { data } = await axios.get(`${config.API_URL}/feed/sitemap?host=${config.HOST_NAME}`);
35
35
  return data.map(url => ({ url, priority: 0.8 }));
36
36
  }
37
37
  },
@@ -56,7 +56,8 @@ module.exports = (config, axios) => ({
56
56
  modules: [
57
57
  '@nuxtjs/axios',
58
58
  '@nuxtjs/dotenv',
59
- '@nuxtjs/sitemap'
59
+ '@nuxtjs/sitemap',
60
+ '@/node_modules/@lancom/feed/lib/module'
60
61
  ],
61
62
  axios: {
62
63
  },
@@ -71,5 +72,45 @@ module.exports = (config, axios) => ({
71
72
  '@lancom'
72
73
  ],
73
74
  extend(config, ctx) {}
74
- }
75
+ },
76
+ feed: [{
77
+ path: '/google-shopping.xml',
78
+ async get() {
79
+ const { data } = await axios.get(`${config.API_URL}/feed/products?host=${config.HOST_NAME}`);
80
+ return {
81
+ title: { _text: 'All products' },
82
+ link: { _text: `https://${config.HOST_NAME}` },
83
+ generator: { _text: config.HOST_NAME },
84
+ item: data.map(item => {
85
+ const spliceFirstImage = images => (images || []).splice(0, 1)[0];
86
+ const getImages = images => (images || []).length > 0 ? images : null;
87
+ const image = spliceFirstImage(item.colorImages) || spliceFirstImage(item.frontImages) || spliceFirstImage(item.backImages) || {};
88
+ const images = getImages(item.colorImages) || getImages(item.frontImages) || getImages(item.backImages) || [];
89
+ return {
90
+ title: { _text: `${item.name} ${item.color}-${item.size}` },
91
+ link: { _text: `https://${config.HOST_NAME}${item.link}` },
92
+ 'g:id': { _text: item.id },
93
+ 'g:item_group_id': { _text: item.groupId },
94
+ 'g:size': { _text: item.size },
95
+ 'g:size_system': 'AU',
96
+ 'g:size_type': 'regular',
97
+ 'g:gender': { _text: item.gender },
98
+ 'g:material': { _text: item.naterial },
99
+ 'g:brand': { _text: item.brand },
100
+ 'g:condition': { _text: item.condition },
101
+ 'g:mpn': { _text: item.mpn },
102
+ 'g:color': { _text: item.color },
103
+ 'g:image_link': image.medium,
104
+ 'g:additional_image_link': images.map(i => i.medium),
105
+ // 'g:google_product_category': 'Business & Industrial>Work Safety Protective Equipment>High-Visibility Clothing',
106
+ // 'g:product_type': 'WDP AU ROOT > Day Night Safety Vests',
107
+ // 'g:availability': 'in stock',
108
+ // 'g:price': '5.49AUD',
109
+ // 'g:identifier_exists': true,
110
+ // 'g:shipping_weight': { _text: item.weight }
111
+ };
112
+ })
113
+ };
114
+ }
115
+ }]
75
116
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lancom/shared",
3
- "version": "0.0.58",
3
+ "version": "0.0.64",
4
4
  "description": "lancom common scripts",
5
5
  "author": "e.tokovenko <e.tokovenko@gmail.com>",
6
6
  "repository": {
package/store/auth.js CHANGED
@@ -23,20 +23,19 @@ export const getters = {
23
23
  stateError: state => state.err
24
24
  };
25
25
  export const actions = {
26
- auth_request({ commit }, { user, customer, shop }) {
26
+ async auth_request({ commit }, { user, customer, shop }) {
27
27
  commit('AUTH_REQUEST');
28
28
  const request = customer ? api.authCustomer(customer, shop._id) : api.admin.authUser(user);
29
- return request
30
- .then(({ token, user }) => {
31
- Cookie.set('auth', token);
32
- this.$axios.defaults.headers.authorization = token;
33
- commit('AUTH_SUCCESS', token, user);
34
- return user;
35
- })
36
- .catch(err => {
37
- commit('AUTH_ERROR', err);
38
- Cookie.remove('auth');
39
- });
29
+ try {
30
+ const { token, user, customer } = await request;
31
+ Cookie.set('auth', token);
32
+ this.$axios.defaults.headers.authorization = token;
33
+ commit('AUTH_SUCCESS', token, customer || user);
34
+ return customer || user;
35
+ } catch (err) {
36
+ commit('AUTH_ERROR', err);
37
+ Cookie.remove('auth');
38
+ }
40
39
  },
41
40
  auth_logout({ commit }) {
42
41
  commit('AUTH_LOGOUT');