import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { faFileImport } from '@fortawesome/free-solid-svg-icons/faFileImport'; import { faFileAlt } from '@fortawesome/free-solid-svg-icons/faFileAlt'; import { faFolder } from '@fortawesome/free-solid-svg-icons/faFolder'; import { bytesToHuman } from '@/helpers'; import differenceInHours from 'date-fns/difference_in_hours'; import format from 'date-fns/format'; import distanceInWordsToNow from 'date-fns/distance_in_words_to_now'; import React from 'react'; import { FileObject } from '@/api/server/files/loadDirectory'; import FileDropdownMenu from '@/components/server/files/FileDropdownMenu'; import { ServerContext } from '@/state/server'; export default ({ file }: { file: FileObject }) => { const directory = ServerContext.useStoreState(state => state.files.directory); return ( { if (file.isFile) { return e.preventDefault(); } }} >
{file.isFile ? : }
{file.name}
{file.isFile &&
{bytesToHuman(file.size)}
}
{Math.abs(differenceInHours(file.modifiedAt, new Date())) > 48 ? format(file.modifiedAt, 'MMM Do, YYYY h:mma') : distanceInWordsToNow(file.modifiedAt, { includeSeconds: true }) }
); };