{open && (
<>
setOpen(false)} />
{ onChange('all'); setOpen(false); }}
label="全部产品"
/>
{options.map((opt) => (
{ onChange(opt.id); setOpen(false); }}
label={opt.name}
/>
))}
>
)}
);
}
function DropdownItem({
active,
onClick,
label,
}: {
active: boolean;
onClick: () => void;
label: string;
}) {
return (
);
}
/* ─── LegendDot ──────────────────────────────────────────────────── */
function LegendDot({ color, label }: { color: string; label: string }) {
return (
{label}
);
}
/* ─── EmptyState ─────────────────────────────────────────────────── */
function EmptyState() {
return (
);
}
/* ─── CreateProjectModal ─────────────────────────────────────────── */
function CreateProjectModal({
products,
overview,
onClose,
onSubmit,
}: {
products: { id: string; name: string }[];
overview: any[];
onClose: () => void;
onSubmit: (productId: string, name: string, description: string) => Promise
;
}) {
const [productId, setProductId] = useState('');
const [name, setName] = useState('');
const [description, setDescription] = useState('');
const [submitting, setSubmitting] = useState(false);
const [duplicateError, setDuplicateError] = useState(false);
const handleSubmit = async () => {
if (!productId || !name.trim()) return;
const product = overview.find((p: any) => p.id === productId);
if (product) {
const exists = product.projects?.some(
(proj: any) => proj.name === name.trim()
);
if (exists) {
setDuplicateError(true);
return;
}
}
setSubmitting(true);
try {
await onSubmit(productId, name.trim(), description.trim());
} finally {
setSubmitting(false);
}
};
return (
新建项目
{/* Product select */}
{/* Name */}
{ setName(e.target.value); setDuplicateError(false); }}
placeholder="请输入项目名称"
className={`h-9 w-full rounded-lg border bg-[var(--bg)] px-3 text-[13px] text-[var(--ink)] placeholder:text-[var(--ink-muted)] focus:outline-none focus:ring-2 ${
duplicateError
? 'border-red-500 focus:border-red-500 focus:ring-red-100'
: 'border-[var(--line)] focus:border-[var(--accent)] focus:ring-[var(--accent-ring)]'
}`}
/>
{duplicateError && (
该产品下已存在同名项目
)}
{/* Description */}
);
}