mirror of
https://github.com/pacnpal/thrilltrack-explorer.git
synced 2025-12-20 13:51:13 -05:00
Fix: Imperial units not displaying
This commit is contained in:
@@ -57,10 +57,13 @@ export function useUnitPreferences() {
|
||||
};
|
||||
|
||||
const autoDetectPreferences = async () => {
|
||||
console.log('🌐 Calling edge function for location detection...');
|
||||
try {
|
||||
const response = await supabase.functions.invoke('detect-location');
|
||||
console.log('📡 Edge function response:', response);
|
||||
|
||||
if (response.data && response.data.measurementSystem) {
|
||||
console.log('🎯 Detected measurement system:', response.data.measurementSystem);
|
||||
const newPreferences: UnitPreferences = {
|
||||
...DEFAULT_PREFERENCES,
|
||||
measurement_system: response.data.measurementSystem,
|
||||
@@ -71,15 +74,19 @@ export function useUnitPreferences() {
|
||||
// Save to localStorage for anonymous users
|
||||
if (!user) {
|
||||
localStorage.setItem('unit_preferences', JSON.stringify(newPreferences));
|
||||
console.log('💾 Saved preferences to localStorage:', newPreferences);
|
||||
}
|
||||
|
||||
return newPreferences;
|
||||
} else {
|
||||
console.log('⚠️ No measurement system in response');
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Error auto-detecting location:', error);
|
||||
console.error('❌ Error auto-detecting location:', error);
|
||||
}
|
||||
|
||||
// Fallback to default
|
||||
console.log('🔄 Falling back to default preferences');
|
||||
setPreferences(DEFAULT_PREFERENCES);
|
||||
return DEFAULT_PREFERENCES;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user