Skip to content

Commit

Permalink
added store
Browse files Browse the repository at this point in the history
  • Loading branch information
Nacnus committed Jan 18, 2024
1 parent 24a86c4 commit 34b9691
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 18 deletions.
20 changes: 5 additions & 15 deletions pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
>
<v-avatar class="profile-image" size="68">
<v-img
:src="usersData.profile_photo"
:src="$store.state.usersData.profile_photo"
/>
</v-avatar>
<v-img
:src="usersData.banner_photo"
:src="$store.state.usersData.banner_photo"
class="background-image"
/>
<v-card-title class="mt-8 align-center justify-center" style="font-size: 16px">
{{ usersData.first_name }} {{ usersData.last_name }}
{{ $store.state.usersData.first_name }} {{ $store.state.usersData.last_name }}
</v-card-title>

<v-card-subtitle class="text-center" style="font-size: 12px">
{{ usersData.biography }}
{{ $store.state.usersData.biography }}
</v-card-subtitle>
<v-divider />
<v-card-text style="font-size: 12px">
Expand All @@ -40,7 +40,7 @@
<v-row>
<v-avatar class="mt-3 ml-4" size="48">
<v-img
:src="usersData.profile_photo"
:src="$store.state.usersData.profile_photo"
/>
</v-avatar>
<v-btn
Expand Down Expand Up @@ -112,7 +112,6 @@ export default {
middleware: authControl,
data () {
return {
usersData: {},
postItems: [
{
icon: 'mdi-image-outline',
Expand All @@ -132,16 +131,7 @@ export default {
]
}
},
mounted () {
this.getUserData()
},
methods: {
getUserData () {
this.$auth.fetchUser()
.then((response) => {
this.usersData = response.data
})
},
logout () {
this.$auth.logout()
.then(() => {
Expand Down
20 changes: 17 additions & 3 deletions store/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,21 @@
export const state = () => ({})
export const state = () => ({
usersData: {}
})

export const mutations = {}
export const mutations = {
setUserData (state, userData) {
state.usersData = userData
}
}

export const actions = {}
export const actions = {
getData ({ commit }) {
this.$auth.fetchUser()
.then((response) => {
commit('setUserData', response.data)
})
}

}

export const getters = {}

0 comments on commit 34b9691

Please sign in to comment.