import { createContext, useContext } from "react";

export type ToastPosition = "top" | "bottom";

export interface ToastContextValue {
  show: (msg: string, position?: ToastPosition) => void;
}

export const ToastContext = createContext<ToastContextValue | null>(null);

export function useToast() {
  const ctx = useContext(ToastContext);
  if (!ctx) throw new Error("useToast must be used within ToastProvider");
  return ctx;
}
