import CallMadeIcon from "@mui/icons-material/CallMade"; import CallReceivedIcon from "@mui/icons-material/CallReceived"; import QuestionMarkIcon from "@mui/icons-material/QuestionMark"; import React from "react"; import { match } from "ts-pattern"; import { InboxEntry } from "../api/InboxApi"; import { fmtDateFromTime } from "../utils/DateUtils"; import { AmountWidget } from "./AmountWidget"; import { UploadedFileWidget } from "./UploadedFileWidget"; export function InboxEntryWidget(p: { entry: InboxEntry }): React.ReactElement { return ( {/* File */} {/* Icon */} {match(p.entry.amount) .when( (v) => v === undefined, () => ) .when( (v) => v > 0, () => ) .otherwise(() => ( ))} {(p.entry.label?.length ?? 0) > 0 ? p.entry.label : No label} {p.entry.amount ? ( ) : ( No amount )} {fmtDateFromTime(p.entry.time)} ); }