Commit e71e2a8 1 parent 872b4a1 commit e71e2a8 Copy full SHA for e71e2a8
File tree 1 file changed +7
-3
lines changed
apps/dashboard/src/components
1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change 1
- import { Avatar , AvatarImage } from "@midday/ui/avatar" ;
1
+ import { Avatar } from "@midday/ui/avatar" ;
2
2
import Image from "next/image" ;
3
+ import { useState } from "react" ;
3
4
4
5
type Props = {
5
6
src : string | null ;
@@ -8,22 +9,25 @@ type Props = {
8
9
} ;
9
10
10
11
export function BankLogo ( { src, alt, size = 34 } : Props ) {
12
+ const [ hasError , setHasError ] = useState ( false ) ;
13
+
11
14
return (
12
15
< Avatar style = { { width : size , height : size } } >
13
- { src && (
16
+ { src && ! hasError && (
14
17
< Image
15
18
src = { src }
16
19
alt = { alt }
17
20
className = "text-transparent"
18
21
width = { size }
19
22
height = { size }
20
23
quality = { 100 }
24
+ onError = { ( ) => setHasError ( true ) }
21
25
/>
22
26
) }
23
27
< Image
24
28
src = "https://cdn-engine.midday.ai/default.jpg"
25
29
alt = { alt }
26
- className = " absolute -z-10"
30
+ className = { ` absolute ${ ! src || hasError ? "" : " -z-10"} ` }
27
31
width = { size }
28
32
height = { size }
29
33
/>
You can’t perform that action at this time.
0 commit comments