Skip to content

Commit e71e2a8

Browse files
committed
Fix bank logos
1 parent 872b4a1 commit e71e2a8

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

apps/dashboard/src/components/bank-logo.tsx

+7-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
1-
import { Avatar, AvatarImage } from "@midday/ui/avatar";
1+
import { Avatar } from "@midday/ui/avatar";
22
import Image from "next/image";
3+
import { useState } from "react";
34

45
type Props = {
56
src: string | null;
@@ -8,22 +9,25 @@ type Props = {
89
};
910

1011
export function BankLogo({ src, alt, size = 34 }: Props) {
12+
const [hasError, setHasError] = useState(false);
13+
1114
return (
1215
<Avatar style={{ width: size, height: size }}>
13-
{src && (
16+
{src && !hasError && (
1417
<Image
1518
src={src}
1619
alt={alt}
1720
className="text-transparent"
1821
width={size}
1922
height={size}
2023
quality={100}
24+
onError={() => setHasError(true)}
2125
/>
2226
)}
2327
<Image
2428
src="https://cdn-engine.midday.ai/default.jpg"
2529
alt={alt}
26-
className="absolute -z-10"
30+
className={`absolute ${!src || hasError ? "" : "-z-10"}`}
2731
width={size}
2832
height={size}
2933
/>

0 commit comments

Comments
 (0)