import { useInject } from '@/lib/di/hooks/useInject'; import { TEAM_SERVICE_TOKEN } from '@/lib/di/tokens'; import { ApiError } from '@/lib/gateways/api/base/ApiError'; import type { CreateTeamInputDTO } from '@/lib/types/generated/CreateTeamInputDTO'; import type { CreateTeamOutputDTO } from '@/lib/types/generated/CreateTeamOutputDTO'; import { useMutation, UseMutationOptions } from '@tanstack/react-query'; export function useCreateTeam(options?: UseMutationOptions) { const teamService = useInject(TEAM_SERVICE_TOKEN); return useMutation({ mutationFn: async (input) => { const result = await teamService.createTeam(input); if (result.isErr()) { throw result.getError(); } return result.unwrap(); }, ...options, }); }