2023-02-22 18:21:00 +01:00
|
|
|
import React, { useState, FC, ReactElement } from 'react';
|
2021-02-04 08:24:12 +01:00
|
|
|
|
|
|
|
export const AlertMessageContext = React.createContext({
|
2021-02-04 17:04:00 +01:00
|
|
|
message: null,
|
2023-05-21 06:15:25 +02:00
|
|
|
setMessage: (_text?: string) => null,
|
2021-02-04 08:24:12 +01:00
|
|
|
});
|
|
|
|
|
2023-02-22 18:21:00 +01:00
|
|
|
export type AlertMessageProviderProps = {
|
|
|
|
children: ReactElement;
|
|
|
|
};
|
|
|
|
|
|
|
|
const AlertMessageProvider: FC<AlertMessageProviderProps> = ({ children }) => {
|
2021-02-04 17:04:00 +01:00
|
|
|
const [message, setMessage] = useState('');
|
|
|
|
|
|
|
|
const providerValue = {
|
|
|
|
message,
|
|
|
|
setMessage,
|
|
|
|
};
|
|
|
|
return (
|
|
|
|
<AlertMessageContext.Provider value={providerValue}>{children}</AlertMessageContext.Provider>
|
|
|
|
);
|
|
|
|
};
|
2021-02-04 08:24:12 +01:00
|
|
|
|
2021-02-04 17:04:00 +01:00
|
|
|
export default AlertMessageProvider;
|