From 82f1e90bc815ec9f2a954410513ddb7320e73513 Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Mon, 15 Jan 2024 13:21:10 +0000 Subject: [PATCH] Fix amount string on order details --- frontend/src/components/OrderDetails/index.tsx | 13 ++++++------- frontend/src/components/TradeBox/index.tsx | 2 -- frontend/src/contexts/FederationContext.tsx | 1 + 3 files changed, 7 insertions(+), 9 deletions(-) diff --git a/frontend/src/components/OrderDetails/index.tsx b/frontend/src/components/OrderDetails/index.tsx index ade6ae7f5..92ffea6ff 100644 --- a/frontend/src/components/OrderDetails/index.tsx +++ b/frontend/src/components/OrderDetails/index.tsx @@ -60,7 +60,6 @@ const OrderDetails = ({ const { t } = useTranslation(); const theme = useTheme(); const { federation } = useContext(FederationContext); - const { orderUpdatedAt } = useContext(GarageContext); const [coordinator, setCoordinator] = useState( federation.getCoordinator(shortAlias), ); @@ -71,10 +70,10 @@ const OrderDetails = ({ useEffect(() => { setCoordinator(federation.getCoordinator(shortAlias)); setCurrencyCode(currencies[(currentOrder?.currency ?? 1).toString()]); - }, [currentOrder, orderUpdatedAt]); + }, [currentOrder]); const amountString = useMemo(() => { - if (currentOrder === null || currentOrder.amount === null) return; + if (currentOrder === null) return; if (currentOrder.currency === 1000) { return ( @@ -88,14 +87,14 @@ const OrderDetails = ({ } else { return ( amountToString( - currentOrder.amount.toString(), + currentOrder.amount?.toString(), currentOrder.amount > 0 ? false : currentOrder.has_range, currentOrder.min_amount, currentOrder.max_amount, ) + ` ${String(currencyCode)}` ); } - }, [orderUpdatedAt, currencyCode]); + }, [currentOrder, currencyCode]); // Countdown Renderer callback with condition const countdownRenderer = function ({ @@ -208,7 +207,6 @@ const OrderDetails = ({ send = t('You send via {{method}} {{amount}}', { amount: amountString, method: order.payment_method, - currencyCode, }); receive = t('You receive via Lightning {{amount}} Sats (Approx)', { amount: sats, @@ -239,8 +237,9 @@ const OrderDetails = ({ method: order.payment_method, }); } + return { send, receive }; - }, [orderUpdatedAt]); + }, [currentOrder, amountString]); return ( diff --git a/frontend/src/components/TradeBox/index.tsx b/frontend/src/components/TradeBox/index.tsx index 8ff52f2f6..bad53f7a9 100644 --- a/frontend/src/components/TradeBox/index.tsx +++ b/frontend/src/components/TradeBox/index.tsx @@ -648,7 +648,6 @@ const TradeBox = ({ baseUrl, onStartAgain }: TradeBoxProps): JSX.Element => { baseContract.prompt = function () { return ( { baseContract.prompt = function () { return ( { if (currentOrderId.id && currentOrderId.shortAlias) { setCurrentOrder(null); + setBadOrder(undefined); clearInterval(timer); fetchCurrentOrder(); }