oktopus/frontend/src/contexts/error-context.js
2024-10-30 08:44:54 -03:00

32 lines
725 B
JavaScript

import { createContext, useContext, useState } from 'react';
export const AlertContext = createContext({ undefined });
export const AlertProvider = (props) => {
const { children } = props;
/*
{
severity: '', // options => error, warning, info, success
message: '',
title: '',
}
*/
// const [alert, setAlert] = useState(null);
const [alert, setAlert] = useState();
return (
<AlertContext.Provider
value={{
alert,
setAlert,
}}
>
{children}
</AlertContext.Provider>
);
};
export const AlertConsumer = AlertContext.Consumer;
export const useAlertContext = () => useContext(AlertContext);