mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-05 22:10:10 +00:00
Fix usenavigate PRO (#571)
* Simplify and optimize nodeapp * Add pro frontend * Fix PRO errors
This commit is contained in:
parent
71820cee91
commit
1e39f32eb5
@ -85,6 +85,7 @@ const BookPage = (): JSX.Element => {
|
|||||||
onClose={() => {
|
onClose={() => {
|
||||||
setOpenNoRobot(false);
|
setOpenNoRobot(false);
|
||||||
}}
|
}}
|
||||||
|
onClickGenerateRobot={() => navigate('/robot')}
|
||||||
/>
|
/>
|
||||||
{openMaker ? (
|
{openMaker ? (
|
||||||
<Dialog
|
<Dialog
|
||||||
@ -98,6 +99,7 @@ const BookPage = (): JSX.Element => {
|
|||||||
onOrderCreated={(id) => {
|
onOrderCreated={(id) => {
|
||||||
navigate('/order/' + id);
|
navigate('/order/' + id);
|
||||||
}}
|
}}
|
||||||
|
onClickGenerateRobot={() => navigate('/robot')}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
|
@ -69,6 +69,7 @@ const MakerPage = (): JSX.Element => {
|
|||||||
onClose={() => {
|
onClose={() => {
|
||||||
setOpenNoRobot(false);
|
setOpenNoRobot(false);
|
||||||
}}
|
}}
|
||||||
|
onClickGenerateRobot={() => navigate('/robot')}
|
||||||
/>
|
/>
|
||||||
<Grid item>
|
<Grid item>
|
||||||
<Collapse in={matches.length > 0 && showMatches}>
|
<Collapse in={matches.length > 0 && showMatches}>
|
||||||
@ -114,6 +115,7 @@ const MakerPage = (): JSX.Element => {
|
|||||||
setShowMatches(false);
|
setShowMatches(false);
|
||||||
}}
|
}}
|
||||||
submitButtonLabel={matches.length > 0 && !showMatches ? 'Submit' : 'Create order'}
|
submitButtonLabel={matches.length > 0 && !showMatches ? 'Submit' : 'Create order'}
|
||||||
|
onClickGenerateRobot={() => navigate('/robot')}
|
||||||
/>
|
/>
|
||||||
</Paper>
|
</Paper>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
@ -109,6 +109,7 @@ const OrderPage = (): JSX.Element => {
|
|||||||
baseUrl={baseUrl}
|
baseUrl={baseUrl}
|
||||||
info={info}
|
info={info}
|
||||||
hasRobot={robot.avatarLoaded}
|
hasRobot={robot.avatarLoaded}
|
||||||
|
onClickGenerateRobot={() => navigate('/robot')}
|
||||||
/>
|
/>
|
||||||
</Paper>
|
</Paper>
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -164,6 +165,7 @@ const OrderPage = (): JSX.Element => {
|
|||||||
baseUrl={baseUrl}
|
baseUrl={baseUrl}
|
||||||
info={info}
|
info={info}
|
||||||
hasRobot={robot.avatarLoaded}
|
hasRobot={robot.avatarLoaded}
|
||||||
|
onClickGenerateRobot={() => navigate('/robot')}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
<div style={{ display: tab == 'contract' ? '' : 'none' }}>
|
<div style={{ display: tab == 'contract' ? '' : 'none' }}>
|
||||||
@ -196,6 +198,7 @@ const OrderPage = (): JSX.Element => {
|
|||||||
baseUrl={baseUrl}
|
baseUrl={baseUrl}
|
||||||
info={info}
|
info={info}
|
||||||
hasRobot={robot.avatarLoaded}
|
hasRobot={robot.avatarLoaded}
|
||||||
|
onClickGenerateRobot={() => navigate('/robot')}
|
||||||
/>
|
/>
|
||||||
</Paper>
|
</Paper>
|
||||||
)
|
)
|
||||||
|
@ -344,54 +344,57 @@ const BookTable = ({
|
|||||||
};
|
};
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
const premiumObj = useCallback((width: number) => {
|
const premiumObj = useCallback(
|
||||||
// coloring premium texts based on 4 params:
|
(width: number) => {
|
||||||
// Hardcoded: a sell order at 0% is an outstanding premium
|
// coloring premium texts based on 4 params:
|
||||||
// Hardcoded: a buy order at 10% is an outstanding premium
|
// Hardcoded: a sell order at 0% is an outstanding premium
|
||||||
const sellStandardPremium = 10;
|
// Hardcoded: a buy order at 10% is an outstanding premium
|
||||||
const buyOutstandingPremium = 10;
|
const sellStandardPremium = 10;
|
||||||
return {
|
const buyOutstandingPremium = 10;
|
||||||
field: 'premium',
|
return {
|
||||||
headerName: t('Premium'),
|
field: 'premium',
|
||||||
type: 'number',
|
headerName: t('Premium'),
|
||||||
width: width * fontSize,
|
type: 'number',
|
||||||
renderCell: (params: any) => {
|
width: width * fontSize,
|
||||||
const currencyCode = currencyDict[params.row.currency.toString()];
|
renderCell: (params: any) => {
|
||||||
let fontColor = `rgb(0,0,0)`;
|
const currencyCode = currencyDict[params.row.currency.toString()];
|
||||||
if (params.row.type === 0) {
|
let fontColor = `rgb(0,0,0)`;
|
||||||
var premiumPoint = params.row.premium / buyOutstandingPremium;
|
if (params.row.type === 0) {
|
||||||
premiumPoint = premiumPoint < 0 ? 0 : premiumPoint > 1 ? 1 : premiumPoint;
|
var premiumPoint = params.row.premium / buyOutstandingPremium;
|
||||||
fontColor = premiumColor(
|
premiumPoint = premiumPoint < 0 ? 0 : premiumPoint > 1 ? 1 : premiumPoint;
|
||||||
theme.palette.text.primary,
|
fontColor = premiumColor(
|
||||||
theme.palette.secondary.dark,
|
theme.palette.text.primary,
|
||||||
premiumPoint,
|
theme.palette.secondary.dark,
|
||||||
|
premiumPoint,
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
var premiumPoint = (sellStandardPremium - params.row.premium) / sellStandardPremium;
|
||||||
|
premiumPoint = premiumPoint < 0 ? 0 : premiumPoint > 1 ? 1 : premiumPoint;
|
||||||
|
fontColor = premiumColor(
|
||||||
|
theme.palette.text.primary,
|
||||||
|
theme.palette.primary.dark,
|
||||||
|
premiumPoint,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
const fontWeight = 400 + Math.round(premiumPoint * 5) * 100;
|
||||||
|
return (
|
||||||
|
<Tooltip
|
||||||
|
placement='left'
|
||||||
|
enterTouchDelay={0}
|
||||||
|
title={pn(params.row.price) + ' ' + currencyCode + '/BTC'}
|
||||||
|
>
|
||||||
|
<div style={{ cursor: 'pointer' }}>
|
||||||
|
<Typography variant='inherit' color={fontColor} sx={{ fontWeight }}>
|
||||||
|
{parseFloat(parseFloat(params.row.premium).toFixed(4)) + '%'}
|
||||||
|
</Typography>
|
||||||
|
</div>
|
||||||
|
</Tooltip>
|
||||||
);
|
);
|
||||||
} else {
|
},
|
||||||
var premiumPoint = (sellStandardPremium - params.row.premium) / sellStandardPremium;
|
};
|
||||||
premiumPoint = premiumPoint < 0 ? 0 : premiumPoint > 1 ? 1 : premiumPoint;
|
},
|
||||||
fontColor = premiumColor(
|
[theme],
|
||||||
theme.palette.text.primary,
|
);
|
||||||
theme.palette.primary.dark,
|
|
||||||
premiumPoint,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
const fontWeight = 400 + Math.round(premiumPoint * 5) * 100;
|
|
||||||
return (
|
|
||||||
<Tooltip
|
|
||||||
placement='left'
|
|
||||||
enterTouchDelay={0}
|
|
||||||
title={pn(params.row.price) + ' ' + currencyCode + '/BTC'}
|
|
||||||
>
|
|
||||||
<div style={{ cursor: 'pointer' }}>
|
|
||||||
<Typography variant='inherit' color={fontColor} sx={{ fontWeight }}>
|
|
||||||
{parseFloat(parseFloat(params.row.premium).toFixed(4)) + '%'}
|
|
||||||
</Typography>
|
|
||||||
</div>
|
|
||||||
</Tooltip>
|
|
||||||
);
|
|
||||||
},
|
|
||||||
};
|
|
||||||
}, []);
|
|
||||||
|
|
||||||
const timerObj = useCallback((width: number) => {
|
const timerObj = useCallback((width: number) => {
|
||||||
return {
|
return {
|
||||||
|
@ -1,12 +1,12 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
import { NoRobotDialog, StoreTokenDialog } from '.';
|
import { NoRobotDialog, StoreTokenDialog } from '.';
|
||||||
import { Page } from '../../basic/NavBar';
|
|
||||||
|
|
||||||
interface ConfirmationDialogProps {
|
interface ConfirmationDialogProps {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
onClickDone: () => void;
|
onClickDone: () => void;
|
||||||
hasRobot: boolean;
|
hasRobot: boolean;
|
||||||
|
onClickGenerateRobot?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const ConfirmationDialog = ({
|
const ConfirmationDialog = ({
|
||||||
@ -14,6 +14,7 @@ const ConfirmationDialog = ({
|
|||||||
onClose,
|
onClose,
|
||||||
hasRobot,
|
hasRobot,
|
||||||
onClickDone,
|
onClickDone,
|
||||||
|
onClickGenerateRobot = () => null,
|
||||||
}: ConfirmationDialogProps): JSX.Element => {
|
}: ConfirmationDialogProps): JSX.Element => {
|
||||||
return hasRobot ? (
|
return hasRobot ? (
|
||||||
<StoreTokenDialog
|
<StoreTokenDialog
|
||||||
@ -23,7 +24,7 @@ const ConfirmationDialog = ({
|
|||||||
onClickDone={onClickDone}
|
onClickDone={onClickDone}
|
||||||
/>
|
/>
|
||||||
) : (
|
) : (
|
||||||
<NoRobotDialog open={open} onClose={onClose} />
|
<NoRobotDialog open={open} onClose={onClose} onClickGenerateRobot={onClickGenerateRobot} />
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import React, { useContext } from 'react';
|
import React from 'react';
|
||||||
import { useTranslation } from 'react-i18next';
|
import { useTranslation } from 'react-i18next';
|
||||||
import {
|
import {
|
||||||
Dialog,
|
Dialog,
|
||||||
@ -8,21 +8,19 @@ import {
|
|||||||
DialogContentText,
|
DialogContentText,
|
||||||
Button,
|
Button,
|
||||||
} from '@mui/material';
|
} from '@mui/material';
|
||||||
import { useNavigate } from 'react-router-dom';
|
|
||||||
|
|
||||||
interface Props {
|
interface Props {
|
||||||
open: boolean;
|
open: boolean;
|
||||||
onClose: () => void;
|
onClose: () => void;
|
||||||
|
onClickGenerateRobot?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const NoRobotDialog = ({ open, onClose }: Props): JSX.Element => {
|
const NoRobotDialog = ({
|
||||||
|
open,
|
||||||
|
onClose,
|
||||||
|
onClickGenerateRobot = () => null,
|
||||||
|
}: Props): JSX.Element => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const navigate = useNavigate();
|
|
||||||
|
|
||||||
const handleClickGenerate = function () {
|
|
||||||
onClose();
|
|
||||||
navigate('/robot');
|
|
||||||
};
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Dialog open={open} onClose={onClose}>
|
<Dialog open={open} onClose={onClose}>
|
||||||
@ -35,7 +33,14 @@ const NoRobotDialog = ({ open, onClose }: Props): JSX.Element => {
|
|||||||
</DialogContent>
|
</DialogContent>
|
||||||
|
|
||||||
<DialogActions>
|
<DialogActions>
|
||||||
<Button onClick={handleClickGenerate}>{t('Generate Robot')}</Button>
|
<Button
|
||||||
|
onClick={() => {
|
||||||
|
onClickGenerateRobot();
|
||||||
|
onClose();
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
{t('Generate Robot')}
|
||||||
|
</Button>
|
||||||
</DialogActions>
|
</DialogActions>
|
||||||
</Dialog>
|
</Dialog>
|
||||||
);
|
);
|
||||||
|
@ -50,6 +50,7 @@ interface MakerFormProps {
|
|||||||
onReset?: () => void;
|
onReset?: () => void;
|
||||||
submitButtonLabel?: string;
|
submitButtonLabel?: string;
|
||||||
onOrderCreated?: (id: number) => void;
|
onOrderCreated?: (id: number) => void;
|
||||||
|
onClickGenerateRobot?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const MakerForm = ({
|
const MakerForm = ({
|
||||||
@ -60,12 +61,14 @@ const MakerForm = ({
|
|||||||
onReset = () => {},
|
onReset = () => {},
|
||||||
submitButtonLabel = 'Create Order',
|
submitButtonLabel = 'Create Order',
|
||||||
onOrderCreated = () => null,
|
onOrderCreated = () => null,
|
||||||
|
onClickGenerateRobot = () => null,
|
||||||
}: MakerFormProps): JSX.Element => {
|
}: MakerFormProps): JSX.Element => {
|
||||||
const { fav, setFav, limits, fetchLimits, info, maker, setMaker, baseUrl, robot } =
|
const { fav, setFav, limits, fetchLimits, info, maker, setMaker, baseUrl, robot } =
|
||||||
useContext<UseAppStoreType>(AppContext);
|
useContext<UseAppStoreType>(AppContext);
|
||||||
|
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
|
||||||
const [badRequest, setBadRequest] = useState<string | null>(null);
|
const [badRequest, setBadRequest] = useState<string | null>(null);
|
||||||
const [amountLimits, setAmountLimits] = useState<number[]>([1, 1000]);
|
const [amountLimits, setAmountLimits] = useState<number[]>([1, 1000]);
|
||||||
const [satoshisLimits, setSatoshisLimits] = useState<number[]>([20000, 4000000]);
|
const [satoshisLimits, setSatoshisLimits] = useState<number[]>([20000, 4000000]);
|
||||||
@ -469,6 +472,7 @@ const MakerForm = ({
|
|||||||
}}
|
}}
|
||||||
onClickDone={handleCreateOrder}
|
onClickDone={handleCreateOrder}
|
||||||
hasRobot={robot.avatarLoaded}
|
hasRobot={robot.avatarLoaded}
|
||||||
|
onClickGenerateRobot={onClickGenerateRobot}
|
||||||
/>
|
/>
|
||||||
<Collapse in={limits.list.length == 0}>
|
<Collapse in={limits.list.length == 0}>
|
||||||
<div style={{ display: limits.list.length == 0 ? '' : 'none' }}>
|
<div style={{ display: limits.list.length == 0 ? '' : 'none' }}>
|
||||||
|
@ -32,6 +32,7 @@ interface TakeButtonProps {
|
|||||||
setOrder: (state: Order) => void;
|
setOrder: (state: Order) => void;
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
info: Info;
|
info: Info;
|
||||||
|
onClickGenerateRobot?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
interface OpenDialogsProps {
|
interface OpenDialogsProps {
|
||||||
@ -40,7 +41,13 @@ interface OpenDialogsProps {
|
|||||||
}
|
}
|
||||||
const closeAll = { inactiveMaker: false, confirmation: false };
|
const closeAll = { inactiveMaker: false, confirmation: false };
|
||||||
|
|
||||||
const TakeButton = ({ order, setOrder, baseUrl, info }: TakeButtonProps): JSX.Element => {
|
const TakeButton = ({
|
||||||
|
order,
|
||||||
|
setOrder,
|
||||||
|
baseUrl,
|
||||||
|
info,
|
||||||
|
onClickGenerateRobot = () => null,
|
||||||
|
}: TakeButtonProps): JSX.Element => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
const { robot } = useContext<UseAppStoreType>(AppContext);
|
const { robot } = useContext<UseAppStoreType>(AppContext);
|
||||||
@ -336,6 +343,7 @@ const TakeButton = ({ order, setOrder, baseUrl, info }: TakeButtonProps): JSX.El
|
|||||||
setOpen(closeAll);
|
setOpen(closeAll);
|
||||||
}}
|
}}
|
||||||
hasRobot={robot.avatarLoaded}
|
hasRobot={robot.avatarLoaded}
|
||||||
|
onClickGenerateRobot={onClickGenerateRobot}
|
||||||
/>
|
/>
|
||||||
<InactiveMakerDialog />
|
<InactiveMakerDialog />
|
||||||
</Box>
|
</Box>
|
||||||
|
@ -44,6 +44,7 @@ interface OrderDetailsProps {
|
|||||||
info: Info;
|
info: Info;
|
||||||
baseUrl: string;
|
baseUrl: string;
|
||||||
hasRobot: boolean;
|
hasRobot: boolean;
|
||||||
|
onClickGenerateRobot?: () => void;
|
||||||
}
|
}
|
||||||
|
|
||||||
const OrderDetails = ({
|
const OrderDetails = ({
|
||||||
@ -52,6 +53,7 @@ const OrderDetails = ({
|
|||||||
setOrder,
|
setOrder,
|
||||||
baseUrl,
|
baseUrl,
|
||||||
hasRobot,
|
hasRobot,
|
||||||
|
onClickGenerateRobot = () => null,
|
||||||
}: OrderDetailsProps): JSX.Element => {
|
}: OrderDetailsProps): JSX.Element => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
@ -444,6 +446,7 @@ const OrderDetails = ({
|
|||||||
baseUrl={baseUrl}
|
baseUrl={baseUrl}
|
||||||
hasRobot={hasRobot}
|
hasRobot={hasRobot}
|
||||||
info={info}
|
info={info}
|
||||||
|
onClickGenerateRobot={onClickGenerateRobot}
|
||||||
/>
|
/>
|
||||||
</Grid>
|
</Grid>
|
||||||
) : (
|
) : (
|
||||||
|
@ -42,9 +42,10 @@ http {
|
|||||||
index basic.html;
|
index basic.html;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /pro/ {
|
location /pro {
|
||||||
root /usr/src/robosats;
|
root /usr/src/robosats;
|
||||||
try_files $uri $uri/ /pro.html;
|
try_files $uri $uri/ /pro.html;
|
||||||
|
index pro.html;
|
||||||
}
|
}
|
||||||
|
|
||||||
location /static/ {
|
location /static/ {
|
||||||
|
Loading…
Reference in New Issue
Block a user