/** Toast notifications: the context + `useToast()` hook (kept separate from the
 *  provider component so each module has a single concern / fast-refresh stays happy). */
import { createContext, useContext } from 'react'

export type ToastVariant = 'success' | 'error' | 'info'

export interface ToastApi {
  show: (message: string, variant?: ToastVariant) => void
  success: (message: string) => void
  error: (message: string) => void
}

const NOOP: ToastApi = { show: () => {}, success: () => {}, error: () => {} }

export const ToastContext = createContext<ToastApi>(NOOP)

export function useToast(): ToastApi {
  return useContext(ToastContext)
}
