website refactor
This commit is contained in:
@@ -8,7 +8,13 @@ export function useAllTeams() {
|
||||
|
||||
const queryResult = useQuery({
|
||||
queryKey: ['allTeams'],
|
||||
queryFn: () => teamService.getAllTeams(),
|
||||
queryFn: async () => {
|
||||
const result = await teamService.getAllTeams();
|
||||
if (result.isErr()) {
|
||||
throw result.getError();
|
||||
}
|
||||
return result.unwrap();
|
||||
},
|
||||
});
|
||||
|
||||
return enhanceQueryResult(queryResult);
|
||||
|
||||
@@ -9,7 +9,13 @@ export function useCreateTeam(options?: UseMutationOptions<CreateTeamOutputDTO,
|
||||
const teamService = useInject(TEAM_SERVICE_TOKEN);
|
||||
|
||||
return useMutation<CreateTeamOutputDTO, ApiError, CreateTeamInputDTO>({
|
||||
mutationFn: (input) => teamService.createTeam(input),
|
||||
mutationFn: async (input) => {
|
||||
const result = await teamService.createTeam(input);
|
||||
if (result.isErr()) {
|
||||
throw result.getError();
|
||||
}
|
||||
return result.unwrap();
|
||||
},
|
||||
...options,
|
||||
});
|
||||
}
|
||||
@@ -8,7 +8,13 @@ export function useTeamDetails(teamId: string, currentUserId: string) {
|
||||
|
||||
const queryResult = useQuery({
|
||||
queryKey: ['teamDetails', teamId, currentUserId],
|
||||
queryFn: () => teamService.getTeamDetails(teamId, currentUserId),
|
||||
queryFn: async () => {
|
||||
const result = await teamService.getTeamDetails(teamId, currentUserId);
|
||||
if (result.isErr()) {
|
||||
throw result.getError();
|
||||
}
|
||||
return result.unwrap();
|
||||
},
|
||||
enabled: !!teamId && !!currentUserId,
|
||||
});
|
||||
|
||||
|
||||
@@ -8,7 +8,13 @@ export function useTeamMembers(teamId: string, currentUserId: string, teamOwnerI
|
||||
|
||||
const queryResult = useQuery({
|
||||
queryKey: ['teamMembers', teamId, currentUserId, teamOwnerId],
|
||||
queryFn: () => teamService.getTeamMembers(teamId, currentUserId, teamOwnerId),
|
||||
queryFn: async () => {
|
||||
const result = await teamService.getTeamMembers(teamId, currentUserId, teamOwnerId);
|
||||
if (result.isErr()) {
|
||||
throw result.getError();
|
||||
}
|
||||
return result.unwrap();
|
||||
},
|
||||
enabled: !!teamId && !!currentUserId && !!teamOwnerId,
|
||||
});
|
||||
|
||||
|
||||
@@ -9,7 +9,13 @@ export function useTeamMembership(teamId: string, driverId: string) {
|
||||
|
||||
const queryResult = useQuery({
|
||||
queryKey: ['teamMembership', teamId, driverId],
|
||||
queryFn: () => teamService.getMembership(teamId, driverId),
|
||||
queryFn: async () => {
|
||||
const result = await teamService.getMembership(teamId, driverId);
|
||||
if (result.isErr()) {
|
||||
throw result.getError();
|
||||
}
|
||||
return result.unwrap();
|
||||
},
|
||||
enabled: !!teamId && !!driverId,
|
||||
});
|
||||
|
||||
|
||||
@@ -9,7 +9,13 @@ export function useUpdateTeam(options?: UseMutationOptions<UpdateTeamOutputDTO,
|
||||
const teamService = useInject(TEAM_SERVICE_TOKEN);
|
||||
|
||||
return useMutation<UpdateTeamOutputDTO, ApiError, { teamId: string; input: UpdateTeamInputDTO }>({
|
||||
mutationFn: ({ teamId, input }) => teamService.updateTeam(teamId, input),
|
||||
mutationFn: async ({ teamId, input }) => {
|
||||
const result = await teamService.updateTeam(teamId, input);
|
||||
if (result.isErr()) {
|
||||
throw result.getError();
|
||||
}
|
||||
return result.unwrap();
|
||||
},
|
||||
...options,
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user