Skip to content
Snippets Groups Projects
Commit 6ef252a5 authored by Zara Mudassar's avatar Zara Mudassar
Browse files

Functionality added for leaving a community

parent 5b25b4f8
No related branches found
No related tags found
1 merge request!77Leave community
Pipeline #179285 passed
...@@ -27,7 +27,8 @@ ...@@ -27,7 +27,8 @@
</li> </li>
<li id="leaveGroup"> <li id="leaveGroup">
<div <div
class="cursor-pointer block py-2 px-4 text-sm text-red-600 hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white" class="cursor-pointer block py-2 px-4 text-sm text-error hover:bg-gray-100 dark:hover:bg-gray-600 dark:text-gray-200 dark:hover:text-white"
@click="leaveCommunity"
> >
Forlat Gruppe Forlat Gruppe
</div> </div>
...@@ -37,10 +38,26 @@ ...@@ -37,10 +38,26 @@
</template> </template>
<script> <script>
import { LeaveCommunity } from "@/utils/apiutil";
export default { export default {
name: "CommunityHamburger", name: "CommunityHamburger",
props: { props: {
communityID: Number, communityID: Number,
}, },
data(){
return{
id: -1,
}
},
methods:{
leaveCommunity: async function(){
this.id = await this.$router.currentRoute.value.params.communityID;
await LeaveCommunity(this.id);
this.$router.push('/');
}
}
}; };
</script> </script>
...@@ -223,3 +223,17 @@ export async function GetIfUserAlreadyInCommunity(communityID) { ...@@ -223,3 +223,17 @@ export async function GetIfUserAlreadyInCommunity(communityID) {
return error; return error;
}); });
} }
export async function LeaveCommunity(communityID) {
return axios
.patch(API_URL + "communities/" + communityID + "/leave", communityID, {
headers: tokenHeader(),
})
.then((response) => {
return response.data;
})
.catch((error) => {
console.log(error.data);
return error;
});
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment