From 1767b8e4dbad507eb89eca2c6bdc1c35c5f24715 Mon Sep 17 00:00:00 2001 From: RadoslavDimchev Date: Wed, 24 Apr 2024 18:18:57 +0300 Subject: [PATCH] fix(currency-dropdown): remove supported currencies and use symbols constant --- src/components/General/CurrencyDropdown.tsx | 46 ++++----------------- 1 file changed, 7 insertions(+), 39 deletions(-) diff --git a/src/components/General/CurrencyDropdown.tsx b/src/components/General/CurrencyDropdown.tsx index 45dd9ff8..5db8552a 100644 --- a/src/components/General/CurrencyDropdown.tsx +++ b/src/components/General/CurrencyDropdown.tsx @@ -14,20 +14,13 @@ type CurrencyDropdownProps = { const CurrencyDropdown = ({ depositAmount }: CurrencyDropdownProps) => { const [isOpen, setIsOpen] = useState(false) - const [supportedCurrencies, setSupportedCurrencies] = useState([]) const [currentCurrencyAmount, setCurrentCurrencyAmount] = useState(0) const [isCurrencyLoading, setIsCurrencyLoading] = useState(false) - const [isSupportedCurrenciesLoading, setIsSupportedCurrenciesLoading] = - useState(false) const currency = useSelector((state: RootState) => state.currency) const dispatch = useDispatch() const totalPrice = depositAmount * currentCurrencyAmount - useEffect(() => { - fetchSupportedCurrencies() - }, []) - useEffect(() => { fetchCurrencyPrice() }, [currency]) @@ -53,27 +46,6 @@ const CurrencyDropdown = ({ depositAmount }: CurrencyDropdownProps) => { } } - const fetchSupportedCurrencies = async () => { - try { - const response = await fetch( - 'https://api.coingecko.com/api/v3/simple/supported_vs_currencies', - { - headers: { - accept: 'application/json', - 'x-cg-demo-api-key': COIN_GECKO_API_KEY, - }, - }, - ) - - const newSupportedCurrencies = await response.json() - setSupportedCurrencies(newSupportedCurrencies) - } catch (error) { - console.error(error) - } finally { - setIsSupportedCurrenciesLoading(false) - } - } - const changeIsOpenHandler = (isOpen: boolean) => { setIsOpen(isOpen) } @@ -102,17 +74,13 @@ const CurrencyDropdown = ({ depositAmount }: CurrencyDropdownProps) => { height={190} className={'transparent-scrollbar'} > - {isSupportedCurrenciesLoading ? ( - {}} /> - ) : ( - supportedCurrencies.map(currency => ( - changeCurrencyHandler(currency)} - /> - )) - )} + {Object.keys(currencySymbols).map(currency => ( + changeCurrencyHandler(currency)} + /> + ))}