'use client' import type { Dispatch, SetStateAction } from 'react' import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog' import type { MemberForm } from '../types' // Top-level (NOT defined inside the render body): keeping this stable is what // preserves input focus across keystrokes. The add and edit dialogs both render it. function MemberFormFields({ form, setForm }: { form: MemberForm; setForm: Dispatch> }) { return ( <>
setForm(f => ({ ...f, display_name: e.target.value }))} className="w-full bg-background border border-border rounded px-3 py-2 font-sans text-sm text-foreground focus:outline-none focus:border-primary transition" />
setForm(f => ({ ...f, email: e.target.value }))} className="w-full bg-background border border-border rounded px-3 py-2 font-sans text-sm text-foreground focus:outline-none focus:border-primary transition" />
setForm(f => ({ ...f, phone: e.target.value }))} className="w-full bg-background border border-border rounded px-3 py-2 font-sans text-sm text-foreground focus:outline-none focus:border-primary transition" />
setForm(f => ({ ...f, handle: e.target.value }))} className="w-full bg-background border border-border rounded px-3 py-2 font-mono text-sm text-foreground focus:outline-none focus:border-primary transition" />
setForm(f => ({ ...f, joined_at: e.target.value }))} className="w-full bg-background border border-border rounded px-3 py-2 font-sans text-sm text-foreground focus:outline-none focus:border-primary" />
) } interface MemberFormDialogProps { open: boolean // Drives title + submit-button copy; add and edit share one form-state shape. isEdit: boolean memberName?: string | null form: MemberForm setForm: Dispatch> loading: boolean error: string onSubmit: (e: React.FormEvent) => void onClose: () => void } export function MemberFormDialog({ open, isEdit, memberName, form, setForm, loading, error, onSubmit, onClose }: MemberFormDialogProps) { return ( { if (!o) onClose() }}> {isEdit ? <>Edit {memberName} : 'Add Member'}
{error &&

{error}

}
) }