Skip to content

Commit e890bc2

Browse files
committed
fix: make entire refund widget clickable and remove fallback values
- Make both MEV and Gas values clickable (entire widget is now clickable) - Remove hardcoded fallback values (380.29/444.24) - Widget now hides if data fetch fails instead of showing stale data - Both values redirect to the same URL (protect.flashbots.net)
1 parent aac7371 commit e890bc2

File tree

1 file changed

+17
-22
lines changed

1 file changed

+17
-22
lines changed

src/components/MevMetrics.tsx

Lines changed: 17 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,8 @@ export default function MevMetrics(): JSX.Element | null {
3636
setData(metrics);
3737
} catch (error) {
3838
console.error('Error fetching MEV metrics:', error);
39-
// Mock data as fallback
40-
setData({
41-
totalMevRefund: 380.29,
42-
totalGasRefund: 444.24,
43-
fetchedAt: new Date().toISOString(),
44-
stale: true
45-
});
39+
// Don't show widget on error
40+
setData(null);
4641
} finally {
4742
setLoading(false);
4843
}
@@ -55,31 +50,31 @@ export default function MevMetrics(): JSX.Element | null {
5550
return `${value.toFixed(2)} ETH`;
5651
};
5752

58-
const handleMevClick = () => {
53+
const handleClick = () => {
5954
const redirectUrl = siteConfig.customFields?.refundMetricsRedirectUrl as string;
6055
window.open(redirectUrl, '_blank', 'noopener,noreferrer');
6156
};
6257

63-
// Hide widget if flag says so
64-
if (!showWidget) {
58+
// Hide widget if flag says so or if no data
59+
if (!showWidget || (!loading && !data)) {
6560
return null;
6661
}
6762

6863
return (
69-
<div className={styles.container}>
64+
<div
65+
className={`${styles.container} ${styles.clickable}`}
66+
onClick={handleClick}
67+
role="button"
68+
tabIndex={0}
69+
onKeyDown={(e) => {
70+
if (e.key === 'Enter' || e.key === ' ') {
71+
handleClick();
72+
}
73+
}}
74+
>
7075
<span className={styles.label}>Refund</span>
7176
<span className={styles.separator}>|</span>
72-
<div
73-
className={`${styles.metric} ${styles.clickable}`}
74-
onClick={handleMevClick}
75-
role="button"
76-
tabIndex={0}
77-
onKeyDown={(e) => {
78-
if (e.key === 'Enter' || e.key === ' ') {
79-
handleMevClick();
80-
}
81-
}}
82-
>
77+
<div className={styles.metric}>
8378
<span className={styles.label}>MEV:</span>
8479
<span className={`${styles.value} ${loading ? styles.loading : ''}`}>
8580
{loading ? '...' : data && formatValue(data.totalMevRefund)}

0 commit comments

Comments
 (0)