import React from "react"; import clsx from "clsx"; import { initialsOf } from "../../../components/ui/org-badge.tsx"; // Smaller than this on either side is not a picture of anything; staging holds a 1x1 logo that drew // as a flat colour block. const SMALLEST_USABLE_IMAGE = 8; // A photograph when there is a real one, the practice's logo for its front desk, and otherwise the // initials. Never the stock silhouette: a face that belongs to nobody reads as a person on the row. // An image that fails to load, or loads as a speck, falls back to the initials too. export const InboxAvatar = ({ label, imageUrl, isLogo = false, glyph, tone, }: { label: string; imageUrl?: string; isLogo?: boolean; glyph?: React.ReactNode; /** Whose mark it is, for initials only: "patient" draws the deck's tan patient mark. */ tone?: "patient"; }) => { const [unusable, setUnusable] = React.useState(null); const showImage = !!imageUrl && unusable !== imageUrl; return ( ); }; export type InboxRowProps = { avatar: React.ReactNode; name: string; sub?: string; preview?: string; time: string; unread: number; selected: boolean; online?: boolean; onOpen: (event: React.SyntheticEvent) => void; }; // Name and time on the first line, who they are on the second, the last thing said on the third. export const InboxRow = ({ avatar, name, sub, preview, time, unread, selected, online, onOpen }: InboxRowProps) => (
{ if (event.key !== "Enter" && event.key !== " ") return; event.preventDefault(); onOpen(event); }} className={clsx( "ahr-inbox-row focus-visible:outline focus-visible:outline-2 focus-visible:outline-offset-2", selected && "ahr-inbox-row--on", )} > {avatar} {online && } {name} {time} {sub && {sub}} {(preview || unread > 0) && ( {preview} {unread > 0 && {unread}} )}
);