2023-12-31 12:39:01 +01:00
|
|
|
const { notify } = useNotification()
|
|
|
|
|
|
|
|
|
|
export const useAlert = () => {
|
|
|
|
|
function success(message, autoClose = 10000) {
|
|
|
|
|
notify({
|
2024-04-15 19:39:03 +02:00
|
|
|
title: "Success",
|
2023-12-31 12:39:01 +01:00
|
|
|
text: message,
|
2024-04-15 19:39:03 +02:00
|
|
|
type: "success",
|
|
|
|
|
duration: autoClose,
|
2023-12-31 12:39:01 +01:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function error(message, autoClose = 10000) {
|
|
|
|
|
notify({
|
2024-04-15 19:39:03 +02:00
|
|
|
title: "Error",
|
2023-12-31 12:39:01 +01:00
|
|
|
text: message,
|
2024-04-15 19:39:03 +02:00
|
|
|
type: "error",
|
|
|
|
|
duration: autoClose,
|
2023-12-31 12:39:01 +01:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function warning(message, autoClose = 10000) {
|
|
|
|
|
notify({
|
2024-04-15 19:39:03 +02:00
|
|
|
title: "Warning",
|
2023-12-31 12:39:01 +01:00
|
|
|
text: message,
|
2024-04-15 19:39:03 +02:00
|
|
|
type: "warning",
|
|
|
|
|
duration: autoClose,
|
2023-12-31 12:39:01 +01:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-15 19:39:03 +02:00
|
|
|
function confirm(message, success, failure = () => {}, autoClose = 10000) {
|
2023-12-31 12:39:01 +01:00
|
|
|
notify({
|
2024-04-15 19:39:03 +02:00
|
|
|
title: "Confirm",
|
2023-12-31 12:39:01 +01:00
|
|
|
text: message,
|
2024-04-15 19:39:03 +02:00
|
|
|
type: "confirm",
|
2023-12-31 12:39:01 +01:00
|
|
|
duration: autoClose,
|
|
|
|
|
data: {
|
|
|
|
|
success,
|
2024-04-15 19:39:03 +02:00
|
|
|
failure,
|
|
|
|
|
},
|
2023-12-31 12:39:01 +01:00
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
|
success,
|
|
|
|
|
error,
|
|
|
|
|
warning,
|
2024-04-15 19:39:03 +02:00
|
|
|
confirm,
|
2023-12-31 12:39:01 +01:00
|
|
|
}
|
|
|
|
|
}
|