Files
pulse/components/settings/ProfileSettings.tsx
Usman Baig acede8ca54 feat: rename section to Account, move Danger Zone to own sidebar item
- Rename "Pulse Settings" to "Account"
- Add hideDangerZone prop to hide it from Profile tab
- Add standalone "Danger Zone" item under Account section
- Bump @ciphera-net/ui to ^0.0.92
2026-03-06 12:23:00 +01:00

71 lines
2.3 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' | 'danger-zone'
borderless?: boolean
hideDangerZone?: boolean
}
export default function ProfileSettings({ activeTab, borderless, hideDangerZone }: 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}
hideDangerZone={hideDangerZone}
/>
)
}