snp-global/frontend/src/contexts/ToastContext.tsx
HYOJIN b2b268f1e5 chore: 프로젝트 초기 설정 및 팀 워크플로우 구성
- Spring Boot 3.2.1 + React 19 프로젝트 구조
- S&P Global Maritime API Bypass 및 Risk & Compliance Screening 기능
- 팀 워크플로우 v1.6.1 적용 (settings.json, hooks, workflow-version)
- 프론트엔드 빌드 (Vite + TypeScript + Tailwind CSS)
- 메인 카드 레이아웃 CSS Grid 전환

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-07 15:42:23 +09:00

30 lines
881 B
TypeScript

import { createContext, useContext, type ReactNode } from 'react';
import { useToast, type Toast } from '../hooks/useToast';
interface ToastContextValue {
toasts: Toast[];
showToast: (message: string, type?: Toast['type']) => void;
removeToast: (id: number) => void;
}
const ToastContext = createContext<ToastContextValue | null>(null);
export function ToastProvider({ children }: { children: ReactNode }) {
const { toasts, showToast, removeToast } = useToast();
return (
<ToastContext.Provider value={{ toasts, showToast, removeToast }}>
{children}
</ToastContext.Provider>
);
}
// eslint-disable-next-line react-refresh/only-export-components
export function useToastContext(): ToastContextValue {
const ctx = useContext(ToastContext);
if (!ctx) {
throw new Error('useToastContext must be used within a ToastProvider');
}
return ctx;
}