import { previewBracket } from "./server";
import { useServerSuspenseQuery } from "@/lib/tanstack-query/hooks";
import { BracketData } from "./types";

const bracketKeys = {
  preview: (teams: number) => ["bracket", "preview", teams] as const,
};

export const bracketQueries = {
  preview: (teams: number) => ({
    queryKey: bracketKeys.preview(teams),
    queryFn: () => previewBracket({ data: teams }),
  }),
};

export const useBracketPreview = (teams: number) =>
  useServerSuspenseQuery<BracketData>(bracketQueries.preview(teams));
