From 4b9f69c0d68a2706ce0e30fa369aca3ba3719488 Mon Sep 17 00:00:00 2001 From: Titus Kristiansen <titusk@stud.ntnu.no> Date: Fri, 6 May 2022 15:42:57 +0200 Subject: [PATCH] Router fixes --- .../CommunityComponents/CommunityHome.vue | 2 +- .../ItemComponents/EditItemForm.vue | 2 +- .../UserProfileComponents/UserProfile.vue | 2 +- src/router/index.js | 34 +++++++++++-------- 4 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/components/CommunityComponents/CommunityHome.vue b/src/components/CommunityComponents/CommunityHome.vue index 2e09b51..57ba73f 100644 --- a/src/components/CommunityComponents/CommunityHome.vue +++ b/src/components/CommunityComponents/CommunityHome.vue @@ -164,7 +164,7 @@ export default { } }, goToItemInfoPage(item) { - this.$router.push("/itempage/" + item); + this.$router.push("/item/" + item); }, getItemPictures: async function (itemid) { let res = await getItemPictures(itemid); diff --git a/src/components/ItemComponents/EditItemForm.vue b/src/components/ItemComponents/EditItemForm.vue index 17f4620..23f9bdc 100644 --- a/src/components/ItemComponents/EditItemForm.vue +++ b/src/components/ItemComponents/EditItemForm.vue @@ -377,7 +377,7 @@ export default { this.initialItem.listingID, this.updatedItem.images ); - this.$router.push("/itempage/" + this.initialItem.listingID); + this.$router.push("/item/" + this.initialItem.listingID); } }, diff --git a/src/components/UserProfileComponents/UserProfile.vue b/src/components/UserProfileComponents/UserProfile.vue index c2d2a05..b2ab1f8 100644 --- a/src/components/UserProfileComponents/UserProfile.vue +++ b/src/components/UserProfileComponents/UserProfile.vue @@ -38,7 +38,7 @@ > <li> <router-link - to="/user/userItems" + to="/profile/items" class="block py-2 px-4 text-sm text-gray-700 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white" >Mine gjenstander</router-link > diff --git a/src/router/index.js b/src/router/index.js index 076a261..77ddb19 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -64,15 +64,15 @@ const routes = [ component: () => import("../views/HelpView.vue"), }, { - path: "/item/:id/edit", - name: "editItem", - component: () => import("../views/ItemViews/EditItemView.vue"), + path: "/item/:id", + name: "itemInfo", + component: () => import("../views/RentingViews/ItemInfoPageView.vue"), beforeEnter: guardRoute, }, { - path: "/itempage/:id", - name: "itemInfo", - component: () => import("../views/RentingViews/ItemInfoPageView.vue"), + path: "/item/:id/edit", + name: "editItem", + component: () => import("../views/ItemViews/EditItemView.vue"), beforeEnter: guardRoute, }, { @@ -122,6 +122,12 @@ const routes = [ component: () => import("../views/UserProfileViews/RentHistoryView.vue"), beforeEnter: guardRoute, }, + { + path: "/profile/items", + name: "userItems", + component: () => import("../views/UserProfileViews/UserItemsView.vue"), + beforeEnter: guardRoute, + }, { path: "/register", name: "register", @@ -143,15 +149,15 @@ const routes = [ component: () => import("../views/TestView.vue"), beforeEnter: guardRoute, }, - { - path: "/user/userItems", - name: "userItems", - component: () => import("../views/UserProfileViews/UserItemsView.vue"), - beforeEnter: guardRoute, - }, - // Make sure it's your last route definition - { path: "/:pathMatch(.*)*", name: "not-found", component: NotFound }, + /** + * Catch all for wrong/non-existing routes + * Must be last to catch all + */ + { path: "/:pathMatch(.*)*", + name: "not-found", + component: NotFound + }, ]; const router = createRouter({ -- GitLab