From 6d0fdec4df10f7fdcab6872eda9c7141d48fcb88 Mon Sep 17 00:00:00 2001 From: Diego-C-05 Date: Tue, 5 May 2026 11:00:31 +0200 Subject: [PATCH] feat: aggiunta salvataggio impostazioni profilo dinamico user name e email --- frontend-BriefAI/src/pages/SettingsPage.tsx | 17 +++++++++++++++-- frontend-BriefAI/src/services/apiService.ts | 13 ++++++++++++- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/frontend-BriefAI/src/pages/SettingsPage.tsx b/frontend-BriefAI/src/pages/SettingsPage.tsx index acf8e49..e437cbc 100644 --- a/frontend-BriefAI/src/pages/SettingsPage.tsx +++ b/frontend-BriefAI/src/pages/SettingsPage.tsx @@ -15,6 +15,11 @@ type SettingsSnapshot = { subscriptionState: SubscriptionState } +type ProfileIdentity = { + username: string + email: string +} + const STORAGE_KEY = 'briefai-settings' const ONBOARDING_KEY = 'briefai-onboarding' const DEFAULT_MACRO_TOPICS = ['Scienza & Ricerca'] @@ -62,6 +67,10 @@ function persistSettings(snapshot: SettingsSnapshot) { // Pagina Impostazioni: gestisce preferenze feed e account con una struttura a tab. function SettingsPage() { const [activeTab, setActiveTab] = useState('interests') + const [profileIdentity, setProfileIdentity] = useState({ + username: '', + email: '', + }) const [selectedMacroTopics, setSelectedMacroTopics] = useState(() => readInitialSettings().selectedMacroTopics, ) @@ -75,6 +84,10 @@ function SettingsPage() { fetchProfile() .then((res) => { if (res && res.profile) { + setProfileIdentity({ + username: res.profile.username || '', + email: res.profile.email || '', + }) setSelectedMacroTopics(res.profile.macroTopics || []) setKeywords(res.profile.keywords || []) } @@ -182,8 +195,8 @@ function SettingsPage() { ) : ( fetch(`${BASE}${path}`, { ...options, @@ -29,7 +40,7 @@ export const fetchOverview = () => // GET /api/profile export const fetchProfile = () => - authFetch('/api/profile').then((r) => r.json()) + authFetch('/api/profile').then((r) => r.json() as Promise) // PUT /api/profile export const updateProfile = async (data: {