Skip to content

@pgege/kaboo-react


Function: useTurnFeedback()

useTurnFeedback(groups, onFeedback): TurnFeedbackState

Defined in: src/feedback/useTurnFeedback.ts:98

Headless feedback state for one turn: resolves the turn's correlation ids from its activity groups and tracks the submitted score. Pure mechanism — the host supplies the storage via onFeedback, and can build any UI on top (or use the bundled TurnFeedback buttons).

Parameters

groups

GroupEntry[]

onFeedback

FeedbackHandler

Returns

TurnFeedbackState

Example

import { useTurnFeedback, type GroupEntry } from "@pgege/kaboo-react";

function Score({ groups }: { groups: GroupEntry[] }) {
  const { submit, submitted } = useTurnFeedback(groups, (p) =>
    fetch("/api/feedback", { method: "POST", body: JSON.stringify(p) }),
  );
  return submitted != null ? <span>thanks!</span> : (
    <button onClick={() => submit(1)}>Helpful</button>
  );
}