From 859ba61aa20a0d5a2da31b9895bf999ba1ed2870 Mon Sep 17 00:00:00 2001 From: Gilgard <Hjelljord.alida@gmail.com> Date: Wed, 4 May 2022 12:53:47 +0200 Subject: [PATCH] Updated my communities page --- src/router/index.js | 12 +++---- .../CommunityViews/MyCommunitiesView.vue | 32 ----------------- .../UserProfileViews/MyCommunitiesView.vue | 35 +++++++++++++++++++ 3 files changed, 41 insertions(+), 38 deletions(-) delete mode 100644 src/views/CommunityViews/MyCommunitiesView.vue create mode 100644 src/views/UserProfileViews/MyCommunitiesView.vue diff --git a/src/router/index.js b/src/router/index.js index 5fbb09f..9aaaf0c 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -37,6 +37,12 @@ const routes = [ component: () => import("../views/UserProfileViews/RentHistoryView.vue"), beforeEnter: guardRoute, }, + { + path: "/profile/communities", + name: "myCommunities", + component: () => import("../views/UserProfileViews/MyCommunitiesView.vue"), + beforeEnter: guardRoute, + }, { path: "/register", name: "register", @@ -94,12 +100,6 @@ const routes = [ import("../components/BaseComponents/NotificationsForm.vue"), beforeEnter: guardRoute, }, - { - path: "/user/:id/communities", - name: "myCommunities", - component: () => import("../views/CommunityViews/MyCommunitiesView.vue"), - beforeEnter: guardRoute, - }, { path: "/community/:communityID", name: "communityHome", diff --git a/src/views/CommunityViews/MyCommunitiesView.vue b/src/views/CommunityViews/MyCommunitiesView.vue deleted file mode 100644 index b2abf6c..0000000 --- a/src/views/CommunityViews/MyCommunitiesView.vue +++ /dev/null @@ -1,32 +0,0 @@ -<template> - <div> - <div id="myGroups"> - <div>Mine grupper:</div> - <group-list :groupList="myGroups" /> - </div> - </div> -</template> - -<script> -import GroupList from "@/components/CommunityComponents/CommunityList.vue"; -import { getMyGroups } from "@/utils/apiutil"; - -export default { - data() { - return { - myGroups: [], - }; - }, - components: { - GroupList, - }, - methods: { - async getMyGroups() { - this.myGroups = await getMyGroups(); - }, - }, - beforeMount() { - this.getMyGroups(); - }, -}; -</script> diff --git a/src/views/UserProfileViews/MyCommunitiesView.vue b/src/views/UserProfileViews/MyCommunitiesView.vue new file mode 100644 index 0000000..6a5c376 --- /dev/null +++ b/src/views/UserProfileViews/MyCommunitiesView.vue @@ -0,0 +1,35 @@ +<template> + <!-- My communities, with pagination --> + <div class="flex flex-row p-4 relative"> + <div class="text-xl md:text-2xl text-primary-light font-medium w-full"> + Mine grupper + </div> + <UserAddIcon + class="cursor-pointer max-h-6 max-w-6 float-right grow text-primary-dark" + @click="$router.push('/newCommunity')" + alt="Opprett ny gruppe" + /> + </div> + <CommunityList :communities="myCommunities" :member="true" /> +</template> + +<script> +import CommunityList from "@/components/CommunityComponents/CommunityList.vue"; +import CommunityService from "@/services/community.service"; +import { UserAddIcon } from "@heroicons/vue/outline"; + +export default { + data() { + return { + myCommunities: [], + }; + }, + components: { + CommunityList, + UserAddIcon, + }, + async beforeCreate() { + this.myCommunities = await CommunityService.getUserCommunities(); + }, +}; +</script> -- GitLab