website refactor

This commit is contained in:
2026-01-16 01:00:03 +01:00
parent ce7be39155
commit a98e3e3166
286 changed files with 5522 additions and 5261 deletions

View File

@@ -1,14 +1,20 @@
import { useMutation, useQueryClient } from '@tanstack/react-query';
import { useInject } from '@/lib/di/hooks/useInject';
import { LEAGUE_MEMBERSHIP_SERVICE_TOKEN } from '@/lib/di/tokens';
import { ApiError } from '@/lib/api/base/ApiError';
export function useLeagueMembershipMutation() {
const leagueMembershipService = useInject(LEAGUE_MEMBERSHIP_SERVICE_TOKEN);
const queryClient = useQueryClient();
const joinLeagueMutation = useMutation({
mutationFn: ({ leagueId, driverId }: { leagueId: string; driverId: string }) =>
leagueMembershipService.joinLeague(leagueId, driverId),
mutationFn: async ({ leagueId, driverId }: { leagueId: string; driverId: string }) => {
const result = await leagueMembershipService.joinLeague(leagueId, driverId);
if (result.isErr()) {
const error = result.getError();
throw new ApiError(error.message, 'SERVER_ERROR', { timestamp: new Date().toISOString() });
}
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['leagueMemberships'] });
queryClient.invalidateQueries({ queryKey: ['allLeagues'] });
@@ -16,8 +22,13 @@ export function useLeagueMembershipMutation() {
});
const leaveLeagueMutation = useMutation({
mutationFn: ({ leagueId, driverId }: { leagueId: string; driverId: string }) =>
leagueMembershipService.leaveLeague(leagueId, driverId),
mutationFn: async ({ leagueId, driverId }: { leagueId: string; driverId: string }) => {
const result = await leagueMembershipService.leaveLeague(leagueId, driverId);
if (result.isErr()) {
const error = result.getError();
throw new ApiError(error.message, 'SERVER_ERROR', { timestamp: new Date().toISOString() });
}
},
onSuccess: () => {
queryClient.invalidateQueries({ queryKey: ['leagueMemberships'] });
queryClient.invalidateQueries({ queryKey: ['allLeagues'] });
@@ -28,4 +39,4 @@ export function useLeagueMembershipMutation() {
joinLeague: joinLeagueMutation,
leaveLeague: leaveLeagueMutation,
};
}
}