Fix amount string on order details

This commit is contained in:
Reckless_Satoshi 2024-01-15 13:21:10 +00:00
parent 5dcb6f0394
commit 82f1e90bc8
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
3 changed files with 7 additions and 9 deletions

View File

@ -60,7 +60,6 @@ const OrderDetails = ({
const { t } = useTranslation();
const theme = useTheme();
const { federation } = useContext<UseFederationStoreType>(FederationContext);
const { orderUpdatedAt } = useContext<UseGarageStoreType>(GarageContext);
const [coordinator, setCoordinator] = useState<Coordinator | null>(
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 (
<Grid container spacing={0}>

View File

@ -648,7 +648,6 @@ const TradeBox = ({ baseUrl, onStartAgain }: TradeBoxProps): JSX.Element => {
baseContract.prompt = function () {
return (
<SuccessfulPrompt
baseUrl={baseUrl}
order={order}
ratePlatform={ratePlatform}
onClickStartAgain={onStartAgain}
@ -688,7 +687,6 @@ const TradeBox = ({ baseUrl, onStartAgain }: TradeBoxProps): JSX.Element => {
baseContract.prompt = function () {
return (
<SuccessfulPrompt
baseUrl={baseUrl}
order={order}
ratePlatform={ratePlatform}
onClickStartAgain={onStartAgain}

View File

@ -163,6 +163,7 @@ export const FederationContextProvider = ({
useEffect(() => {
if (currentOrderId.id && currentOrderId.shortAlias) {
setCurrentOrder(null);
setBadOrder(undefined);
clearInterval(timer);
fetchCurrentOrder();
}