sdlc-hub/web/src/projects/ProjectPicker.tsx
2026-10-22 00:23:39 +04:00

18 lines
903 B
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { Select } from "../ui/index.ts";
import { useProjectContext } from "./ProjectContext.ts";
const NEW = " new"; // служебное значение пункта «Новый проект…»: метка пробелов содержать не может
export function ProjectPicker() {
const { state, projects, select, openNew } = useProjectContext();
const current = state.kind === "ok" ? state.project.label : "";
return (
<Select className="project-picker" aria-label="Проект" value={current}
onChange={(e) => { if (e.target.value === NEW) openNew(); else select(e.target.value); }}>
{current === "" && <option value="" disabled>выберите проект</option>}
{projects.map((p) => <option key={p.label} value={p.label}>{p.label} — {p.name}</option>)}
<option value={NEW}>+ Новый проект…</option>
</Select>
);
}