import React, { useState } from 'react'; import { gatewayHealth } from '../../services/apiClient'; import { GATEWAY_URL } from '../../auth/authConfig'; const tabs = [ { id: 'general', label: 'General' }, { id: 'connection', label: 'Connection' }, { id: 'notifications', label: 'Notifications' }, { id: 'security', label: 'Security' }, ]; export default function Settings({ sessionUser, sessionToken, onSignOut }) { const [activeTab, setActiveTab] = useState('general'); const [tenantId, setTenantId] = useState(localStorage.getItem('adplatform_tenantId') || ''); const [healthResult, setHealthResult] = useState(null); const [testing, setTesting] = useState(false); const saveTenantId = () => { if (tenantId.trim()) { localStorage.setItem('adplatform_tenantId', tenantId.trim()); } else { localStorage.removeItem('adplatform_tenantId'); } }; const testConnection = async () => { setTesting(true); setHealthResult(null); const result = await gatewayHealth(); setHealthResult(result); setTesting(false); }; return (

Settings

{activeTab === 'general' && ( <>

Profile

Display Name
{sessionUser?.name || 'Not set'}
Email
{sessionUser?.email || 'Not set'}
Role
{sessionUser?.role || 'User'}

Tenant Configuration

setTenantId(e.target.value)} placeholder="e.g. 123-456-7890" />
This ID is sent as X-Tenant-Id header with API requests.
)} {activeTab === 'connection' && ( <>

Gateway Connection

Gateway URL
{GATEWAY_URL}
Connection Test
Verify the gateway is reachable and responding.
{healthResult && (
{healthResult.ok ? '✓ Gateway is healthy and responding.' : `✗ Connection failed: ${healthResult.error}`}
)}

Session Information

Session Token {sessionToken ? sessionToken.substring(0, 32) + '…' : 'None'}
User ID {sessionUser?.userId || '—'}
Client ID {sessionUser?.clientId || '—'}
Session ID {sessionUser?.sessionId || '—'}
)} {activeTab === 'notifications' && (

Notification Preferences

Campaign Alerts
Receive alerts when campaigns need attention.
Coming soon
Budget Warnings
Get notified when budgets are nearly exhausted.
Coming soon
Weekly Summary
Receive a weekly performance summary email.
Coming soon
)} {activeTab === 'security' && ( <>

Authentication

Sign Out
End your current session and return to the login page.
)}
); }