Fix makerform UI current price

This commit is contained in:
Reckless_Satoshi 2023-03-14 13:08:22 -07:00
parent 82c8f2280b
commit 64f3243c53
No known key found for this signature in database
GPG Key ID: 9C4585B561315571

View File

@ -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<AppContextProps>(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);