mirror of
https://github.com/RoboSats/robosats.git
synced 2025-07-19 17:23:19 +00:00
Fix amount string on order details
This commit is contained in:
@ -60,7 +60,6 @@ const OrderDetails = ({
|
|||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { federation } = useContext<UseFederationStoreType>(FederationContext);
|
const { federation } = useContext<UseFederationStoreType>(FederationContext);
|
||||||
const { orderUpdatedAt } = useContext<UseGarageStoreType>(GarageContext);
|
|
||||||
const [coordinator, setCoordinator] = useState<Coordinator | null>(
|
const [coordinator, setCoordinator] = useState<Coordinator | null>(
|
||||||
federation.getCoordinator(shortAlias),
|
federation.getCoordinator(shortAlias),
|
||||||
);
|
);
|
||||||
@ -71,10 +70,10 @@ const OrderDetails = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
setCoordinator(federation.getCoordinator(shortAlias));
|
setCoordinator(federation.getCoordinator(shortAlias));
|
||||||
setCurrencyCode(currencies[(currentOrder?.currency ?? 1).toString()]);
|
setCurrencyCode(currencies[(currentOrder?.currency ?? 1).toString()]);
|
||||||
}, [currentOrder, orderUpdatedAt]);
|
}, [currentOrder]);
|
||||||
|
|
||||||
const amountString = useMemo(() => {
|
const amountString = useMemo(() => {
|
||||||
if (currentOrder === null || currentOrder.amount === null) return;
|
if (currentOrder === null) return;
|
||||||
|
|
||||||
if (currentOrder.currency === 1000) {
|
if (currentOrder.currency === 1000) {
|
||||||
return (
|
return (
|
||||||
@ -88,14 +87,14 @@ const OrderDetails = ({
|
|||||||
} else {
|
} else {
|
||||||
return (
|
return (
|
||||||
amountToString(
|
amountToString(
|
||||||
currentOrder.amount.toString(),
|
currentOrder.amount?.toString(),
|
||||||
currentOrder.amount > 0 ? false : currentOrder.has_range,
|
currentOrder.amount > 0 ? false : currentOrder.has_range,
|
||||||
currentOrder.min_amount,
|
currentOrder.min_amount,
|
||||||
currentOrder.max_amount,
|
currentOrder.max_amount,
|
||||||
) + ` ${String(currencyCode)}`
|
) + ` ${String(currencyCode)}`
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}, [orderUpdatedAt, currencyCode]);
|
}, [currentOrder, currencyCode]);
|
||||||
|
|
||||||
// Countdown Renderer callback with condition
|
// Countdown Renderer callback with condition
|
||||||
const countdownRenderer = function ({
|
const countdownRenderer = function ({
|
||||||
@ -208,7 +207,6 @@ const OrderDetails = ({
|
|||||||
send = t('You send via {{method}} {{amount}}', {
|
send = t('You send via {{method}} {{amount}}', {
|
||||||
amount: amountString,
|
amount: amountString,
|
||||||
method: order.payment_method,
|
method: order.payment_method,
|
||||||
currencyCode,
|
|
||||||
});
|
});
|
||||||
receive = t('You receive via Lightning {{amount}} Sats (Approx)', {
|
receive = t('You receive via Lightning {{amount}} Sats (Approx)', {
|
||||||
amount: sats,
|
amount: sats,
|
||||||
@ -239,8 +237,9 @@ const OrderDetails = ({
|
|||||||
method: order.payment_method,
|
method: order.payment_method,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
return { send, receive };
|
return { send, receive };
|
||||||
}, [orderUpdatedAt]);
|
}, [currentOrder, amountString]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Grid container spacing={0}>
|
<Grid container spacing={0}>
|
||||||
|
@ -648,7 +648,6 @@ const TradeBox = ({ baseUrl, onStartAgain }: TradeBoxProps): JSX.Element => {
|
|||||||
baseContract.prompt = function () {
|
baseContract.prompt = function () {
|
||||||
return (
|
return (
|
||||||
<SuccessfulPrompt
|
<SuccessfulPrompt
|
||||||
baseUrl={baseUrl}
|
|
||||||
order={order}
|
order={order}
|
||||||
ratePlatform={ratePlatform}
|
ratePlatform={ratePlatform}
|
||||||
onClickStartAgain={onStartAgain}
|
onClickStartAgain={onStartAgain}
|
||||||
@ -688,7 +687,6 @@ const TradeBox = ({ baseUrl, onStartAgain }: TradeBoxProps): JSX.Element => {
|
|||||||
baseContract.prompt = function () {
|
baseContract.prompt = function () {
|
||||||
return (
|
return (
|
||||||
<SuccessfulPrompt
|
<SuccessfulPrompt
|
||||||
baseUrl={baseUrl}
|
|
||||||
order={order}
|
order={order}
|
||||||
ratePlatform={ratePlatform}
|
ratePlatform={ratePlatform}
|
||||||
onClickStartAgain={onStartAgain}
|
onClickStartAgain={onStartAgain}
|
||||||
|
@ -163,6 +163,7 @@ export const FederationContextProvider = ({
|
|||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentOrderId.id && currentOrderId.shortAlias) {
|
if (currentOrderId.id && currentOrderId.shortAlias) {
|
||||||
setCurrentOrder(null);
|
setCurrentOrder(null);
|
||||||
|
setBadOrder(undefined);
|
||||||
clearInterval(timer);
|
clearInterval(timer);
|
||||||
fetchCurrentOrder();
|
fetchCurrentOrder();
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user