1
0
mirror of https://github.com/oceanprotocol/market.git synced 2024-12-02 05:57:29 +01:00
claudiaHash b1d8a77895
Update file metadata from provider (#631)
* get file metadata from provider

* get file metadata without a wallet connected

* unused import deleted

* get file metadata from provider


get file metadata without a wallet connected


unused import deleted

* loader added

* lint fix

* loaded added on file icon

* fileMetadata empty object init

* lint error fixed, deleted unused imports

Co-authored-by: claudia.holhos <claudia.holhos@hpm.ro>
2021-06-10 11:39:24 +03:00

61 lines
1.3 KiB
TypeScript

import React, { ReactElement } from 'react'
import { File as FileMetadata } from '@oceanprotocol/lib'
import filesize from 'filesize'
import classNames from 'classnames/bind'
import cleanupContentType from '../../utils/cleanupContentType'
import styles from './File.module.css'
import Loader from '../atoms/Loader'
const cx = classNames.bind(styles)
function LoaderArea() {
return (
<div className={styles.loaderWrap}>
<Loader />
</div>
)
}
export default function File({
file,
className,
small,
isLoading
}: {
file: FileMetadata
className?: string
small?: boolean
isLoading?: boolean
}): ReactElement {
if (!file) return null
const styleClasses = cx({
file: true,
small: small,
[className]: className
})
return (
<ul className={styleClasses}>
{isLoading === false || isLoading === undefined ? (
<>
{file.contentType || file.contentLength ? (
<>
<li>{cleanupContentType(file.contentType)}</li>
<li>
{file.contentLength && file.contentLength !== '0'
? filesize(Number(file.contentLength))
: ''}
</li>
</>
) : (
<li className={styles.empty}>No file info available</li>
)}
</>
) : (
<LoaderArea />
)}
</ul>
)
}