import { useState } from "react"; import { commitChanges } from "../api/git_repositories"; interface CommitPanelProps { projectId: string; repoId: string; modified: string[]; added: string[]; deleted: string[]; untracked: string[]; onCommit: () => void; } export const CommitPanel = ({ projectId, repoId, modified, added, deleted, untracked, onCommit, }: CommitPanelProps) => { const [message, setMessage] = useState(""); const [loading, setLoading] = useState(false); const [error, setError] = useState(null); const allFiles = [...modified, ...added, ...deleted, ...untracked]; const hasChanges = allFiles.length > 0; const handleCommit = async () => { if (!message.trim()) { setError("Please enter a commit message"); return; } setLoading(true); setError(null); try { await commitChanges(projectId, repoId, message); setMessage(""); onCommit(); } catch { setError("Commit failed. Please try again."); } finally { setLoading(false); } }; if (!hasChanges) return null; return (

Changes

{modified.map((file) => (
M {file}
))} {added.map((file) => (
A {file}
))} {deleted.map((file) => (
D {file}
))} {untracked.map((file) => (
? {file}
))}