FileListItem.tsx
643 Bytes
import React from "react";
import { FileItem } from "./useFileList";
import { Link } from "react-router-dom";
import { Button } from "antd";
import { FolderFilled, FileFilled } from "@ant-design/icons";
import { useDownload } from "./useDownload";
export function FileListItem({ item }: { item: FileItem }) {
const download = useDownload();
return item.is_folder ? (
<Link to={`/folder/${item.id}`}>
<FolderFilled /> {item.name}
</Link>
) : (
<Button
type="link"
size="small"
onClick={() => download(item.id)}
style={{ padding: 0 }}
>
<FileFilled /> {item.name}
</Button>
);
}