From c767d924426bd12fda8d7a1cbcf36edc346d306f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 2 May 2023 06:40:48 +0200 Subject: [PATCH] add notification --- src/store/index.ts | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/src/store/index.ts b/src/store/index.ts index ed26a54..eca10eb 100644 --- a/src/store/index.ts +++ b/src/store/index.ts @@ -1,6 +1,7 @@ import { api, isAxiosError } from '@flaschengeist/api'; import { defineStore } from 'pinia'; import { EditableEvent } from './models'; +import { Notify } from 'quasar'; /** * 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}`); const idx = this.invitations.findIndex((v) => v.id === (invite.id || invite)); 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) { @@ -218,7 +222,30 @@ export const useEventStore = defineStore({ }); const idx = this.invitations.findIndex((v) => v.id === (invite.id || invite)); 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' }], + }); +}