feat: add popop with awfuls colors and backend api call

This commit is contained in:
Pierre Tellier
2025-02-08 12:11:20 +01:00
parent dfaa97346f
commit b228b78e17
7 changed files with 34 additions and 26 deletions

View File

@ -1,17 +1,20 @@
import {ref} from "vue";
enum errorType {Error, Warning}
function addNewError(errorMessage: string, timeout?: number, type?: errorType){
enum color {Red, Yellow, Blue, green}
function addNewMessage(errorMessage: string, type?: color, timeout?: number){
if (timeout == null){
timeout = 5000;
}
if (type == null){
type = Error;
type = color.Red;
}
errorList.value.push({errorMessage: errorMessage, timeout: timeout, type: type})
setTimeout(() => errorList.value.pop(errorMessage), 5000)
const data = {errorMessage: errorMessage, timeout: timeout, type: type, uid: Math.random()*100000};
errorList.value.push(data)
setTimeout(() => errorList.value.slice(0, 1), timeout)
}
const errorList = ref([])
export {addNewError, errorList}
export {addNewMessage, errorList, color}