23 lines
494 B
JavaScript
23 lines
494 B
JavaScript
import { createContext, useContext } from "react"
|
|
|
|
const alerContextDefaultValue = {
|
|
alert: ()=>{},
|
|
}
|
|
const alertContext = createContext(alerContextDefaultValue)
|
|
|
|
export const AlertType = {
|
|
Success: "Success",
|
|
Error: "Error",
|
|
Info: "Info",
|
|
Warning: "Warning",
|
|
};
|
|
export function useAlert() {
|
|
return useContext(alertContext)
|
|
}
|
|
|
|
export function AlertProvider({ children, setAlert }) {
|
|
|
|
return <alertContext.Provider value={{alert: setAlert}}>{children}</alertContext.Provider>
|
|
}
|
|
|