Pierre Tellier 645a10477d
All checks were successful
CI / build (push) Successful in 4s
feat: now respect codestyle
2025-02-09 15:59:30 +01:00

44 lines
843 B
TypeScript

import { ref, type Ref } from "vue";
enum color {
Red,
Yellow,
Blue,
Green,
}
type ErrorMessageContent = {
message: string;
color: color;
id: number;
timeout: number;
};
let id: number = 0;
const getId = () => {
id = id + 1;
return id;
};
function addNewMessage(errorMessage: string, type?: color, timeout?: number) {
if (timeout == null) {
timeout = 5000;
}
if (type == null) {
type = color.Red;
}
const data: ErrorMessageContent = {
message: errorMessage,
timeout: timeout,
color: type,
id: getId(),
};
errorList.value.push(data);
setTimeout(() => errorList.value.slice(0, 1), timeout);
}
const errorList: Ref<ErrorMessageContent[]> = ref([]);
export { addNewMessage, errorList, color, type ErrorMessageContent };