import type { OdFolderChildren } from '../types'
import Link from 'next/link'
import { FC } from 'react'
import { useClipboard } from 'use-clipboard-copy'
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
import { useTranslation } from 'next-i18next'
import { getBaseUrl } from '../utils/getBaseUrl'
import { humanFileSize, formatModifiedDateTime } from '../utils/fileDetails'
import { getReadablePath } from '../utils/getReadablePath'
import { Downloading, Checkbox, formatChildName, ChildIcon } from './FileListing'
const FileListItem: FC<{ fileContent: OdFolderChildren }> = ({ fileContent: c }) => {
return (
{formatChildName(c.name)}
{formatModifiedDateTime(c.lastModifiedDateTime)}
{humanFileSize(c.size)}
)
}
const FolderListLayout = ({
path,
folderChildren,
selected,
toggleItemSelected,
totalSelected,
toggleTotalSelected,
totalGenerating,
handleSelectedDownload,
folderGenerating,
handleFolderDownload,
toast,
}) => {
const clipboard = useClipboard()
const { t } = useTranslation()
return (
{t('Name')}
{t('Last Modified')}
{t('Size')}
{t('Actions')}
{totalGenerating ? (
) : (
)}
{folderChildren.map((c: OdFolderChildren) => (
{c.folder ? (
{
clipboard.copy(
`${getBaseUrl()}${getReadablePath(`${path === '/' ? '' : path}/${encodeURIComponent(c.name)}`)}`
)
toast(t('Copied folder permalink.'), { icon: '👌' })
}}
>
{folderGenerating[c.id] ? (
) : (
{
const p = `${path === '/' ? '' : path}/${encodeURIComponent(c.name)}`
handleFolderDownload(p, c.id, c.name)()
}}
>
)}
) : (
{
clipboard.copy(
`${getBaseUrl()}/api?path=${getReadablePath(
`${path === '/' ? '' : path}/${encodeURIComponent(c.name)}`
)}&raw=true`
)
toast.success(t('Copied raw file permalink.'))
}}
>
)}
{!c.folder && !(c.name === '.password') && (
toggleItemSelected(c.id)}
title={t('Select file')}
/>
)}
))}
)
}
export default FolderListLayout