import { useQuery } from "@tanstack/react-query";

import { api } from "../../api";

export function useCatalog(token: string) {
  const sources = useQuery({ queryKey: ["catalog", "activity-sources"], queryFn: () => api.activitySources(token) });
  const exercises = { ...sources, data: sources.data?.filter((source) => source.kind === "exercise") };
  const machines = { ...sources, data: sources.data?.filter((source) => source.kind === "machine") };
  return { sources, exercises, machines, equipment: machines };
}
