Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | 9x 9x 1x 9x 19x 19x 9x 2x 9x | import OurTable, { ButtonColumn } from "../OurTable";
import { hasRole } from "../../utils/currentUser";
import { Link } from "react-router";
export default function MenuItemTable({ menuItems, currentUser }) {
const testid = "MenuItemTable";
const reviewCallback = async (_cell) => {
alert("Reviews coming soon!");
};
const columns = [
{
Header: "Item Name",
accessor: "name",
},
{
Header: "Station",
accessor: "station",
},
{
Header: "Reviews",
accessor: "id",
Cell: ({ value }) => <Link to={`/reviews/${value}`}>Reviews</Link>,
},
{
Header: "Avg Rating",
accessor: "averageRating",
Cell: ({ value }) => (value == null ? "—" : value.toFixed(1)),
},
];
if (hasRole(currentUser, "ROLE_USER")) {
columns.push(
ButtonColumn("Review Item", "warning", reviewCallback, testid),
);
}
return <OurTable columns={columns} data={menuItems} testid={testid} />;
}
|