Skip to content

Commit c119406

Browse files
committed
upd: main store avatar logic
1 parent 5231122 commit c119406

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

src/stores/main.js

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,18 @@
11
import { defineStore } from 'pinia'
2-
import { ref } from 'vue'
2+
import { ref, computed } from 'vue'
33
import axios from 'axios'
44

55
export const useMainStore = defineStore('main', () => {
6-
const userName = ref('john doe')
7-
const userEmail = ref('[email protected]')
8-
const userAvatar = ref('https://avatars.dicebear.com/api/avataaars/example.svg')
6+
const userName = ref('John Doe')
7+
const userEmail = ref('[email protected]')
98

10-
// ... or you can use computed:
11-
// const userAvatar = computed(
12-
// () =>
13-
// `https://avatars.dicebear.com/api/avataaars/${userName.value.replace(
14-
// /[^a-z0-9]+/i,
15-
// ''
16-
// )}.svg`
17-
// )
9+
const userAvatar = computed(
10+
() =>
11+
`https://avatars.dicebear.com/api/avataaars/${userEmail.value.replace(
12+
/[^a-z0-9]+/gi,
13+
'-'
14+
)}.svg`
15+
)
1816

1917
const isFieldFocusRegistered = ref(false)
2018

@@ -28,9 +26,6 @@ export const useMainStore = defineStore('main', () => {
2826
if (payload.email) {
2927
userEmail.value = payload.email
3028
}
31-
if (payload.avatar) {
32-
userAvatar.value = payload.avatar
33-
}
3429
}
3530

3631
function fetchSampleClients() {

0 commit comments

Comments
 (0)