2020-08-14 11:32:23 +02:00
|
|
|
<template>
|
|
|
|
<section v-if="invitations && invitations.length > 0">
|
|
|
|
<InvitationCard
|
|
|
|
v-for="member in invitations"
|
|
|
|
:key="member.id"
|
|
|
|
:member="member"
|
|
|
|
@accept="acceptInvitation"
|
|
|
|
@reject="rejectInvitation"
|
|
|
|
/>
|
|
|
|
</section>
|
|
|
|
</template>
|
|
|
|
<script lang="ts">
|
|
|
|
import { ACCEPT_INVITATION, REJECT_INVITATION } from "@/graphql/member";
|
|
|
|
import { IMember } from "@/types/actor";
|
|
|
|
import { Component, Prop, Vue } from "vue-property-decorator";
|
|
|
|
import InvitationCard from "@/components/Group/InvitationCard.vue";
|
2020-09-29 09:53:48 +02:00
|
|
|
import { SnackbarProgrammatic as Snackbar } from "buefy";
|
2020-08-14 11:32:23 +02:00
|
|
|
|
|
|
|
@Component({
|
|
|
|
components: {
|
|
|
|
InvitationCard,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
export default class Invitations extends Vue {
|
|
|
|
@Prop({ required: true, type: Array }) invitations!: IMember;
|
|
|
|
|
2020-09-29 09:53:48 +02:00
|
|
|
async acceptInvitation(id: string): Promise<void> {
|
|
|
|
try {
|
|
|
|
const { data } = await this.$apollo.mutate<{ acceptInvitation: IMember }>({
|
|
|
|
mutation: ACCEPT_INVITATION,
|
|
|
|
variables: {
|
|
|
|
id,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
if (data) {
|
|
|
|
this.$emit("acceptInvitation", data.acceptInvitation);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
Snackbar.open({ message: e.message, type: "is-danger", position: "is-bottom" });
|
2020-08-14 11:32:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-09-29 09:53:48 +02:00
|
|
|
async rejectInvitation(id: string): Promise<void> {
|
|
|
|
try {
|
|
|
|
const { data } = await this.$apollo.mutate<{ rejectInvitation: IMember }>({
|
|
|
|
mutation: REJECT_INVITATION,
|
|
|
|
variables: {
|
|
|
|
id,
|
|
|
|
},
|
|
|
|
});
|
|
|
|
if (data) {
|
|
|
|
this.$emit("rejectInvitation", data.rejectInvitation);
|
|
|
|
}
|
|
|
|
} catch (e) {
|
|
|
|
Snackbar.open({ message: e.message, type: "is-danger", position: "is-bottom" });
|
2020-08-14 11:32:23 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
</script>
|