import { Play, Trash2, Eye, EyeOff, Download, Clock, Users, FileVideo } from 'lucide-react'; import { useState } from 'react'; import api from '../services/api'; import { useLanguage } from '../contexts/LanguageContext'; import toast from 'react-hot-toast'; export default function RecordingList({ recordings, onRefresh }) { const [loading, setLoading] = useState({}); const { t, language } = useLanguage(); const formatDuration = (startTime, endTime) => { if (!startTime || !endTime) return '—'; const ms = parseInt(endTime) - parseInt(startTime); const minutes = Math.floor(ms / 60000); const hours = Math.floor(minutes / 60); const mins = minutes % 60; if (hours > 0) return `${hours}h ${mins}m`; return `${mins}m`; }; const formatDate = (timestamp) => { if (!timestamp) return '—'; return new Date(parseInt(timestamp)).toLocaleDateString(language === 'de' ? 'de-DE' : 'en-US', { day: '2-digit', month: '2-digit', year: 'numeric', hour: '2-digit', minute: '2-digit', }); }; const formatSize = (bytes) => { if (!bytes) return ''; const mb = parseInt(bytes) / (1024 * 1024); if (mb > 1024) return `${(mb / 1024).toFixed(1)} GB`; return `${mb.toFixed(1)} MB`; }; const handleDelete = async (recordID) => { if (!confirm(t('recordings.deleteConfirm'))) return; setLoading(prev => ({ ...prev, [recordID]: 'deleting' })); try { await api.delete(`/recordings/${recordID}`); toast.success(t('recordings.deleted')); onRefresh?.(); } catch (err) { toast.error(t('recordings.deleteFailed')); } finally { setLoading(prev => ({ ...prev, [recordID]: null })); } }; const handlePublish = async (recordID, publish) => { setLoading(prev => ({ ...prev, [recordID]: 'publishing' })); try { await api.put(`/recordings/${recordID}/publish`, { publish }); toast.success(publish ? t('recordings.publishSuccess') : t('recordings.unpublishSuccess')); onRefresh?.(); } catch (err) { toast.error(t('recordings.publishFailed')); } finally { setLoading(prev => ({ ...prev, [recordID]: null })); } }; if (!recordings || recordings.length === 0) { return (

{t('recordings.noRecordings')}

); } return (
{recordings.map(rec => (

{rec.name}

{rec.published ? t('recordings.published') : t('recordings.unpublished')}
{formatDate(rec.startTime)} {formatDuration(rec.startTime, rec.endTime)} {rec.participants && ( {rec.participants} )} {rec.size && ( {formatSize(rec.size)} )}
{/* Playback formats */} {rec.formats && rec.formats.length > 0 && (
{rec.formats.map((format, idx) => ( {format.type === 'presentation' ? t('recordings.presentation') : format.type} ))}
)}
{/* Actions */}
))}
); }