'use client' import { useState, useTransition } from 'react' import { useRouter } from 'next/navigation' import { updateMyProfile } from '@/lib/actions' import { ChipInput } from '@/components/chip-input' import { WILLING_TO_SUGGESTIONS } from '@/lib/profile-presets' type Props = { initial: { display_name: string handle: string phone: string skills: string[] interests: string[] willing_to: string[] } } export function ProfileForm({ initial }: Props) { const router = useRouter() const [displayName, setDisplayName] = useState(initial.display_name) const [handle, setHandle] = useState(initial.handle) const [phone, setPhone] = useState(initial.phone) const [skills, setSkills] = useState(initial.skills) const [interests, setInterests] = useState(initial.interests) const [willingTo, setWillingTo] = useState(initial.willing_to) const [error, setError] = useState('') const [status, setStatus] = useState<'idle' | 'saved'>('idle') const [isPending, startTransition] = useTransition() function handleSubmit(e: React.FormEvent) { e.preventDefault() setError('') setStatus('idle') startTransition(async () => { const r = await updateMyProfile({ display_name: displayName, handle: handle || null, phone: phone || null, skills, interests, willing_to: willingTo, }) if ('error' in r && r.error) setError(r.error) else { setStatus('saved') router.refresh() } }) } return (
setDisplayName(e.target.value)} maxLength={100} required className="w-full bg-background border border-border text-foreground font-sans text-sm rounded px-3 py-2 focus:outline-none focus:border-primary" />
setHandle(e.target.value)} maxLength={50} className="w-full bg-background border border-border text-foreground font-sans text-sm rounded px-3 py-2 focus:outline-none focus:border-primary" />
setPhone(e.target.value)} maxLength={20} className="w-full bg-background border border-border text-foreground font-sans text-sm rounded px-3 py-2 focus:outline-none focus:border-primary" />

Examples: woodworking, laser, electronics, accounting, grant writing.

Used by the recruitment view (board only) when looking for members willing to take on a role.

{error &&

{error}

} {status === 'saved' && !error && (

Saved.

)}
) }