gpt-engineer-app[bot] commited on
Commit
5326b85
·
1 Parent(s): c0b478a
Files changed (1) hide show
  1. src/routes/dashboard.index.tsx +9 -2
src/routes/dashboard.index.tsx CHANGED
@@ -45,10 +45,17 @@ function IncidentsPage() {
45
 
46
  const selected = incidents.find((i) => i.id === selectedId);
47
 
48
- const rerun = async (id: string) => {
49
  try { await analyze({ data: { incidentId: id } }); toast.success("Analysis updated"); }
50
  catch (e: any) { toast.error(e.message); }
51
- };
 
 
 
 
 
 
 
52
 
53
  const remove = async (id: string) => {
54
  await supabase.from("incidents").delete().eq("id", id);
 
45
 
46
  const selected = incidents.find((i) => i.id === selectedId);
47
 
48
+ const rerun = useCallback(async (id: string) => {
49
  try { await analyze({ data: { incidentId: id } }); toast.success("Analysis updated"); }
50
  catch (e: any) { toast.error(e.message); }
51
+ }, [analyze]);
52
+
53
+ // Auto-trigger analysis when a pending incident is selected
54
+ useEffect(() => {
55
+ if (selected && selected.status === "pending") {
56
+ rerun(selected.id);
57
+ }
58
+ }, [selected?.id, selected?.status, rerun]);
59
 
60
  const remove = async (id: string) => {
61
  await supabase.from("incidents").delete().eq("id", id);