diff --git a/frontend/src/app/dashboard/page.tsx b/frontend/src/app/dashboard/page.tsx index 9a07a84..177dd66 100644 --- a/frontend/src/app/dashboard/page.tsx +++ b/frontend/src/app/dashboard/page.tsx @@ -111,11 +111,12 @@ export default function DashboardPage() { } }, [isLoading, isAuthenticated, router]) + // Load portfolio data on mount (so we can show count in tab) useEffect(() => { - if (isAuthenticated && activeTab === 'portfolio') { + if (isAuthenticated) { loadPortfolio() } - }, [isAuthenticated, activeTab]) + }, [isAuthenticated]) const handleOpenBillingPortal = async () => { try { diff --git a/frontend/src/app/settings/page.tsx b/frontend/src/app/settings/page.tsx index ac28b97..115fac8 100644 --- a/frontend/src/app/settings/page.tsx +++ b/frontend/src/app/settings/page.tsx @@ -43,6 +43,14 @@ export default function SettingsPage() { email: '', }) + // Notification preferences (local state - would be persisted via API in production) + const [notificationPrefs, setNotificationPrefs] = useState({ + domain_availability: true, + price_alerts: true, + weekly_digest: false, + }) + const [savingNotifications, setSavingNotifications] = useState(false) + // Price alerts const [priceAlerts, setPriceAlerts] = useState([]) const [loadingAlerts, setLoadingAlerts] = useState(false) @@ -92,9 +100,10 @@ export default function SettingsPage() { setSuccess(null) try { - // In a real app, this would call an API to update the user - // For now, we'll just show success - await new Promise(resolve => setTimeout(resolve, 500)) + await api.updateMe({ name: profileForm.name || undefined }) + // Update store with new user info + const { checkAuth } = useStore.getState() + await checkAuth() setSuccess('Profile updated successfully') } catch (err) { setError(err instanceof Error ? err.message : 'Failed to update profile') @@ -103,6 +112,32 @@ export default function SettingsPage() { } } + const handleSaveNotifications = async () => { + setSavingNotifications(true) + setError(null) + setSuccess(null) + + try { + // Store in localStorage for now (would be API in production) + localStorage.setItem('notification_prefs', JSON.stringify(notificationPrefs)) + setSuccess('Notification preferences saved') + } catch (err) { + setError(err instanceof Error ? err.message : 'Failed to save preferences') + } finally { + setSavingNotifications(false) + } + } + + // Load notification preferences from localStorage + useEffect(() => { + const saved = localStorage.getItem('notification_prefs') + if (saved) { + try { + setNotificationPrefs(JSON.parse(saved)) + } catch {} + } + }, []) + const handleDeletePriceAlert = async (tld: string, alertId: number) => { setDeletingAlertId(alertId) try { @@ -301,7 +336,12 @@ export default function SettingsPage() {

Domain Availability

Get notified when watched domains become available

- + setNotificationPrefs({ ...notificationPrefs, domain_availability: e.target.checked })} + className="w-5 h-5 accent-accent cursor-pointer" + /> + + {/* Active Price Alerts */} diff --git a/frontend/src/lib/api.ts b/frontend/src/lib/api.ts index b4a071f..a955383 100644 --- a/frontend/src/lib/api.ts +++ b/frontend/src/lib/api.ts @@ -130,6 +130,19 @@ class ApiClient { }>('/auth/me') } + async updateMe(data: { name?: string }) { + return this.request<{ + id: number + email: string + name: string | null + is_active: boolean + created_at: string + }>('/auth/me', { + method: 'PUT', + body: JSON.stringify(data), + }) + } + // Password Reset async forgotPassword(email: string) { return this.request<{ message: string; success: boolean }>('/auth/forgot-password', {