Skip to content

Commit

Permalink
fix: prices
Browse files Browse the repository at this point in the history
  • Loading branch information
danielsimao committed Jul 22, 2024
1 parent 3a55488 commit 0cf2b9a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,9 +13,9 @@ type InheritAttrs = Omit<FlexProps, (keyof Props & AriaAttrs) | 'children'>;

type HeaderProps = Props & AriaAttrs & InheritAttrs;

const ButtonGroup = ({ onSelectionChange, selectionMode, ...props }: HeaderProps): JSX.Element => {
const ButtonGroup = ({ onSelectionChange, selectionMode, selectedKeys, ...props }: HeaderProps): JSX.Element => {
const domRef = useDOMRef<HTMLDivElement>(null);
let state = useListState({ ...props, onSelectionChange, selectionMode });
let state = useListState({ ...props, onSelectionChange, selectionMode, selectedKeys });
let { gridProps } = useTagGroup(props, state, domRef);

return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ type HeaderProps = Props;
const TokenButtonGroup = ({ isSelected, currency, onSelectionChange }: HeaderProps): JSX.Element => {
const { locale } = useLocale();
const format = useCurrencyFormatter();
const { getPrice } = usePrices({ baseUrl: import.meta.env.VITE_MARKET_DATA_API });
const { getPrice, data: pricesData } = usePrices({ baseUrl: import.meta.env.VITE_MARKET_DATA_API });

const [key, setKey] = useState<string>();

Expand All @@ -35,14 +35,14 @@ const TokenButtonGroup = ({ isSelected, currency, onSelectionChange }: HeaderPro
return usdItems.map((usd) =>
CurrencyAmount.fromRawAmount(
currency,
new Big(100000000).mul(usd).div(getPrice(currency.symbol)).round(0, 0).toNumber()
pricesData ? new Big(100000000).mul(usd).div(getPrice(currency.symbol)).round(0, 0).toNumber() : 0
)
);
}

return usdItems.map((usd) => CurrencyAmount.fromBaseAmount(currency, usd));
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currency]);
}, [currency, pricesData]);

const handleSelectionChange = (key: any) => {
const [selectedKey] = [...key];
Expand Down

0 comments on commit 0cf2b9a

Please sign in to comment.