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 @@
</li>
<li id="leaveGroup">
<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
</div>
......@@ -37,10 +38,26 @@
</template>
<script>
import { LeaveCommunity } from "@/utils/apiutil";
export default {
name: "CommunityHamburger",
props: {
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>
......@@ -223,3 +223,17 @@ export async function GetIfUserAlreadyInCommunity(communityID) {
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