mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-31 10:31:35 +00:00
Fix makerform UI current price
This commit is contained in:
parent
82c8f2280b
commit
64f3243c53
@ -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 { useTranslation } from 'react-i18next';
|
||||||
import {
|
import {
|
||||||
InputAdornment,
|
InputAdornment,
|
||||||
@ -63,7 +63,7 @@ const MakerForm = ({
|
|||||||
onOrderCreated = () => null,
|
onOrderCreated = () => null,
|
||||||
hasRobot = true,
|
hasRobot = true,
|
||||||
}: MakerFormProps): JSX.Element => {
|
}: 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);
|
useContext<AppContextProps>(AppContext);
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
@ -81,6 +81,23 @@ const MakerForm = ({
|
|||||||
const minRangeAmountMultiple = 1.6;
|
const minRangeAmountMultiple = 1.6;
|
||||||
const amountSafeThresholds = [1.03, 0.98];
|
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 updateAmountLimits = function (limitList: LimitList, currency: number, premium: number) {
|
||||||
const index = currency == 0 ? 1 : currency;
|
const index = currency == 0 ? 1 : currency;
|
||||||
let minAmountLimit: number = limitList[index].min_amount * (1 + premium / 100);
|
let minAmountLimit: number = limitList[index].min_amount * (1 + premium / 100);
|
||||||
|
Loading…
Reference in New Issue
Block a user