import React, { useState } from 'react'; import { GitCommit, Rocket, Copy, CheckCircle } from 'lucide-react'; const CommitList = ({ commits, currentCommit, onDeploy, onCreateDev, loading = false }) => { const [actionLoading, setActionLoading] = useState({}); const [showDevModal, setShowDevModal] = useState(null); function formatDate(dateString) { if (!dateString) return '-'; const date = new Date(dateString); const now = new Date(); const diffMs = now - date; const diffHours = Math.floor(diffMs / (1000 * 60 * 60)); const diffDays = Math.floor(diffHours / 24); if (diffHours < 1) return 'Just now'; if (diffHours < 24) return `${diffHours}h ago`; if (diffDays < 7) return `${diffDays}d ago`; return date.toLocaleDateString(); } async function handleDeploy(commit) { if (!confirm(`Deploy commit ${commit.sha.substring(0, 7)} to production?`)) { return; } setActionLoading(prev => ({ ...prev, [`deploy-${commit.sha}`]: true })); try { await onDeploy?.({ commit_sha: commit.sha }); } finally { setActionLoading(prev => ({ ...prev, [`deploy-${commit.sha}`]: false })); } } async function handleCreateDev(commit, config) { setActionLoading(prev => ({ ...prev, [`dev-${commit.sha}`]: true })); try { await onCreateDev?.({ commit_sha: commit.sha, config }); setShowDevModal(null); } finally { setActionLoading(prev => ({ ...prev, [`dev-${commit.sha}`]: false })); } } if (loading) { return
No commits found.
Push changes to your repository to see commits here.
{commit.message}
{commit.author && ( {commit.author} )}
Create a development environment with code from commit{' '}
{commit.sha.substring(0, 7)}
"{commit.message}"