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 { UpdateTeamInputDTO } from '@/lib/types/generated/UpdateTeamInputDTO'; import type { UpdateTeamOutputDTO } from '@/lib/types/generated/UpdateTeamOutputDTO'; import { useMutation, UseMutationOptions } from '@tanstack/react-query'; export function useUpdateTeam(options?: UseMutationOptions) { const teamService = useInject(TEAM_SERVICE_TOKEN); return useMutation({ mutationFn: async ({ teamId, input }) => { const result = await teamService.updateTeam(teamId, input); if (result.isErr()) { throw result.getError(); } return result.unwrap(); }, ...options, }); }