import { useState } from "react"; import { useMutation, useQueryClient } from "@tanstack/react-query"; import type { ProjectWorkspace } from "@paperclipai/shared"; import { Link } from "lucide-react"; import { projectsApi } from "@/api/projects"; import { queryKeys } from "@/lib/queryKeys"; import { Button } from "./ui/button"; import { Input } from "./ui/input"; /** Preserve manual URL editing for workspaces created before the GitHub picker. */ export function LegacyProjectRepository({ workspace, projectRef }: { workspace: ProjectWorkspace; projectRef: string }) { const client = useQueryClient(); const [draft, setDraft] = useState(null); const save = useMutation({ mutationFn: async () => { const repoUrl = draft?.trim() || null; if (!repoUrl && !workspace.cwd && !workspace.remoteWorkspaceRef) return projectsApi.removeWorkspace(workspace.projectId, workspace.id); return projectsApi.updateWorkspace(workspace.projectId, workspace.id, { repoUrl }); }, onSuccess: () => { void client.invalidateQueries({ queryKey: queryKeys.projects.all(workspace.companyId) }); void client.invalidateQueries({ queryKey: queryKeys.projects.detail(workspace.projectId) }); void client.invalidateQueries({ queryKey: queryKeys.projects.detail(projectRef) }); setDraft(null); }, }); return
Existing repo URL {draft === null ?
{workspace.repoUrl}
:
{ event.preventDefault(); if (!save.isPending) save.mutate(); }}> setDraft(event.target.value)} /> {save.isError &&

{save.error.message}

}
}
; }