import React from 'react'; import { FolderIcon } from '../../components/icons'; import { formatDate } from '../../utils/date'; import DocumentThumbnailImage from '../DocumentThumbnailImage'; import { resolveCorrespondents } from '../correspondents'; import type { DocumentsListEntry } from '../../types/documents'; import { useDocumentsAssetContext } from '../context/DocumentsAssetContext'; import { useDocumentsViewStateContext } from '../context/DocumentsViewStateContext'; import { useDocumentsCommandContext } from '../context/DocumentsCommandContext'; import type { DocumentViewLogic } from '../logic/useDocumentViewLogic'; import EditableEntryTitle from './EditableEntryTitle'; import EntryCorrespondents from './EntryCorrespondents'; import DocumentTags from './DocumentTags'; import FolderEntry from './FolderEntry'; import DocumentEntry from './DocumentEntry'; import { TagInteractionHandlers } from '../interactions/useTagInteractions'; interface DocumentsListRowProps { entry: DocumentsListEntry; viewLogic: DocumentViewLogic; iconSize?: number; tagHandlers?: TagInteractionHandlers; } const DocumentsListRow: React.FC = (props) => { const { entry, iconSize, tagHandlers } = props; const { ensureAssetUrl, getDocumentAsset } = useDocumentsAssetContext(); const { scrollRef, activeCorrespondentIdSet, tagLookupById } = useDocumentsViewStateContext(); const { correspondents: { onClick: onCorrespondentClick }, tags: { onClick: onTagClick } } = useDocumentsCommandContext(); if (entry.type === 'folder') { const folder = entry.folder; if (!folder) return null; return ( {(logic) => ( <>
{folder.name}
— — )}
); } const doc = entry.document; if (!doc) return null; const correspondents = resolveCorrespondents(doc); const issuedLabel = formatDate(doc.issued_at); const addedLabel = formatDate(doc.created_at || doc.uploaded_at); return ( {(logic) => ( <>
{doc.title}
{issuedLabel} {addedLabel} )}
); }; export default DocumentsListRow;