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

import { consignmentsService } from "../services/consignments.service";

export const useConsignments = () =>
  useQuery({
    queryKey: ["consignments"],
    queryFn: consignmentsService.list,
  });

export const useConsignment = (id: string) =>
  useQuery({
    queryKey: ["consignments", id],
    queryFn: () => consignmentsService.get(id),
    enabled: Boolean(id),
  });
