@burh/nuxt-core 1.1.24 → 1.1.27

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.
@@ -22,7 +22,7 @@
22
22
  "
23
23
  />
24
24
  <h6
25
- v-if="userData && userData.user_complementary_information && userData.user_complementary_information.birth && getAge() > 0 || false"
25
+ v-if="userHasBirthDate"
26
26
  >
27
27
  {{ getAge() }} {{ $t('user_cv.left_side.years_old') }}
28
28
  </h6>
@@ -273,7 +273,6 @@
273
273
  <script>
274
274
  import getPrefixes from '~/util/getPrefixes.js';
275
275
  import VueQrcode from '@chenfengyuan/vue-qrcode';
276
- import moment from 'moment';
277
276
 
278
277
  import Profile from '../../Aboutme/Profile.vue';
279
278
 
@@ -291,6 +290,10 @@ export default {
291
290
  },
292
291
  currentCompany() {
293
292
  return this.$store.state.company.currentCompany;
293
+ },
294
+ userHasBirthDate() {
295
+ const birth = this.userData && this.userData.user_complementary_information && this.userData.user_complementary_information.birth;
296
+ return !!this.parseBirthDate(birth);
294
297
  }
295
298
  },
296
299
  props: {
@@ -319,9 +322,48 @@ export default {
319
322
  handleAboutmeDownloadClick() {
320
323
  this.$emit('aboutme-download');
321
324
  },
322
- getAge(){
323
- const userAge = this.userData.user_complementary_information.birth;
324
- return moment().diff(userAge, 'years');
325
+ parseBirthDate(birth) {
326
+ if (!birth) return null;
327
+
328
+ if (birth instanceof Date) {
329
+ return isNaN(birth.getTime()) ? null : birth;
330
+ }
331
+
332
+ if (typeof birth === 'number') {
333
+ const d = new Date(birth);
334
+ return isNaN(d.getTime()) ? null : d;
335
+ }
336
+
337
+ if (typeof birth === 'string') {
338
+ const trimmed = birth.trim();
339
+ const match = trimmed.match(/^(\d{4})-(\d{2})-(\d{2})$/);
340
+ if (match) {
341
+ const year = Number(match[1]);
342
+ const monthIndex = Number(match[2]) - 1;
343
+ const day = Number(match[3]);
344
+ const d = new Date(year, monthIndex, day);
345
+ return isNaN(d.getTime()) ? null : d;
346
+ }
347
+
348
+ const d = new Date(trimmed);
349
+ return isNaN(d.getTime()) ? null : d;
350
+ }
351
+
352
+ return null;
353
+ },
354
+ getAge() {
355
+ const birth = this.userData && this.userData.user_complementary_information && this.userData.user_complementary_information.birth;
356
+ const birthDate = this.parseBirthDate(birth);
357
+ if (!birthDate) return '';
358
+
359
+ const today = new Date();
360
+ let years = today.getFullYear() - birthDate.getFullYear();
361
+ const monthDiff = today.getMonth() - birthDate.getMonth();
362
+ if (monthDiff < 0 || (monthDiff === 0 && today.getDate() < birthDate.getDate())) {
363
+ years -= 1;
364
+ }
365
+
366
+ return years >= 0 ? years : 0;
325
367
  },
326
368
  highlightText(search, text) {
327
369
  if (search.length < 2) return text;
@@ -1,73 +1,73 @@
1
- <template>
2
- <img
3
- :src="(this.src) ? this.src : getAvatarUrl()"
4
- :alt="this.alt"
5
- @error="img => getImageFallback(img)"
6
- >
7
- </template>
8
-
9
- <script>
10
- export default {
11
- name: 'image-with-fallback',
12
- props: {
13
- src: {
14
- type: [String, Boolean],
15
- default: null
16
- },
17
- alt: {
18
- type: String,
19
- required: true
20
- },
21
- fallbackSize: {
22
- type: String,
23
- default: '512'
24
- },
25
- fallbackBackground: {
26
- type: [String, Boolean],
27
- default: null
28
- },
29
- fallbackText: {
30
- type: String,
31
- required: true
32
- },
33
- fallbackSingle: {
34
- type: Boolean,
35
- default: true
36
- }
37
- },
38
- methods: {
39
- getAvatarUrl() {
40
- let size = this.fallbackSize;
41
- let text = this.getNameInitials();
42
- // let background = this.fallbackBackground;
43
-
44
- const url = new URL('https://api.dicebear.com/7.x/initials/svg');
45
-
46
- url.searchParams.append('seed', text);
47
- url.searchParams.append('backgroundColor', '8DA2B5');
48
- url.searchParams.append('size', size);
49
- url.searchParams.append('fontSize', '40');
50
-
51
- return url.toString();
52
- },
53
- getImageFallback(img) {
54
- img.target.src = this.getAvatarUrl();
55
- },
56
- getNameInitials() {
57
- let userAvatarName;
58
-
59
- if (this.fallbackText) {
60
- if (this.fallbackSingle) {
61
- userAvatarName = this.fallbackText.slice(0, 1).toUpperCase();
62
- } else {
63
- userAvatarName = this.fallbackText;
64
- }
65
- } else {
66
- userAvatarName = 'BURH';
67
- }
68
-
69
- return userAvatarName;
70
- },
71
- }
72
- };
73
- </script>
1
+ <template>
2
+ <img
3
+ :src="(this.src) ? this.src : getAvatarUrl()"
4
+ :alt="this.alt"
5
+ @error="img => getImageFallback(img)"
6
+ >
7
+ </template>
8
+
9
+ <script>
10
+ export default {
11
+ name: 'image-with-fallback',
12
+ props: {
13
+ src: {
14
+ type: [String, Boolean],
15
+ default: null
16
+ },
17
+ alt: {
18
+ type: String,
19
+ required: true
20
+ },
21
+ fallbackSize: {
22
+ type: String,
23
+ default: '512'
24
+ },
25
+ fallbackBackground: {
26
+ type: [String, Boolean],
27
+ default: null
28
+ },
29
+ fallbackText: {
30
+ type: String,
31
+ required: true
32
+ },
33
+ fallbackSingle: {
34
+ type: Boolean,
35
+ default: true
36
+ }
37
+ },
38
+ methods: {
39
+ getAvatarUrl() {
40
+ let size = this.fallbackSize;
41
+ let text = this.getNameInitials();
42
+ // let background = this.fallbackBackground;
43
+
44
+ const url = new URL('https://api.dicebear.com/7.x/initials/svg');
45
+
46
+ url.searchParams.append('seed', text);
47
+ url.searchParams.append('backgroundColor', '8DA2B5');
48
+ url.searchParams.append('size', size);
49
+ url.searchParams.append('fontSize', '40');
50
+
51
+ return url.toString();
52
+ },
53
+ getImageFallback(img) {
54
+ img.target.src = this.getAvatarUrl();
55
+ },
56
+ getNameInitials() {
57
+ let userAvatarName;
58
+
59
+ if (this.fallbackText) {
60
+ if (this.fallbackSingle) {
61
+ userAvatarName = this.fallbackText.slice(0, 1).toUpperCase();
62
+ } else {
63
+ userAvatarName = this.fallbackText;
64
+ }
65
+ } else {
66
+ userAvatarName = 'BURH';
67
+ }
68
+
69
+ return userAvatarName;
70
+ },
71
+ }
72
+ };
73
+ </script>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@burh/nuxt-core",
3
- "version": "1.1.24",
3
+ "version": "1.1.27",
4
4
  "description": "Design System and Components.",
5
5
  "author": "Burh",
6
6
  "private": false,