add notification

This commit is contained in:
Tim Gröger 2023-05-02 06:40:48 +02:00
parent 8cd9182a8b
commit c767d92442
1 changed files with 29 additions and 2 deletions

View File

@ -1,6 +1,7 @@
import { api, isAxiosError } from '@flaschengeist/api'; import { api, isAxiosError } from '@flaschengeist/api';
import { defineStore } from 'pinia'; import { defineStore } from 'pinia';
import { EditableEvent } from './models'; import { EditableEvent } from './models';
import { Notify } from 'quasar';
/** /**
* Convert JSON decoded Job to real job (fix Date object) * Convert JSON decoded Job to real job (fix Date object)
@ -208,7 +209,10 @@ export const useEventStore = defineStore({
await api.delete(`/events/invitations/${typeof invite === 'number' ? invite : invite.id}`); await api.delete(`/events/invitations/${typeof invite === 'number' ? invite : invite.id}`);
const idx = this.invitations.findIndex((v) => v.id === (invite.id || invite)); const idx = this.invitations.findIndex((v) => v.id === (invite.id || invite));
if (idx >= 0) this.invitations.splice(idx, 1); if (idx >= 0) this.invitations.splice(idx, 1);
} catch (e) {} notify_success('Einladung für erfolgreich abgelehnt');
} catch (e) {
notify_failure();
}
}, },
async acceptInvitation(invite: FG.Invitation | number) { async acceptInvitation(invite: FG.Invitation | number) {
@ -218,7 +222,30 @@ export const useEventStore = defineStore({
}); });
const idx = this.invitations.findIndex((v) => v.id === (invite.id || invite)); const idx = this.invitations.findIndex((v) => v.id === (invite.id || invite));
if (idx >= 0) this.invitations.splice(idx, 1); if (idx >= 0) this.invitations.splice(idx, 1);
} catch (e) {} notify_success('Einladung für erfolgreich angenommen');
} catch (e) {
notify_failure();
}
}, },
}, },
}); });
function notify_failure() {
Notify.create({
message: 'Es ist ein Fehler aufgetreten.',
color: 'negative',
group: false,
timeout: 10000,
actions: [{ icon: 'mdi-close', color: 'white' }],
});
}
function notify_success(msg: string) {
Notify.create({
message: msg,
color: 'positive',
group: false,
timeout: 5000,
actions: [{ icon: 'mdi-close', color: 'white' }],
});
}