@@ -27,15 +27,27 @@ const glyphFor = (documentType?: ReinsuranceDocumentType) => {
2727
2828// Lazily probes the document's first page image. Digital documents (e-mail, CSV,
2929// plain text) have no rendered page, so the request 404s and the type glyph stays.
30+ // Only these formats render a page image; requesting one for any other type
31+ // (CSV, Excel, e-mail, plain text) just 404s and noises up the console.
32+ const PAGE_IMAGE_EXTENSIONS = [ ".pdf" , ".png" , ".jpg" , ".jpeg" , ".tif" , ".tiff" ] ;
33+
34+ const rendersPage = ( fileName ?: string ) : boolean => {
35+ const lower = ( fileName ?? "" ) . toLowerCase ( ) ;
36+ return PAGE_IMAGE_EXTENSIONS . some ( ( extension ) => lower . endsWith ( extension ) ) ;
37+ } ;
38+
3039export function QueueThumbnail ( {
3140 documentId,
3241 documentType,
42+ fileName,
3343} : {
3444 documentId : string ;
3545 documentType ?: ReinsuranceDocumentType ;
46+ fileName ?: string ;
3647} ) {
3748 const [ hasImage , setHasImage ] = useState ( false ) ;
3849 const Glyph = glyphFor ( documentType ) ;
50+ const canRenderPage = rendersPage ( fileName ) ;
3951
4052 return (
4153 < span className = "relative flex h-12 w-[2.375rem] shrink-0 items-center justify-center overflow-hidden rounded-md border border-border bg-surface-2 text-subtle-foreground shadow-soft ring-1 ring-inset ring-border/40 transition-[border-color,box-shadow] group-hover:border-border-strong group-hover:shadow-pop" >
@@ -44,19 +56,23 @@ export function QueueThumbnail({
4456 < Glyph width = { 15 } height = { 15 } />
4557 </ span >
4658 ) }
47- { /* eslint-disable-next-line @next/next/no-img-element */ }
48- < img
49- src = { api . pageImageUrl ( documentId , 1 ) }
50- alt = ""
51- aria-hidden = "true"
52- loading = "lazy"
53- onLoad = { ( ) => setHasImage ( true ) }
54- onError = { ( ) => setHasImage ( false ) }
55- className = { cn (
56- "absolute inset-0 h-full w-full object-cover object-top transition-opacity duration-300" ,
57- hasImage ? "opacity-100" : "opacity-0" ,
58- ) }
59- />
59+ { canRenderPage && (
60+ < >
61+ { /* eslint-disable-next-line @next/next/no-img-element */ }
62+ < img
63+ src = { api . pageImageUrl ( documentId , 1 ) }
64+ alt = ""
65+ aria-hidden = "true"
66+ loading = "lazy"
67+ onLoad = { ( ) => setHasImage ( true ) }
68+ onError = { ( ) => setHasImage ( false ) }
69+ className = { cn (
70+ "absolute inset-0 h-full w-full object-cover object-top transition-opacity duration-300" ,
71+ hasImage ? "opacity-100" : "opacity-0" ,
72+ ) }
73+ />
74+ </ >
75+ ) }
6076 { /* A faint top sheen sells the thumbnail as a real page edge, not a flat box. */ }
6177 { hasImage && (
6278 < span
0 commit comments