import { Fragment } from 'react'
import { Upload, Star } from 'lucide-react'
import type { FileManagerState } from './useFileManager'
import { FileRow } from './FileManagerRow'
import { usePluginViewContributions, PluginCardFooter } from '../Plugins/PluginContributions'
import EmptyState from '../shared/EmptyState'
export function FilesView(S: FileManagerState) {
const {
can, trip, getRootProps, getInputProps, isDragActive, uploading, t, allowedFileTypes,
files, filterType, setFilterType, filteredFiles,
} = S
const contribFor = usePluginViewContributions('files', S.tripId)
return (
<>
{/* Upload zone */}
{can('file_upload', trip) &&
{uploading ? (
) : (
<>
{t('files.dropzone')}
{t('files.dropzoneHint')}
{(allowedFileTypes || 'jpg,jpeg,png,gif,webp,heic,pdf,doc,docx,xls,xlsx,txt,csv').toUpperCase().split(',').join(', ')} ยท Max 50 MB
>
)}
}
{/* Filter tabs */}
{[
{ id: 'all', label: t('files.filterAll') },
...(files.some(f => f.starred) ? [{ id: 'starred', icon: Star }] : []),
{ id: 'pdf', label: t('files.filterPdf') },
{ id: 'image', label: t('files.filterImages') },
{ id: 'doc', label: t('files.filterDocs') },
...(files.some(f => f.note_id) ? [{ id: 'collab', label: t('files.filterCollab') || 'Collab' }] : []),
].map(tab => (
))}
{filteredFiles.length === 1 ? t('files.countSingular') : t('files.count', { count: filteredFiles.length })}
{/* File list */}
{filteredFiles.length === 0 ? (
) : (
{filteredFiles.map(file => {
const contributions = contribFor(file.id)
return (
{contributions.length > 0 && }
)
})}
)}
>
)
}