2024-02-11 00:00:27 -06:00
|
|
|
import React, { createContext, useContext, useRef } from 'react';
|
|
|
|
import { Toast } from 'primereact/toast';
|
|
|
|
|
|
|
|
const ToastContext = createContext();
|
|
|
|
|
|
|
|
export const useToast = () => useContext(ToastContext);
|
|
|
|
|
|
|
|
export const ToastProvider = ({ children }) => {
|
|
|
|
const toast = useRef(null);
|
|
|
|
|
|
|
|
const showToast = (severity, summary, detail) => {
|
|
|
|
toast.current.show({ severity, summary, detail });
|
|
|
|
};
|
|
|
|
|
|
|
|
return (
|
|
|
|
<ToastContext.Provider value={{ showToast }}>
|
2024-10-05 19:01:07 -05:00
|
|
|
<Toast ref={toast} style={{ zIndex: 50 }} />
|
2024-02-11 00:00:27 -06:00
|
|
|
{children}
|
|
|
|
</ToastContext.Provider>
|
|
|
|
);
|
|
|
|
};
|