mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-08 15:22:39 +02:00
20 lines
515 B
TypeScript
20 lines
515 B
TypeScript
|
|
/**
|
||
|
|
* Shared hook for dispatching HITL decisions.
|
||
|
|
*
|
||
|
|
* All tool-ui components that handle approve/reject/edit should use this
|
||
|
|
* instead of manually constructing `CustomEvent("hitl-decision", ...)`.
|
||
|
|
*/
|
||
|
|
|
||
|
|
import { useCallback } from "react";
|
||
|
|
import type { HitlDecision } from "./types";
|
||
|
|
|
||
|
|
export function useHitlDecision() {
|
||
|
|
const dispatch = useCallback((decisions: HitlDecision[]) => {
|
||
|
|
window.dispatchEvent(
|
||
|
|
new CustomEvent("hitl-decision", { detail: { decisions } }),
|
||
|
|
);
|
||
|
|
}, []);
|
||
|
|
|
||
|
|
return { dispatch };
|
||
|
|
}
|