Files
pulse/components/settings/ProfileSettings.tsx
Usman Baig 6d360cf1ac feat: settings modal improvements — borderless profile, remove descriptions, bump ui to 0.0.91
- Add borderless prop passthrough to ProfileSettings
- Remove section descriptions from SettingsModalWrapper sidebar
- Bump @ciphera-net/ui to ^0.0.91
2026-03-06 11:44:30 +01:00

69 lines
2.2 KiB
TypeScript

'use client'
import { useAuth } from '@/lib/auth/context'
import { ProfileSettings as SharedProfileSettings } from '@ciphera-net/ui'
import api from '@/lib/api/client'
import { deriveAuthKey } from '@/lib/crypto/password'
import { deleteAccount, getUserSessions, revokeSession, updateUserPreferences, updateDisplayName } from '@/lib/api/user'
import { setup2FA, verify2FA, disable2FA, regenerateRecoveryCodes } from '@/lib/api/2fa'
import { registerPasskey, listPasskeys, deletePasskey } from '@/lib/api/webauthn'
interface Props {
activeTab?: 'profile' | 'security' | 'preferences'
borderless?: boolean
}
export default function ProfileSettings({ activeTab, borderless }: Props = {}) {
const { user, refresh, logout } = useAuth()
if (!user) return null
const handleUpdateProfile = async (email: string, currentPasswordDerived: string, newDerivedKey: string) => {
await api('/auth/user/email', {
method: 'PUT',
body: JSON.stringify({
email: email,
current_password: currentPasswordDerived,
new_derived_key: newDerivedKey
})
})
}
const handleUpdatePassword = async (currentPasswordDerived: string, newDerivedKey: string) => {
await api('/auth/user/password', {
method: 'PUT',
body: JSON.stringify({
current_password: currentPasswordDerived,
new_password: newDerivedKey
})
})
}
return (
<SharedProfileSettings
user={user}
onUpdateProfile={handleUpdateProfile}
onUpdateDisplayName={updateDisplayName}
onUpdatePassword={handleUpdatePassword}
onDeleteAccount={deleteAccount}
onSetup2FA={setup2FA}
onVerify2FA={verify2FA}
onDisable2FA={disable2FA}
onRegenerateRecoveryCodes={regenerateRecoveryCodes}
onGetSessions={getUserSessions}
onRevokeSession={revokeSession}
onRegisterPasskey={registerPasskey}
onListPasskeys={listPasskeys}
onDeletePasskey={deletePasskey}
onUpdatePreferences={updateUserPreferences}
deriveAuthKey={deriveAuthKey}
refreshUser={refresh}
logout={logout}
activeTab={activeTab}
hideNav={activeTab !== undefined}
hideNotifications
borderless={borderless}
/>
)
}