import { useState } from "react"; import { useQuery, useQueryClient } from "@tanstack/react-query"; import { getGitRepos, importGitRepos, updateGitRepoDeploy, deleteGitRepo, githubGetToken, githubListRepos, type GitRepo, type UpdateGitRepoDeployInput, } from "../../lib/commands"; import { useUIStore } from "../../store/ui"; interface Props { onClose: () => void; } type Tab = "registry" | "sync"; // ── 部署信息编辑表单 ────────────────────────────────────────────────────────── function DeployForm({ repo, onSaved, onCancel, }: { repo: GitRepo; onSaved: () => void; onCancel: () => void; }) { const showToast = useUIStore((s) => s.showToast); const qc = useQueryClient(); const [form, setForm] = useState({ staging_url: repo.staging_url ?? "", prod_url: repo.prod_url ?? "", server_note: repo.server_note ?? "", upstream_url: repo.upstream_url ?? "", tech_stack: repo.tech_stack ?? "", status: repo.status ?? "active", priority: repo.priority ?? "mid", }); const [saving, setSaving] = useState(false); const set = (k: keyof UpdateGitRepoDeployInput) => (e: React.ChangeEvent) => setForm((f) => ({ ...f, [k]: e.target.value })); const handleSave = async () => { setSaving(true); try { await updateGitRepoDeploy(repo.id, form); qc.invalidateQueries({ queryKey: ["git-repos"] }); showToast("已保存 ✓"); onSaved(); } catch (e) { showToast(`❌ ${e}`); } finally { setSaving(false); } }; const inputCls = "w-full border border-gray-200 rounded-lg px-3 py-2 text-sm outline-none focus:ring-2 focus:ring-blue-200"; return (