import { useState, type ChangeEvent } from 'react'; import { uploadMedia } from '../../services/api'; import type { FullProfile } from '../../types'; interface BasicProfileFormProps { profile: FullProfile; onChange: (profile: FullProfile) => void; } function BasicProfileForm({ profile, onChange }: BasicProfileFormProps) { const [isUploading, setIsUploading] = useState(false); const [uploadMessage, setUploadMessage] = useState(''); const [uploadError, setUploadError] = useState(''); const updateField = (field: keyof FullProfile, value: string | undefined) => { onChange({ ...profile, [field]: value, }); }; const handleProfileImageUpload = async (event: ChangeEvent) => { const file = event.target.files?.[0]; event.target.value = ''; if (!file) return; setIsUploading(true); setUploadMessage(''); setUploadError(''); try { const paths = await uploadMedia(file); const imagePath = paths.find((path) => /\.(png|jpg|jpeg|webp|gif)$/i.test(path)); if (!imagePath) { setUploadError('Upload completed, but no image path was returned.'); return; } updateField('profile_image_path', imagePath); setUploadMessage('Profile image uploaded and selected.'); } catch (error) { setUploadError(error instanceof Error ? error.message : 'Failed to upload profile image.'); } finally { setIsUploading(false); } }; return (

Basic Profile

Edit the public identity, profile image, title, location, tagline, and bio.

Profile Image

Upload a portrait image. The saved path appears in the public hero section.

{profile.profile_image_path ? Profile preview : H7}
{uploadMessage &&

{uploadMessage}

} {uploadError &&

{uploadError}

}