import { useEffect, useState } from "react"; import { Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from "../components/ui/dialog"; import { Button } from "../components/ui/button"; interface Props { open: boolean; initial: string; onOpenChange: (open: boolean) => void; onSubmit: (name: string) => void; title?: string; } export function RenameDialog({ open, initial, onOpenChange, onSubmit, title = "Rename session" }: Props) { const [name, setName] = useState(initial); useEffect(() => { if (open) setName(initial); }, [open, initial]); function submit(e: React.FormEvent) { e.preventDefault(); if (!name.trim()) return; onSubmit(name.trim()); onOpenChange(false); } return ( {title}
setName(e.target.value)} className="w-full rounded-lg border border-input bg-card px-3 py-2 text-sm shadow-xs outline-none transition-[border-color,box-shadow] focus:border-primary/50 focus:ring-3 focus:ring-ring/15" placeholder="Session name…" />
); }