Fix settings not closing on submit bug

This commit is contained in:
2024-09-27 23:28:19 +02:00
parent cf3ad5f389
commit 122860d230
4 changed files with 27 additions and 9 deletions

View File

@@ -64,10 +64,14 @@ export const saveUserSettings = async (settings) => {
},
body: JSON.stringify(settings),
});
if (!response.ok) {
throw new Error('Failed to save user settings');
const errorData = await response.json().catch(() => null);
throw new Error(errorData?.message || `HTTP error! status: ${response.status}`);
}
return await response.json();
const savedSettings = await response.json();
return savedSettings;
} catch (error) {
console.error('Error saving user settings:', error);
throw error;