From 7a8b88f19d1d70c178cb09475a97376b67f1fc39 Mon Sep 17 00:00:00 2001
From: Gilgard <Hjelljord.alida@gmail.com>
Date: Wed, 27 Apr 2022 17:47:53 +0200
Subject: [PATCH] my groups view

---
 .../LargeProfileCard.vue                      | 17 +++++-----
 src/router/index.js                           |  8 ++++-
 src/views/MyGroupsView.vue                    | 32 +++++++++++++++++++
 3 files changed, 48 insertions(+), 9 deletions(-)
 create mode 100644 src/views/MyGroupsView.vue

diff --git a/src/components/UserProfileComponents/LargeProfileCard.vue b/src/components/UserProfileComponents/LargeProfileCard.vue
index f8ec7c0..c395505 100644
--- a/src/components/UserProfileComponents/LargeProfileCard.vue
+++ b/src/components/UserProfileComponents/LargeProfileCard.vue
@@ -37,7 +37,7 @@
           </li>
           <li>
             <router-link
-              to=""
+              :to="'/user/' + id + '/groups'"
               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 grupper
             </router-link>
@@ -51,9 +51,10 @@
           </li>
           <li>
             <div
-                @click="logout"
-                class="cursor-pointer 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"
-            >Logg ut
+              @click="logout"
+              class="cursor-pointer 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"
+            >
+              Logg ut
             </div>
           </li>
           <li>
@@ -143,10 +144,10 @@ export default {
       }
       return "../assets/defaultUserProfileImage.jpg";
     },
-    logout(){
-      this.$store.commit('logout');
-      this.$router.push('/')
-    }
+    logout() {
+      this.$store.commit("logout");
+      this.$router.push("/");
+    },
   },
   beforeMount() {
     this.getUser();
diff --git a/src/router/index.js b/src/router/index.js
index aaf7303..c08939d 100644
--- a/src/router/index.js
+++ b/src/router/index.js
@@ -89,7 +89,13 @@ const routes = [
     name: "notifications",
     component: () => import("../views/NotificationView.vue"),
     beforeEnter: guardRoute,
-  }
+  },
+  {
+    path: "/user/:id/groups",
+    name: "myGroups",
+    component: () => import("../views/MyGroupsView.vue"),
+    beforeEnter: guardRoute,
+  },
 ];
 
 const router = createRouter({
diff --git a/src/views/MyGroupsView.vue b/src/views/MyGroupsView.vue
new file mode 100644
index 0000000..74714cd
--- /dev/null
+++ b/src/views/MyGroupsView.vue
@@ -0,0 +1,32 @@
+<template>
+  <div>
+    <div id="myGroups">
+      <div>Mine grupper:</div>
+      <group-list :groupList="myGroups" />
+    </div>
+  </div>
+</template>
+
+<script>
+import GroupList from "@/components/GroupeComponents/GroupList.vue";
+import { getMyGroups } from "@/utils/apiutil";
+
+export default {
+  data() {
+    return {
+      myGroups: [],
+    };
+  },
+  components: {
+    GroupList,
+  },
+  methods: {
+    async getMyGroups() {
+      this.myGroups = await getMyGroups();
+    },
+  },
+  beforeMount() {
+    this.getMyGroups();
+  },
+};
+</script>
-- 
GitLab