mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-12 13:13:45 +01:00
46 lines
1.2 KiB
TypeScript
46 lines
1.2 KiB
TypeScript
import { useTranslation } from 'react-i18next'
|
|
import { formatTime, relativeDate } from '@/features/utils/format-date'
|
|
import { LinkedFileIcon } from '@/features/file-view/components/file-view-icons'
|
|
import type { BinaryFile } from '@/features/file-view/types/binary-file'
|
|
|
|
type TPRFileViewInfoProps = {
|
|
file: BinaryFile
|
|
}
|
|
|
|
/**
|
|
* Shows "Imported from Zotero at <date>" in the file view header
|
|
* when viewing a Zotero-linked .bib file.
|
|
* Registered via overleafModuleImports.tprFileViewInfo.
|
|
*/
|
|
export function TPRFileViewInfo({ file }: TPRFileViewInfoProps) {
|
|
const { t } = useTranslation()
|
|
|
|
if (file.linkedFileData?.provider !== 'zotero') {
|
|
return null
|
|
}
|
|
|
|
const importedAt = (file.linkedFileData as any)?.importedAt || file.created
|
|
const formattedDate = formatTime(importedAt)
|
|
const relative = relativeDate(importedAt)
|
|
|
|
const groupId = (file.linkedFileData as any)?.zoteroGroupId
|
|
|
|
return (
|
|
<p>
|
|
<div>
|
|
<span>
|
|
<LinkedFileIcon />
|
|
|
|
{t('imported_from_zotero_at_date', {
|
|
formattedDate,
|
|
relativeDate: relative,
|
|
})}
|
|
</span>
|
|
{groupId && (
|
|
<span className="text-muted small"> (Group: {groupId})</span>
|
|
)}
|
|
</div>
|
|
</p>
|
|
)
|
|
}
|