Created
August 8, 2023 16:42
-
-
Save reboottime/1a7612f048d6934264aecbf5a91bbeb2 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { type NotificationProps } from '@mantine/core'; | |
import { notifications } from '@mantine/notifications'; | |
import { IconCheck, IconInfoCircle, IconX } from '@tabler/icons-react'; | |
const toast = { | |
error: (message: string, options?: NotificationProps) => { | |
notifications.show({ | |
...options, | |
color: 'red', | |
icon: <IconX size="1.1rem" />, | |
message, | |
title: 'Error' | |
}); | |
}, | |
success: (message: string, options: NotificationProps) => { | |
notifications.show({ | |
...options, | |
color: 'green', | |
icon: <IconCheck size="1.1rem" />, | |
message, | |
title: 'Succcess' | |
}); | |
}, | |
info: (message: string, options?: NotificationProps) => { | |
notifications.show({ | |
...options, | |
color: 'cyan', | |
icon: <IconInfoCircle size="1.1rem" />, | |
message, | |
title: 'Info' | |
}); | |
}, | |
updateNotification: (options: NotificationProps & { id: string; message: string }) => { | |
notifications.update(options); | |
} | |
}; | |
export default toast; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment