import { Eye, Square } from 'lucide-react'; import { provenanceLine } from './shareableRecordItem'; import { useShownRecordItem, type ShownRead } from './useShownRecordItem'; interface Props { reference: string; /** Who is showing it, as this viewer should read it. */ sharerName: string; /** Whom the host is showing it to, named in the host's own line. */ audienceName?: string; /** The viewer is the one showing it. Only they get Stop showing. */ isSharer: boolean; onStop?: () => void; stopping?: boolean; stopError?: string | null; /** A read the window already holds, so the banner and the stage share one request. */ read?: ShownRead; retry?: () => void; /** The item is on the stage, so the banner does not repeat its detail. */ staged?: boolean; } /** * Read under this viewer's own access; a viewer who may not see it is told so, not shown it empty. */ export const ShownRecordItem = ({ reference, sharerName, audienceName, isSharer, onStop, stopping, stopError, read: held, retry: heldRetry, staged }: Props) => { const own = useShownRecordItem(held ? null : reference); const read = held ?? own.read; const retry = heldRetry ?? own.retry; const summary = read.state === 'ready' ? read.summary : undefined; const provenance = summary ? provenanceLine(summary) : undefined; return (
{stopError &&

{stopError}

} {read.state === 'loading' &&

Opening the item…

} {read.state === 'refused' && (

{isSharer ? 'You do not have access to this item.' : sharerName + ' is showing an item from the record that you do not have access to.'}

)} {read.state === 'failed' && (

The item being shown could not be opened.

)} {!staged && summary?.detail &&

{summary.detail}

} {!staged && summary?.changedHere &&

{summary.changedHere}

}
); }; export default ShownRecordItem;