From 23172444a0d18eab7339b3d356febf6f2d027f67 Mon Sep 17 00:00:00 2001
From: "gpt-engineer-app[bot]"
<159125892+gpt-engineer-app[bot]@users.noreply.github.com>
Date: Sun, 28 Sep 2025 20:23:59 +0000
Subject: [PATCH] Refactor: Consolidate save buttons
---
src/components/settings/LocationTab.tsx | 159 +++++++++++-------------
1 file changed, 70 insertions(+), 89 deletions(-)
diff --git a/src/components/settings/LocationTab.tsx b/src/components/settings/LocationTab.tsx
index f1819402..09ab6ced 100644
--- a/src/components/settings/LocationTab.tsx
+++ b/src/components/settings/LocationTab.tsx
@@ -88,52 +88,39 @@ export function LocationTab() {
if (!user) return;
setLoading(true);
try {
- const {
- error
- } = await supabase.from('profiles').update({
+ // Save profile information
+ const { error: profileError } = await supabase.from('profiles').update({
preferred_pronouns: data.preferred_pronouns || null,
timezone: data.timezone,
preferred_language: data.preferred_language,
location_id: data.location_id || null,
updated_at: new Date().toISOString()
}).eq('user_id', user.id);
- if (error) throw error;
- await refreshProfile();
- toast({
- title: 'Information updated',
- description: 'Your location and personal information has been successfully updated.'
- });
- } catch (error: any) {
- toast({
- title: 'Error',
- description: error.message || 'Failed to update information',
- variant: 'destructive'
- });
- } finally {
- setLoading(false);
- }
- };
- const saveAccessibilityPreferences = async () => {
- if (!user) return;
- try {
- const {
- error
- } = await supabase.from('user_preferences').upsert([{
+
+ if (profileError) throw profileError;
+
+ // Save accessibility preferences
+ const { error: accessibilityError } = await supabase.from('user_preferences').upsert([{
user_id: user.id,
accessibility_options: accessibility as any,
updated_at: new Date().toISOString()
}]);
- if (error) throw error;
+
+ if (accessibilityError) throw accessibilityError;
+
+ await refreshProfile();
toast({
- title: 'Accessibility preferences saved',
- description: 'Your accessibility settings have been updated.'
+ title: 'Settings saved',
+ description: 'Your location, personal information, and accessibility settings have been updated.'
});
} catch (error: any) {
toast({
title: 'Error',
- description: error.message || 'Failed to save accessibility preferences',
+ description: error.message || 'Failed to save settings',
variant: 'destructive'
});
+ } finally {
+ setLoading(false);
}
};
const updateAccessibility = (key: keyof AccessibilityOptions, value: any) => {
@@ -227,70 +214,64 @@ export function LocationTab() {
+
+ Increase contrast for better visibility +
++ Minimize animations and transitions +
+- Increase contrast for better visibility -
-- Minimize animations and transitions -
-