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