You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
685 B
26 lines
685 B
'use client'
|
|
|
|
import { createContext, useContext, useState } from 'react';
|
|
|
|
const NotificationContext = createContext();
|
|
|
|
export const NotificationProvider = ({ children }) => {
|
|
const [notification, setNotification] = useState(null);
|
|
|
|
const showNotification = (message, type = 'info') => {
|
|
setNotification({ message, type });
|
|
};
|
|
|
|
const clearNotification = () => {
|
|
setNotification(null);
|
|
};
|
|
|
|
return (
|
|
<NotificationContext.Provider value={{ notification, showNotification, clearNotification }}>
|
|
{children}
|
|
</NotificationContext.Provider>
|
|
);
|
|
};
|
|
|
|
export const useNotification = () => useContext(NotificationContext);
|