tanstack
Some checks failed
Deploy to Test Environment / deploy-to-test (push) Failing after 1m1s

This commit is contained in:
2026-01-10 03:20:40 -08:00
parent 77f9cb6081
commit 2913c7aa09
54 changed files with 1399 additions and 1529 deletions

View File

@@ -0,0 +1,42 @@
// src/hooks/mutations/useGeocodeMutation.ts
import { useMutation } from '@tanstack/react-query';
import { geocodeAddress } from '../../services/apiClient';
interface GeocodeResult {
lat: number;
lng: number;
}
/**
* Mutation hook for geocoding an address string to coordinates.
*
* @returns TanStack Query mutation for geocoding
*
* @example
* ```tsx
* const geocodeMutation = useGeocodeMutation();
*
* const handleGeocode = async () => {
* const result = await geocodeMutation.mutateAsync('123 Main St, City, State');
* if (result) {
* console.log(result.lat, result.lng);
* }
* };
* ```
*/
export const useGeocodeMutation = () => {
return useMutation({
mutationFn: async (address: string): Promise<GeocodeResult> => {
const response = await geocodeAddress(address);
if (!response.ok) {
const error = await response.json().catch(() => ({
message: `Geocoding failed with status ${response.status}`,
}));
throw new Error(error.message || 'Failed to geocode address');
}
return response.json();
},
});
};