Skip to content

Commit

Permalink
[NO CHANGELOG][Add Funds Widget] Show estimated time (#2249)
Browse files Browse the repository at this point in the history
  • Loading branch information
mimi-imtbl authored Sep 30, 2024
1 parent 53b2812 commit 445c19c
Showing 1 changed file with 16 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
Icon,
MenuItem, MenuItemSize, Sticker,
} from '@biom3/react';
import { ReactElement, useMemo } from 'react';
Expand Down Expand Up @@ -37,6 +38,15 @@ export function RouteOption<RC extends ReactElement | undefined = undefined>({

const formattedUsdBalance = useMemo(() => (usdBalance ? Number(usdBalance).toFixed(2) : undefined), [usdBalance]);

const estimatedDurationFormatted = useMemo(() => {
const seconds = estimate.estimatedRouteDuration / 1000;
if (seconds >= 60) {
const minutes = Math.round(seconds / 60);
return minutes === 1 ? '1 min' : `${minutes} mins`;
}
return `${seconds.toFixed(0)}s`;
}, [estimate.estimatedRouteDuration]);

const handleClick = () => {
onClick?.(route);
};
Expand Down Expand Up @@ -94,6 +104,12 @@ export function RouteOption<RC extends ReactElement | undefined = undefined>({
<MenuItem.Badge badgeContent="Fastest" variant="emphasis" />
)}

<MenuItem.Caption>
<Icon icon="Countdown" sx={{ w: 'base.icon.size.250' }} />
{' '}
{ estimatedDurationFormatted }
</MenuItem.Caption>

</MenuItem>
);
}

0 comments on commit 445c19c

Please sign in to comment.