"use client"; import { useQuery } from "@tanstack/react-query"; import { apiFetch } from "@/lib/api-client"; import { useUndoMutation } from "@/hooks/useUndoMutation"; export function ActionHistoryPanel() { const { data, isLoading } = useQuery({ queryKey: ["action-history"], queryFn: () => apiFetch<{ actions: { id: string; summary: string; actionType: string; createdAt: string; undoable: boolean; }[]; }>("/api/actions/recent"), }); const undo = useUndoMutation({ onSuccess: () => { /* query invalidation handled in hook */ }, }); const actions = data?.actions ?? []; return (
Recent actions you can undo. Actions older than 90 days are automatically pruned.
{isLoading ? (Loading...
) : actions.length === 0 ? (No recent actions.
) : ({a.summary}
{new Date(a.createdAt).toLocaleString()} ยท {a.actionType}