k8s redesign complete
This commit is contained in:
@@ -3,6 +3,7 @@
|
||||
*/
|
||||
|
||||
import { useQuery, useMutation, useQueryClient } from '@tanstack/react-query';
|
||||
import { useAuth0 } from '@auth0/auth0-react';
|
||||
import { vehiclesApi } from '../api/vehicles.api';
|
||||
import { CreateVehicleRequest, UpdateVehicleRequest } from '../types/vehicles.types';
|
||||
import toast from 'react-hot-toast';
|
||||
@@ -17,17 +18,20 @@ interface ApiError {
|
||||
}
|
||||
|
||||
export const useVehicles = () => {
|
||||
const { isAuthenticated, isLoading } = useAuth0();
|
||||
return useQuery({
|
||||
queryKey: ['vehicles'],
|
||||
queryFn: vehiclesApi.getAll,
|
||||
enabled: isAuthenticated && !isLoading,
|
||||
});
|
||||
};
|
||||
|
||||
export const useVehicle = (id: string) => {
|
||||
const { isAuthenticated, isLoading } = useAuth0();
|
||||
return useQuery({
|
||||
queryKey: ['vehicles', id],
|
||||
queryFn: () => vehiclesApi.getById(id),
|
||||
enabled: !!id,
|
||||
enabled: !!id && isAuthenticated && !isLoading,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -75,4 +79,4 @@ export const useDeleteVehicle = () => {
|
||||
toast.error(error.response?.data?.error || 'Failed to delete vehicle');
|
||||
},
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user