Skip to content

Enhanced ChatGPT Clone: Features Agents, MCP, Skills, DeepSeek, Anthropic, AWS, OpenAI, Responses API, Azure, Groq, o1, GPT-5, Mistral, OpenRouter, Vertex AI, Gemini, Artifacts, AI model switching, message search, Code Interpreter, langchain, DALL-E-3, OpenAPI Actions, Functions, Secure Multi-User Auth, Presets, open-source for self-hosting. Active

738 B
Raw Blame
import { createContext, useContext, ReactNode, Context } from 'react';
import { JSX } from 'react/jsx-runtime';
import type { TShowToast } from '~/common';
import useToast from '~/hooks/useToast';

type ToastContextType = {
  showToast: ({ message, severity, showIcon, duration }: TShowToast) => void;
};

export const ToastContext: Context<ToastContextType> = createContext<ToastContextType>({
  showToast: () => ({}),
});

export function useToastContext(): ToastContextType {
  return useContext(ToastContext);
}

export default function ToastProvider({ children }: { children: ReactNode }): JSX.Element {
  const { showToast } = useToast();

  return <ToastContext.Provider value={{ showToast }}>{children}</ToastContext.Provider>;
}