import { useState } from 'react'; import { errorMessage } from '../../api/client'; import { Alert, Badge, Button, Card, FormField, Input, Spinner, useToast, } from '@cameleer/design-system'; import { useTenantSettings, useResetServerAdminPassword, useTenantAuthSettings, useUpdateTenantAuthSettings, } from '../../api/tenant-hooks'; import { MfaSection } from '../../components/account/MfaSection'; import { PasskeySection } from '../../components/account/PasskeySection'; import { useScopes } from '../../auth/useScopes'; import styles from '../../styles/platform.module.css'; function statusColor(status: string): 'success' | 'error' | 'warning' | 'auto' { switch (status?.toUpperCase()) { case 'ACTIVE': return 'success'; case 'SUSPENDED': return 'warning'; case 'PROVISIONING': return 'auto'; case 'ERROR': return 'error'; default: return 'auto'; } } function AuthPolicySection() { const scopes = useScopes(); const { toast } = useToast(); const { data: authSettings } = useTenantAuthSettings(); const updateAuth = useUpdateTenantAuthSettings(); if (!scopes.has('tenant:manage') || !authSettings) return null; async function handleMfaModeChange(mode: string) { try { await updateAuth.mutateAsync({ mfaMode: mode }); toast({ title: `MFA mode set to ${mode}`, variant: 'success' }); } catch (err) { toast({ title: 'Failed to update', description: errorMessage(err), variant: 'error' }); } } async function handlePasskeyToggle() { if (!authSettings) return; try { await updateAuth.mutateAsync({ passkeyEnabled: !authSettings.passkeyEnabled }); toast({ title: authSettings.passkeyEnabled ? 'Passkeys disabled' : 'Passkeys enabled', variant: 'success' }); } catch (err) { toast({ title: 'Failed to update', description: errorMessage(err), variant: 'error' }); } } async function handlePasskeyModeChange(mode: string) { try { await updateAuth.mutateAsync({ passkeyMode: mode }); toast({ title: `Passkey mode set to ${mode}`, variant: 'success' }); } catch (err) { toast({ title: 'Failed to update', description: errorMessage(err), variant: 'error' }); } } return (

Configure MFA and passkey requirements for your organization's users.

MFA Mode
{['off', 'optional', 'required'].map((mode) => ( ))}
Passkeys
{authSettings.passkeyEnabled && (
Passkey Mode
{['optional', 'preferred', 'required'].map((mode) => ( ))}
)}
); } export function SettingsPage() { const { data, isLoading, isError } = useTenantSettings(); const resetServerAdmin = useResetServerAdminPassword(); const { toast } = useToast(); const [serverAdminPw, setServerAdminPw] = useState(''); if (isLoading) { return (
); } if (isError || !data) { return (
Could not fetch settings. Please refresh.
); } return (

Settings

{/* Card 1: Tenant Details */}
Name {data.name}
Slug {data.slug}
Status
Server Endpoint {data.serverEndpoint ?? '—'}
Created {new Date(data.createdAt).toLocaleDateString()}

Reset the built-in admin password for your server dashboard (local login at /login?local).

{ e.preventDefault(); if (serverAdminPw.length < 8) { toast({ title: 'Password must be at least 8 characters', variant: 'error' }); return; } try { await resetServerAdmin.mutateAsync(serverAdminPw); toast({ title: 'Server admin password reset successfully', variant: 'success' }); setServerAdminPw(''); } catch (err) { toast({ title: 'Failed to reset server admin password', description: errorMessage(err), variant: 'error' }); } }} style={{ display: 'flex', gap: 8, alignItems: 'flex-end' }} >
setServerAdminPw(e.target.value)} placeholder="Enter new admin password" required minLength={8} />
{/* Card 2: Multi-Factor Authentication (MFA + Passkeys combined) */}

Passkeys

{/* Card 3: Authentication Policy (org-wide settings) */}
); }