mirror of
https://github.com/hansjone/netx.git
synced 2026-10-10 11:20:48 +08:00
feat: initialize netx ops tool repository
Set up netx as a standalone git-managed project with isolated Python dependencies, alarm ingestion/query APIs, oclaw bridge integration, and ops-focused UI enhancements including history and raw field access. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
commit
f49c0b5bad
56 changed files with 6974 additions and 0 deletions
20
web/src/hooks/useToast.ts
Normal file
20
web/src/hooks/useToast.ts
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
import { useCallback, useEffect, useState } from "react";
|
||||
|
||||
export type ToastState = { type: "ok" | "error"; text: string } | null;
|
||||
|
||||
export function useToast(autoHideMs = 2600) {
|
||||
const [toast, setToast] = useState<ToastState>(null);
|
||||
|
||||
const showOk = useCallback((text: string) => setToast({ type: "ok", text }), []);
|
||||
const showError = useCallback((text: string) => setToast({ type: "error", text }), []);
|
||||
const clear = useCallback(() => setToast(null), []);
|
||||
|
||||
useEffect(() => {
|
||||
if (!toast) return;
|
||||
const t = setTimeout(() => setToast(null), autoHideMs);
|
||||
return () => clearTimeout(t);
|
||||
}, [toast, autoHideMs]);
|
||||
|
||||
return { toast, showOk, showError, clear };
|
||||
}
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue