| 'use client'; | |
| import { createContext, useContext } from "react"; | |
| import { toast } from "react-toastify"; | |
| const ToastContext = createContext(); | |
| export function ToastProvider({ children }) { | |
| return ( | |
| <ToastContext.Provider value={toast}> | |
| {children} | |
| </ToastContext.Provider> | |
| ); | |
| } | |
| export function useToast() { | |
| const context = useContext(ToastContext); | |
| if (!context) { | |
| throw new Error("useToast must be used within a ToastProvider"); | |
| } | |
| return context; | |
| } | |