43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import {notifications} from "@mantine/notifications";
|
|
|
|
type CustomNotifications = {
|
|
notify: (...params: Parameters<typeof notifications.show>) => void,
|
|
success: (...params: Parameters<typeof notifications.show>) => void,
|
|
warn: (...params: Parameters<typeof notifications.show>) => void,
|
|
error: (...params: Parameters<typeof notifications.show>) => void,
|
|
guess: (ok: boolean, ...params: Parameters<typeof notifications.show>) => void,
|
|
} & typeof notifications;
|
|
|
|
const customNotifications: CustomNotifications = {
|
|
...notifications,
|
|
notify: (params) => {
|
|
return notifications.show({
|
|
...params,
|
|
color: 'blue'
|
|
})
|
|
},
|
|
success: (params) => {
|
|
return notifications.show({
|
|
...params,
|
|
color: 'green'
|
|
})
|
|
},
|
|
warn: (params) => {
|
|
return notifications.show({
|
|
...params,
|
|
color: 'yellow'
|
|
})
|
|
},
|
|
error: (params) => {
|
|
return notifications.show({
|
|
...params,
|
|
color: 'red'
|
|
})
|
|
},
|
|
guess: (ok: boolean, params) => {
|
|
if (ok) return customNotifications.success(params);
|
|
else return customNotifications.error(params);
|
|
}
|
|
}
|
|
|
|
export {customNotifications as notifications}; |