Client - add link to users in admin

This commit is contained in:
Sam
2021-10-31 18:11:18 +01:00
parent 332983d9ea
commit fca417d9ad
15 changed files with 218 additions and 5 deletions

View File

@ -0,0 +1,69 @@
<template>
<div id="user" v-if="user.username">
<UserHeader :user="user" />
<div class="box">
<UserInfos :user="user" :from-admin="true" />
</div>
</div>
</template>
<script lang="ts">
import {
ComputedRef,
computed,
defineComponent,
onBeforeMount,
onBeforeUnmount,
} from 'vue'
import { useRoute } from 'vue-router'
import UserHeader from '@/components/User/ProfileDisplay/UserHeader.vue'
import UserInfos from '@/components/User/ProfileDisplay/UserInfos.vue'
import { USERS_STORE } from '@/store/constants'
import { IUserProfile } from '@/types/user'
import { useStore } from '@/use/useStore'
export default defineComponent({
name: 'UserView',
components: {
UserHeader,
UserInfos,
},
setup() {
const route = useRoute()
const store = useStore()
const user: ComputedRef<IUserProfile> = computed(
() => store.getters[USERS_STORE.GETTERS.USER]
)
onBeforeMount(() => {
if (
route.params.username &&
typeof route.params.username === 'string'
) {
store.dispatch(USERS_STORE.ACTIONS.GET_USER, route.params.username)
}
})
onBeforeUnmount(() => {
store.dispatch(USERS_STORE.ACTIONS.EMPTY_USER)
})
return { user }
},
})
</script>
<style lang="scss" scoped>
@import '~@/scss/base.scss';
#user {
margin: auto;
width: 700px;
@media screen and (max-width: $medium-limit) {
width: 100%;
margin: 0 auto 50px auto;
}
}
</style>