import { AccessTime, MoreVert } from "@mui/icons-material"; import { Avatar, Box, Card, IconButton, Table, TableBody, TableCell, TableHead, TableRow, Typography, useTheme } from "@mui/material"; import moment from "moment"; import React from "react"; interface SensorRow { label: string; data: string; } interface CableRow { label: string; min: string; avg: string; max: string; } interface Props { name: string; icon?: string; tag: string; lastReading: string; onMenuClick: (event: React.MouseEvent) => void; rows?: SensorRow[]; cableRows?: CableRow[]; /** * the time in hours that a reading is considered 'good' * defaults to 6 */ staleLimit?: number; } export default function BinSensorCard(props: Props) { const { name, icon, tag, lastReading, onMenuClick, rows, cableRows, staleLimit = 6 } = props const theme = useTheme() const isStale = moment().diff(moment(lastReading), "hours") > staleLimit return ( {icon && } {name} - {tag} {cableRows ? ( <> Min Avg Max {cableRows.map((row) => ( {row.label} {row.min} {row.avg} {row.max} ))} ) : ( {rows?.map((row) => ( {row.label} {row.data} ))} )}
{moment(lastReading).fromNow()}
) }