remove invitation when reject or accept

This commit is contained in:
Tim Gröger 2023-05-02 06:23:36 +02:00
parent 46939d4b64
commit 8cd9182a8b
2 changed files with 36 additions and 26 deletions

View File

@ -245,18 +245,19 @@ export default defineComponent({
tooltip: 'Einladung löschen', tooltip: 'Einladung löschen',
color: 'negative', color: 'negative',
onClick: () => { onClick: () => {
void store.rejectInvitation(row.id); void store.rejectInvitation(row.id).then(() => {
onRequest({ onRequest({
pagination: pagination.value, pagination: pagination.value,
filter: () => [], filter: () => [],
getCellValue: () => [], getCellValue: () => [],
});
const notification = all_notifications.value.find(
(n) => (<InvitationData>n.data).invitation === row.id
);
if (notification !== undefined) {
void mainStore.removeNotification(notification.id);
}
}); });
const notification = all_notifications.value.find(
(n) => (<InvitationData>n.data).invitation === row.id
);
if (notification !== undefined) {
void mainStore.removeNotification(notification.id);
}
}, },
}; };
const accept = { const accept = {
@ -264,18 +265,19 @@ export default defineComponent({
tooltip: 'Einladung annehmen', tooltip: 'Einladung annehmen',
color: 'primary', color: 'primary',
onClick: () => { onClick: () => {
void store.acceptInvitation(row.id); void store.acceptInvitation(row.id).then(() => {
onRequest({ onRequest({
pagination: pagination.value, pagination: pagination.value,
filter: () => [], filter: () => [],
getCellValue: () => [], getCellValue: () => [],
});
const notification = all_notifications.value.find(
(n) => (<InvitationData>n.data).invitation === row.id
);
if (notification !== undefined) {
void mainStore.removeNotification(notification.id);
}
}); });
const notification = all_notifications.value.find(
(n) => (<InvitationData>n.data).invitation === row.id
);
if (notification !== undefined) {
void mainStore.removeNotification(notification.id);
}
}, },
}; };
if (sender) { if (sender) {

View File

@ -204,13 +204,21 @@ export const useEventStore = defineStore({
}, },
async rejectInvitation(invite: FG.Invitation | number) { async rejectInvitation(invite: FG.Invitation | number) {
return api.delete(`/events/invitations/${typeof invite === 'number' ? invite : invite.id}`); try {
await api.delete(`/events/invitations/${typeof invite === 'number' ? invite : invite.id}`);
const idx = this.invitations.findIndex((v) => v.id === (invite.id || invite));
if (idx >= 0) this.invitations.splice(idx, 1);
} catch (e) {}
}, },
async acceptInvitation(invite: FG.Invitation | number) { async acceptInvitation(invite: FG.Invitation | number) {
return api.put(`/events/invitations/${typeof invite === 'number' ? invite : invite.id}`, { try {
accept: true, await api.put(`/events/invitations/${typeof invite === 'number' ? invite : invite.id}`, {
}); accept: true,
});
const idx = this.invitations.findIndex((v) => v.id === (invite.id || invite));
if (idx >= 0) this.invitations.splice(idx, 1);
} catch (e) {}
}, },
}, },
}); });