Files
nutriscan/hooks/use-geolocation.ts
T
Evandro Fonseca Junior f98c648311 feat(footer, header, landing): enhance UI components and improve navigation
- Updated Footer component with new links and dynamic year display.
- Refactored Header component to improve mobile navigation and theme toggling.
- Enhanced DonationSection and Features components with improved layout and animations.
- Updated HowItWorks and Impact sections for better user engagement and clarity.
- Improved product page layout and error handling in API interactions.
- General UI refinements across various components for a cohesive user experience.
2026-01-12 19:55:50 -03:00

29 lines
717 B
TypeScript

"use client";
import { useState, useEffect } from "react";
import { detectUserCountry } from "@/lib/geolocation";
export function useGeolocation() {
const [countryCode, setCountryCode] = useState<string | null>(null);
const [isMounted, setIsMounted] = useState(false);
useEffect(() => {
setIsMounted(true);
const detect = async () => {
try {
const country = await detectUserCountry(true);
setScannedCountry(country.code);
} catch {
setCountryCode("br"); // Fallback
}
};
detect();
}, []);
return { countryCode, isMounted };
}
// Helper para evitar erro de nomes
function setScannedCountry(code: string) {
// Lógica interna se necessário
}