Small fixes. Click through laoding overlay, take amount calc with no api/info.

This commit is contained in:
Reckless_Satoshi 2023-04-27 09:04:37 -07:00
parent a0627a2028
commit 275a68a7f0
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
5 changed files with 13 additions and 9 deletions

View File

@ -35,9 +35,9 @@ const OrderPage = (): JSX.Element => {
const [tab, setTab] = useState<'order' | 'contract'>('contract'); const [tab, setTab] = useState<'order' | 'contract'>('contract');
useEffect(() => { useEffect(() => {
setCurrentOrder(Number(params.orderId));
if (currentOrder != params.orderId) { if (currentOrder != params.orderId) {
clearOrder(); clearOrder();
setCurrentOrder(Number(params.orderId));
} }
}, [params.orderId]); }, [params.orderId]);

View File

@ -16,7 +16,6 @@ import {
import { Bolt, Add, DeleteSweep, Logout, Download } from '@mui/icons-material'; import { Bolt, Add, DeleteSweep, Logout, Download } from '@mui/icons-material';
import RobotAvatar from '../../components/RobotAvatar'; import RobotAvatar from '../../components/RobotAvatar';
import TokenInput from './TokenInput'; import TokenInput from './TokenInput';
import { Page } from '../NavBar';
import { Slot, Robot } from '../../models'; import { Slot, Robot } from '../../models';
import { AppContext, UseAppStoreType } from '../../contexts/AppContext'; import { AppContext, UseAppStoreType } from '../../contexts/AppContext';
import { genBase62Token } from '../../utils'; import { genBase62Token } from '../../utils';
@ -156,7 +155,6 @@ const RobotProfile = ({
<Button <Button
onClick={() => { onClick={() => {
navigate(`/order/${robot.activeOrderId}`); navigate(`/order/${robot.activeOrderId}`);
setCurrentOrder(robot.activeOrderId);
}} }}
> >
{t('Active order #{{orderID}}', { orderID: robot.activeOrderId })} {t('Active order #{{orderID}}', { orderID: robot.activeOrderId })}
@ -170,7 +168,6 @@ const RobotProfile = ({
<Button <Button
onClick={() => { onClick={() => {
navigate(`/order/${robot.lastOrderId}`); navigate(`/order/${robot.lastOrderId}`);
setCurrentOrder(robot.lastOrderId);
}} }}
> >
{t('Last order #{{orderID}}', { orderID: robot.lastOrderId })} {t('Last order #{{orderID}}', { orderID: robot.lastOrderId })}

View File

@ -15,6 +15,7 @@ import {
IconButton, IconButton,
Tooltip, Tooltip,
LinearProgressProps, LinearProgressProps,
styled,
} from '@mui/material'; } from '@mui/material';
import { import {
DataGrid, DataGrid,
@ -35,6 +36,12 @@ import RobotAvatar from '../RobotAvatar';
import { Fullscreen, FullscreenExit, Refresh } from '@mui/icons-material'; import { Fullscreen, FullscreenExit, Refresh } from '@mui/icons-material';
import { AppContext, UseAppStoreType } from '../../contexts/AppContext'; import { AppContext, UseAppStoreType } from '../../contexts/AppContext';
const ClickThroughDataGrid = styled(DataGrid)({
'& .MuiDataGrid-overlayWrapperInner': {
pointerEvents: 'none',
},
});
interface BookTableProps { interface BookTableProps {
orderList?: PublicOrder[]; orderList?: PublicOrder[];
maxWidth: number; maxWidth: number;
@ -741,7 +748,7 @@ const BookTable = ({
: { width: `${width}em`, height: `${height}em`, overflow: 'auto' } : { width: `${width}em`, height: `${height}em`, overflow: 'auto' }
} }
> >
<DataGrid <ClickThroughDataGrid
localeText={localeText} localeText={localeText}
rowHeight={3.714 * theme.typography.fontSize} rowHeight={3.714 * theme.typography.fontSize}
headerHeight={3.25 * theme.typography.fontSize} headerHeight={3.25 * theme.typography.fontSize}
@ -776,7 +783,7 @@ const BookTable = ({
return ( return (
<Dialog open={fullscreen} fullScreen={true}> <Dialog open={fullscreen} fullScreen={true}>
<Paper style={{ width: '100%', height: '100%', overflow: 'auto' }}> <Paper style={{ width: '100%', height: '100%', overflow: 'auto' }}>
<DataGrid <ClickThroughDataGrid
localeText={localeText} localeText={localeText}
rowHeight={3.714 * theme.typography.fontSize} rowHeight={3.714 * theme.typography.fontSize}
headerHeight={3.25 * theme.typography.fontSize} headerHeight={3.25 * theme.typography.fontSize}

View File

@ -51,7 +51,7 @@ const TakeButton = ({ order, setOrder, baseUrl, hasRobot, info }: TakeButtonProp
const [satoshis, setSatoshis] = useState<string>(''); const [satoshis, setSatoshis] = useState<string>('');
const satoshisNow = () => { const satoshisNow = () => {
const tradeFee = info.taker_fee; const tradeFee = info?.taker_fee ?? 0;
const defaultRoutingBudget = 0.001; const defaultRoutingBudget = 0.001;
const btc_now = order.satoshis_now / 100000000; const btc_now = order.satoshis_now / 100000000;
const rate = order.amount ? order.amount / btc_now : order.max_amount / btc_now; const rate = order.amount ? order.amount / btc_now : order.max_amount / btc_now;
@ -67,7 +67,7 @@ const TakeButton = ({ order, setOrder, baseUrl, hasRobot, info }: TakeButtonProp
useEffect(() => { useEffect(() => {
setSatoshis(satoshisNow()); setSatoshis(satoshisNow());
}, [order.satoshis_now, takeAmount]); }, [order.satoshis_now, takeAmount, info]);
const currencyCode: string = order.currency == 1000 ? 'Sats' : currencies[`${order.currency}`]; const currencyCode: string = order.currency == 1000 ? 'Sats' : currencies[`${order.currency}`];

View File

@ -149,7 +149,7 @@ const OrderDetails = ({
let sats: string = ''; let sats: string = '';
const isBuyer = (order.type == 0 && order.is_maker) || (order.type == 1 && !order.is_maker); const isBuyer = (order.type == 0 && order.is_maker) || (order.type == 1 && !order.is_maker);
const tradeFee = order.is_maker ? info.maker_fee : info.taker_fee; const tradeFee = order.is_maker ? info?.maker_fee ?? 0 : info?.taker_fee ?? 0;
const defaultRoutingBudget = 0.001; const defaultRoutingBudget = 0.001;
const btc_now = order.satoshis_now / 100000000; const btc_now = order.satoshis_now / 100000000;
const rate = order.amount ? order.amount / btc_now : order.max_amount / btc_now; const rate = order.amount ? order.amount / btc_now : order.max_amount / btc_now;