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.
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
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) })),
|
||||
}))
|
||||
Reference in New Issue
Block a user