import * as React from "react"; import { styled } from "@mui/material/styles"; import Table from "@mui/material/Table"; import TableBody from "@mui/material/TableBody"; import TableCell, { tableCellClasses } from "@mui/material/TableCell"; import TableContainer from "@mui/material/TableContainer"; import TableHead from "@mui/material/TableHead"; import TableRow from "@mui/material/TableRow"; import { Paper, Button } from "@mui/material"; import ArrowUpwardIcon from "@mui/icons-material/ArrowUpward"; import ArrowDownwardIcon from "@mui/icons-material/ArrowDownward"; import "./table.css"; import {lastDisplayIndex} from "../../constants"; const StyledTableCell = styled(TableCell)(({ theme }) => ({ [`&.${tableCellClasses.head}`]: { backgroundColor: theme.palette.primary.light, color: theme.palette.common.white, fontSize: 15, fontWeight: "bold", }, [`&.${tableCellClasses.body}`]: { fontSize: 14, }, })); const StyledTableRow = styled(TableRow)(({ theme }) => ({ "&:nth-of-type(odd)": { backgroundColor: theme.palette.action.hover, }, // hide last border "&:last-child td, &:last-child th": { border: 0, }, })); const getlastValueIndex = (index) => { return index < lastDisplayIndex ? index + 1 : lastDisplayIndex + 1; }; const getValueDiff = (row, data, index, key) => { return row[key] - data[getlastValueIndex(index, data.length - 1)][key]; } export default function CustomizedTables(props) { // const const [data, setlastValue] = React.useState(props.values); const displayData = [...data]; displayData.pop(); return ( Price Change Change (%) Volume {displayData.map((row, index) => ( {" "} $ {row.Close.toFixed(5)} = 0 ? "green" : "red" } > = 0 ? "green" : "red" } > = 0 ? "green" : "red" } > {row.Volume} ))}
); }