diff --git a/frontend/src/components/MakerForm/MakerForm.tsx b/frontend/src/components/MakerForm/MakerForm.tsx index 90171fad..8f60eb3e 100644 --- a/frontend/src/components/MakerForm/MakerForm.tsx +++ b/frontend/src/components/MakerForm/MakerForm.tsx @@ -1,4 +1,4 @@ -import React, { useContext, useMemo, useState } from 'react'; +import React, { useContext, useEffect, useMemo, useState } from 'react'; import { useTranslation } from 'react-i18next'; import { InputAdornment, @@ -63,7 +63,7 @@ const MakerForm = ({ onOrderCreated = () => null, hasRobot = true, }: MakerFormProps): JSX.Element => { - const { fav, setFav, limits, info, maker, setMaker, setPage, baseUrl } = + const { fav, setFav, limits, fetchLimits, info, maker, setMaker, setPage, baseUrl } = useContext(AppContext); const { t } = useTranslation(); @@ -81,6 +81,23 @@ const MakerForm = ({ const minRangeAmountMultiple = 1.6; const amountSafeThresholds = [1.03, 0.98]; + useEffect(() => { + setCurrencyCode(currencyDict[fav.currency == 0 ? 1 : fav.currency]); + if (Object.keys(limits.list).length === 0) { + fetchLimits().then((data) => { + updateAmountLimits(data, fav.currency, maker.premium); + updateCurrentPrice(data, fav.currency, maker.premium); + updateSatoshisLimits(data); + }); + } else { + updateAmountLimits(limits.list, fav.currency, maker.premium); + updateCurrentPrice(limits.list, fav.currency, maker.premium); + updateSatoshisLimits(limits.list); + + fetchLimits(); + } + }, []); + const updateAmountLimits = function (limitList: LimitList, currency: number, premium: number) { const index = currency == 0 ? 1 : currency; let minAmountLimit: number = limitList[index].min_amount * (1 + premium / 100);