prettier fixes #16

This commit is contained in:
Michael Dausmann
2023-10-24 21:18:03 +11:00
parent dc9d64ebf5
commit a7f8c37f99
56 changed files with 1706 additions and 935 deletions

View File

@@ -1,45 +1,51 @@
import { defineStore } from "pinia"
import { defineStore } from 'pinia';
/*
This store manages User and Account state including the ActiveAccount
It is used in the Account administration page and the header due to it's account switching features.
*/
export interface Notification{
export interface Notification {
message: string;
type: NotificationType;
notifyTime: number;
}
export enum NotificationType{
export enum NotificationType {
Info,
Success,
Warning,
Error,
Error
}
interface State {
notifications: Notification[],
notificationsArchive: Notification[],
notifications: Notification[];
notificationsArchive: Notification[];
}
export const useNotifyStore = defineStore('notify', {
state: (): State => {
return {
notifications: [],
notificationsArchive: [],
}
notificationsArchive: []
};
},
actions: {
notify(messageOrError: unknown, type:NotificationType){
let message: string = "";
notify(messageOrError: unknown, type: NotificationType) {
let message: string = '';
if (messageOrError instanceof Error) message = messageOrError.message;
if (typeof messageOrError === "string") message = messageOrError;
const notification: Notification = {message, type, notifyTime: Date.now()};
if (typeof messageOrError === 'string') message = messageOrError;
const notification: Notification = {
message,
type,
notifyTime: Date.now()
};
this.notifications.push(notification);
setTimeout(this.removeNotification.bind(this), 5000, notification);
},
removeNotification(notification: Notification){
this.notifications = this.notifications.filter(n => n.notifyTime != notification.notifyTime);
},
removeNotification(notification: Notification) {
this.notifications = this.notifications.filter(
n => n.notifyTime != notification.notifyTime
);
}
}
});