Skip to content

Commit 5769106

Browse files
committed
first commit
1 parent 6ca8ed8 commit 5769106

11 files changed

+430
-149
lines changed

hooks/use-notification.ts

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
import { TypeOptions, toast } from "react-toastify";
2+
3+
function useNotification() {
4+
const showNotification = (message: string, type: TypeOptions) => {
5+
toast(message, {
6+
position: toast.POSITION.TOP_RIGHT,
7+
autoClose: 3000,
8+
type: type,
9+
});
10+
};
11+
12+
const handleErrorResponse = (error: any) => {
13+
showNotification("Error Test", "error");
14+
};
15+
const showSuccess = (message: string) => {
16+
showNotification(message, "success");
17+
};
18+
19+
const showError = (message: string) => {
20+
showNotification(message, "error");
21+
};
22+
23+
const showInfo = (message: string) => {
24+
showNotification(message, "info");
25+
};
26+
27+
return {
28+
showSuccess,
29+
showError,
30+
showInfo,
31+
handleErrorResponse,
32+
};
33+
}
34+
35+
export default useNotification;

0 commit comments

Comments
 (0)