'use client' import { useStyles, cx } from '../../contexts/StylesContext' import { ProfileSection } from './ProfileSection' import { EmailsSection } from './EmailsSection' import { PasswordSection } from './PasswordSection' import { PasskeysSection } from './PasskeysSection' import { ConnectionsSection } from './ConnectionsSection' import { MFASection } from './MFASection' import { SessionsSection } from './SessionsSection' import { Button } from './SettingsComponents' type SettingsSectionType = 'profile' | 'emails' | 'password' | 'passkeys' | 'connections' | 'mfa' | 'sessions' interface AuthSettingsProps { /** Title shown at the top of the settings page */ title?: string /** Called when user clicks sign out */ onSignOut?: () => void /** Which sections to show. Defaults to all. */ sections?: SettingsSectionType[] /** URL to redirect back to after OAuth connect (for connections section) */ oauthRedirectUrl?: string } const DEFAULT_SECTIONS: SettingsSectionType[] = ['profile', 'emails', 'password', 'passkeys', 'connections', 'mfa', 'sessions'] /** * AuthSettings renders a complete account settings page. * * It includes sections for: * - Profile (display user info) * - Email addresses (manage, verify, set primary) * - Password change * - Passkeys (add/remove passwordless login) * - Connected accounts (OAuth providers) * - Two-factor authentication (TOTP, recovery codes) * - Active sessions (view/end sessions) * * @example * ```tsx * router.push('/logout')} * sections={['profile', 'password', 'mfa']} // Only show these sections * /> * ``` */ export function AuthSettings({ title = 'Account Settings', onSignOut, sections = DEFAULT_SECTIONS, oauthRedirectUrl, }: AuthSettingsProps) { const styles = useStyles() const sectionSet = new Set(sections) return (

{title}

{sectionSet.has('profile') && } {sectionSet.has('emails') && } {sectionSet.has('password') && } {sectionSet.has('passkeys') && } {sectionSet.has('connections') && } {sectionSet.has('mfa') && } {sectionSet.has('sessions') && } {/* Sign Out */} {onSignOut && (
)}
) }