import { useState } from "react"; import { mergeBranches } from "../api/git_repositories"; interface MergeDialogProps { projectId: string; repoId: string; branches: string[]; currentBranch: string; isOpen: boolean; onClose: () => void; onMerge: () => void; } export const MergeDialog = ({ projectId, repoId, branches, currentBranch, isOpen, onClose, onMerge, }: MergeDialogProps) => { const [sourceBranch, setSourceBranch] = useState(""); const [commitMessage, setCommitMessage] = useState(""); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const [success, setSuccess] = useState(false); if (!isOpen) return null; const availableBranches = branches.filter((b) => b !== currentBranch); const handleMerge = async () => { if (!sourceBranch) { setError("Please select a source branch"); return; } setLoading(true); setError(null); setSuccess(false); try { await mergeBranches( projectId, repoId, sourceBranch, currentBranch, commitMessage || undefined ); setSuccess(true); setTimeout(() => { onMerge(); onClose(); }, 1500); } catch { setError("Merge failed. There may be conflicts to resolve."); } finally { setLoading(false); } }; return (
e.stopPropagation()}>

Merge Branch