🚀 feat(_new): new website ui and function

This commit is contained in:
eshanized
2024-12-25 03:38:05 +05:30
parent 3196782ce5
commit 3e920da9fc
89 changed files with 10212 additions and 0 deletions

25
src/hooks/useLocation.ts Normal file
View File

@@ -0,0 +1,25 @@
import { useState, useEffect } from 'react';
import { getUserLocation, type UserLocation } from '@/lib/location';
export function useLocation() {
const [location, setLocation] = useState<UserLocation | null>(null);
const [isLoading, setIsLoading] = useState(true);
const [error, setError] = useState<Error | null>(null);
useEffect(() => {
async function fetchLocation() {
try {
const userLocation = await getUserLocation();
setLocation(userLocation);
} catch (err) {
setError(err instanceof Error ? err : new Error('Failed to get location'));
} finally {
setIsLoading(false);
}
}
fetchLocation();
}, []);
return { location, isLoading, error };
}