--- import AppLayout from '../layouts/AppLayout.astro'; import { updateUserProfile } from '../lib/db'; const user = Astro.locals.user; let success = false; let error: string | null = null; if (Astro.request.method === 'POST') { const data = await Astro.request.formData(); const name = String(data.get('name') ?? '').trim(); const bio = String(data.get('bio') ?? '').trim(); if (name.length < 2) { error = 'Name must be at least 2 characters.'; } else if (bio.length > 280) { error = 'Bio must be 280 characters or fewer.'; } else { updateUserProfile(user.id, name, bio); return Astro.redirect('/account?saved=1'); } } const saved = Astro.url.searchParams.get('saved') === '1'; ---
{saved && (

Profile updated.

)} {error && ( )}