Skip to content

Commit

Permalink
[Platform]: add empty AotF message (#399)
Browse files Browse the repository at this point in the history
  • Loading branch information
carcruz authored Jun 26, 2024
1 parent 9791006 commit fc8bbeb
Showing 1 changed file with 46 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import { Fragment } from "react";
import { flexRender } from "@tanstack/react-table";
import { ClickAwayListener, Fade, Box } from "@mui/material";
import { ClickAwayListener, Fade, Box, Typography } from "@mui/material";
import { v1 } from "uuid";
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
import { faFilterCircleXmark } from "@fortawesome/free-solid-svg-icons";
import { grey } from "@mui/material/colors";

import useAotfContext from "../../hooks/useAotfContext";

Expand Down Expand Up @@ -30,17 +33,57 @@ function ExpandableContainer({ rowExpanded, isExpandedInTable, loading, children
return <Box key={v1()}>{children}</Box>;
}

function EmptyMessage() {
return (
<Box
sx={{
width: "auto",
px: 5,
py: 6,
display: "flex",
flexDirection: "column",
alignItems: "center",
justifyContent: "center",
}}
>
<Box
sx={{
borderRadius: "50%",
backgroundColor: grey[300],
display: "flex",
width: "100px",
height: "100px",
justifyContent: "center",
alignItems: "center",
mb: 2,
}}
>
<FontAwesomeIcon size="3x" icon={faFilterCircleXmark} />
</Box>
<Typography variant="h5" sx={{ mb: 2 }}>
No results found
</Typography>
<Typography variant="body">
Try adjust your search or filter to find what you looking for.
</Typography>
</Box>
);
}

function TableBody({ core, cols }) {
const { id, entity, entityToGet, displayedTable, resetExpandler, expanded } = useAotfContext();

const { rows } = core.getRowModel();
if (rows.length < 1) return null;
const { prefix, loading } = core.getState();

if (prefix === "pinned" && rows.length < 1) return null;

if (rows.length < 1) return <EmptyMessage />;

const flatCols = ["name", ...cols.map(c => c.id)];

const rowNameEntity = entity === "target" ? "name" : "approvedSymbol";
const highLevelHeaders = core.getHeaderGroups()[0].headers;
const { prefix, loading } = core.getState();
const isExpandedInTable = expanded[3] === prefix && flatCols.includes(expanded[1]);

const handleClickAway = e => {
Expand Down

0 comments on commit fc8bbeb

Please sign in to comment.