- 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.
29 lines
717 B
TypeScript
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
|
|
} |