From f04830edded7f01a092e8a029703e0d09b13882d Mon Sep 17 00:00:00 2001 From: Sockenklaus Date: Fri, 29 Oct 2021 17:06:54 +0200 Subject: [PATCH] Some refactoring, added dynamic route for EmployeesDetails --- src/components/VNavigation.vue | 2 +- src/router/index.ts | 6 +++--- src/views/{Profile.vue => EmployeesDetails.vue} | 5 ++++- 3 files changed, 8 insertions(+), 5 deletions(-) rename src/views/{Profile.vue => EmployeesDetails.vue} (97%) diff --git a/src/components/VNavigation.vue b/src/components/VNavigation.vue index dab46ef..463ff5f 100644 --- a/src/components/VNavigation.vue +++ b/src/components/VNavigation.vue @@ -21,7 +21,7 @@ async function onLogout() { Profile diff --git a/src/router/index.ts b/src/router/index.ts index 03ccce0..8144a3b 100644 --- a/src/router/index.ts +++ b/src/router/index.ts @@ -22,9 +22,9 @@ const routes: Array = [ } }, { - path: '/employees/me', - name: 'Profile', - component: () => import('@/views/Profile.vue'), + path: '/employees/:id', + name: 'EmployeesDetails', + component: () => import('@/views/EmployeesDetails.vue'), meta: { requiresAuth: true, requiresAdmin: false diff --git a/src/views/Profile.vue b/src/views/EmployeesDetails.vue similarity index 97% rename from src/views/Profile.vue rename to src/views/EmployeesDetails.vue index 211d04c..22c365e 100644 --- a/src/views/Profile.vue +++ b/src/views/EmployeesDetails.vue @@ -23,6 +23,7 @@ import { reactive, onMounted } from 'vue' import { useUser } from '@/stores/user'; import axios from 'axios' import { useNotifications } from '@/stores/notifications'; +import { useRoute } from 'vue-router'; const userStore = useUser() const useNotification = useNotifications() @@ -61,7 +62,9 @@ onMounted(async () => { }) try { - const data : ResultData = await (await ai.get('employees/me')).data + const id = useRoute().params.id + + const data : ResultData = await (await ai.get('employees/'+id)).data Object.assign(employee, data.employee) Object.assign(user, data.user)