import { useState, type ReactNode } from 'react';
import type { ProfilePageProps } from './types.js';
export function ProfilePage({
user,
onUpdateProfile,
isLoading,
error,
success,
}: ProfilePageProps): ReactNode {
const [name, setName] = useState(user.name);
const [email, setEmail] = useState(user.email);
const handleSubmit = (e: React.FormEvent) => {
e.preventDefault();
if (onUpdateProfile) onUpdateProfile({ name, email });
};
return (
Profile
{error && (
{error}
)}
{success && (
{success}
)}
{/* Avatar */}
{user.avatarUrl ? (

) : (
user.name
.split(' ')
.map(w => w[0])
.join('')
.toUpperCase()
.slice(0, 2)
)}
{user.name}
{user.email}
{user.role && (
Role: {user.role}
)}
{/* Form */}
);
}
const labelStyle: React.CSSProperties = {
display: 'block',
fontSize: 14,
fontWeight: 500,
marginBottom: 6,
color: 'var(--color-foreground, #111827)',
};
const inputStyle: React.CSSProperties = {
width: '100%',
padding: '10px 12px',
borderRadius: 8,
border: '1px solid var(--bl-shell-border, var(--color-border, #e5e7eb))',
fontSize: 14,
background: 'var(--color-surface, #fff)',
color: 'var(--color-foreground, #111827)',
boxSizing: 'border-box',
};
function alertStyle(color: string): React.CSSProperties {
return {
padding: '10px 14px',
borderRadius: 8,
marginBottom: 16,
fontSize: 14,
color,
background: `color-mix(in srgb, ${color} 10%, transparent)`,
border: `1px solid color-mix(in srgb, ${color} 30%, transparent)`,
};
}