feat(complex-selection): enhance auto-selection logic and error handling for complex selection

This commit is contained in:
Jose Selesan
2026-06-04 14:06:23 -03:00
parent 228004a7e0
commit e441f15ee4
2 changed files with 13 additions and 4 deletions

View File

@@ -1,7 +1,7 @@
import { Button } from '@/components/ui/button';
import { apiClient } from '@/lib/api-client';
import type { ComplexWithRole } from '@repo/api-contract';
import { useMutation, useQuery } from '@tanstack/react-query';
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query';
import { useNavigate } from '@tanstack/react-router';
import { Building2, Loader2 } from 'lucide-react';
@@ -13,12 +13,15 @@ export function SelectComplexPage() {
queryFn: () => apiClient.complexes.listMine(),
});
const queryClient = useQueryClient();
const selectMutation = useMutation({
mutationFn: async (complexId: string) => {
const response = await apiClient.complexes.select({ complexId });
return response;
},
onSuccess: () => {
onSuccess: (data) => {
queryClient.setQueryData(['current-complex'], data);
navigate({ to: '/' });
},
});