import { useNavigate } from "@tanstack/react-router";
import { useLingui } from "@lingui/react/macro";
import { createTeam } from "@/features/teams/server";
import { TeamInput } from "@/features/teams/types";
import { logger } from "@/lib/logger";
import { useServerMutation } from "@/lib/tanstack-query/hooks";

const useCreateTeam = () => {
  const navigate = useNavigate();
  const { t } = useLingui();

  return useServerMutation({
    mutationFn: (data: TeamInput) => createTeam({ data }),
    onMutate: (data) => {
      logger.info('Creating team', data);
    },
    successMessage: t`Team created successfully!`,
  });
};

export default useCreateTeam;
