mirror of
https://git.v0id.ovh/n3wt-innov/n3wt-school.git
synced 2026-01-29 07:53:23 +00:00
feat: Preparation des modèles Settings pour l'enregistrement SMTP [#17]
This commit is contained in:
36
Front-End/src/context/NotificationContext.js
Normal file
36
Front-End/src/context/NotificationContext.js
Normal file
@ -0,0 +1,36 @@
|
||||
import React, { createContext, useState, useContext } from 'react';
|
||||
import FlashNotification from '@/components/FlashNotification';
|
||||
|
||||
const NotificationContext = createContext();
|
||||
|
||||
export const NotificationProvider = ({ children }) => {
|
||||
const [notification, setNotification] = useState({
|
||||
message: '',
|
||||
type: '',
|
||||
title: '',
|
||||
});
|
||||
|
||||
const showNotification = (message, type = 'info', title = '') => {
|
||||
setNotification({ message, type, title });
|
||||
};
|
||||
|
||||
const clearNotification = () => {
|
||||
setNotification({ message: '', type: '', title: '' });
|
||||
};
|
||||
|
||||
return (
|
||||
<NotificationContext.Provider value={{ showNotification }}>
|
||||
{notification.message && (
|
||||
<FlashNotification
|
||||
title={notification.title}
|
||||
message={notification.message}
|
||||
type={notification.type}
|
||||
onClose={clearNotification}
|
||||
/>
|
||||
)}
|
||||
{children}
|
||||
</NotificationContext.Provider>
|
||||
);
|
||||
};
|
||||
|
||||
export const useNotification = () => useContext(NotificationContext);
|
||||
Reference in New Issue
Block a user