feat: add website and folder upload and download (#260)
* feat: add website and folder upload and download * feat: download-share-upload navigation * fix: check for files length in hasIndexDocument * fix: change router dependency * refactor: switch to @ethersphere/manfest-js * fix: hide previews on dropzone, fix spinner align, hide 0 size display * feat: add upload and download history * refactor: change drag and drop text * feat: make history ux better * refactor: improve code based on review * build: add missing react-router dependency * ci: remove beeload * revert(ci): remove beeload This reverts commit 4ce6cb0045a2d9aea3047ab395d214d8d368c532.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
import { ReactElement, useEffect, useState } from 'react'
|
||||
import { getPrettyDateString } from '../utils/date'
|
||||
import { getHistorySafe, HistoryItem, HISTORY_KEYS } from '../utils/local-storage'
|
||||
import ExpandableList from './ExpandableList'
|
||||
import ExpandableListItemLink from './ExpandableListItemLink'
|
||||
|
||||
interface Props {
|
||||
title: string
|
||||
localStorageKey: HISTORY_KEYS
|
||||
}
|
||||
|
||||
export function History({ title, localStorageKey }: Props): ReactElement | null {
|
||||
const [items, setItems] = useState<HistoryItem[]>([])
|
||||
|
||||
useEffect(() => {
|
||||
setItems(getHistorySafe(localStorageKey))
|
||||
}, [localStorageKey])
|
||||
|
||||
if (!items.length) {
|
||||
return null
|
||||
}
|
||||
|
||||
return (
|
||||
<ExpandableList label={title} defaultOpen>
|
||||
{items.map((x, i) => (
|
||||
<ExpandableListItemLink
|
||||
label={getPrettyDateString(new Date(x.createdAt))}
|
||||
value={x.name}
|
||||
link={'/files/hash/' + x.hash}
|
||||
key={i}
|
||||
navigationType="HISTORY_PUSH"
|
||||
allowClipboard={false}
|
||||
/>
|
||||
))}
|
||||
</ExpandableList>
|
||||
)
|
||||
}
|
||||
Reference in New Issue
Block a user