Created
August 5, 2021 18:27
-
-
Save sergeyt/1a24bf1206b75bd8dbcfe10c424a9baa to your computer and use it in GitHub Desktop.
multidisk item list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import isEmpty from "lodash/isEmpty"; | |
import List from "@material-ui/core/List"; | |
import { Item, File } from "../types"; | |
import FileItem from "./FileItem"; | |
import FolderItem from "./FolderItem"; | |
import Placeholder from "./Placeholder"; | |
export default function ItemList({ data }: { data: Item[] }) { | |
if (isEmpty(data)) { | |
return ( | |
<Placeholder> | |
This drive is empty, but you can fill it out with something :) | |
</Placeholder> | |
); | |
} | |
const items = data.map((item, k) => { | |
switch (item.type) { | |
case "file": | |
return <FileItem key={k} item={item as File} />; | |
case "folder": | |
return <FolderItem key={k} item={item as Item} />; | |
default: | |
return null; | |
} | |
}); | |
return <List>{items}</List>; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment