2024-08-13 12:48:52 +03:00
|
|
|
import { CurrentUserFile } from '../../types/file.ts'
|
|
|
|
import styles from './style.module.scss'
|
|
|
|
import { Button } from '@mui/material'
|
2024-08-15 15:35:37 +03:00
|
|
|
import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'
|
|
|
|
import { faCheck } from '@fortawesome/free-solid-svg-icons'
|
2024-08-13 12:48:52 +03:00
|
|
|
|
|
|
|
interface FileListProps {
|
|
|
|
files: CurrentUserFile[]
|
|
|
|
currentFile: CurrentUserFile
|
|
|
|
setCurrentFile: (file: CurrentUserFile) => void
|
|
|
|
handleDownload: () => void
|
2024-08-21 11:21:26 +02:00
|
|
|
downloadLabel?: string
|
2024-08-13 12:48:52 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const FileList = ({
|
|
|
|
files,
|
|
|
|
currentFile,
|
|
|
|
setCurrentFile,
|
2024-08-21 11:21:26 +02:00
|
|
|
handleDownload,
|
|
|
|
downloadLabel
|
2024-08-13 12:48:52 +03:00
|
|
|
}: FileListProps) => {
|
|
|
|
const isActive = (file: CurrentUserFile) => file.id === currentFile.id
|
|
|
|
return (
|
2024-08-14 16:08:42 +03:00
|
|
|
<div className={styles.wrap}>
|
2024-08-30 17:58:40 +02:00
|
|
|
<ul className={styles.files}>
|
|
|
|
{files.map((currentUserFile: CurrentUserFile) => (
|
|
|
|
<li
|
|
|
|
key={currentUserFile.id}
|
|
|
|
className={`${styles.fileItem} ${isActive(currentUserFile) && styles.active}`}
|
|
|
|
onClick={() => setCurrentFile(currentUserFile)}
|
|
|
|
>
|
|
|
|
<div className={styles.fileNumber}>{currentUserFile.id}</div>
|
|
|
|
<div className={styles.fileInfo}>
|
|
|
|
<div className={styles.fileName}>{currentUserFile.file.name}</div>
|
|
|
|
</div>
|
2024-08-15 15:35:37 +03:00
|
|
|
|
2024-08-30 17:58:40 +02:00
|
|
|
<div className={styles.fileVisual}>
|
|
|
|
{currentUserFile.isHashValid && (
|
|
|
|
<FontAwesomeIcon icon={faCheck} />
|
|
|
|
)}
|
|
|
|
</div>
|
|
|
|
</li>
|
|
|
|
))}
|
|
|
|
</ul>
|
2024-08-13 12:48:52 +03:00
|
|
|
<Button variant="contained" fullWidth onClick={handleDownload}>
|
2024-08-21 13:11:56 +02:00
|
|
|
{downloadLabel || 'Download Files'}
|
2024-08-13 12:48:52 +03:00
|
|
|
</Button>
|
|
|
|
</div>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
export default FileList
|