Files
Ping/frontend/src/store/toastStore.ts
T
Admin 95a2d46408 Add Ping frontend
React 19 + TypeScript client built with Vite. Zustand for local state,
react-oidc-context for the login flow, a SignalR connection for chat and
presence events, and LiveKit's React components for voice/video calls.
2026-09-21 19:33:02 +02:00

28 lines
681 B
TypeScript

import { create } from 'zustand'
export type ToastTone = 'error' | 'info'
export interface Toast {
id: number
message: string
tone: ToastTone
}
let nextId = 1
interface ToastState {
toasts: Toast[]
push: (message: string, tone?: ToastTone) => void
dismiss: (id: number) => void
}
export const useToastStore = create<ToastState>((set) => ({
toasts: [],
push: (message, tone = 'info') => {
const id = nextId++
set((s) => ({ toasts: [...s.toasts, { id, message, tone }] }))
setTimeout(() => set((s) => ({ toasts: s.toasts.filter((t) => t.id !== id) })), 5000)
},
dismiss: (id) => set((s) => ({ toasts: s.toasts.filter((t) => t.id !== id) })),
}))