Add Tradebox Dialogs

This commit is contained in:
Reckless_Satoshi 2022-11-02 07:31:25 -07:00
parent 059c52b370
commit 040ecaeca7
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
5 changed files with 1940 additions and 2315 deletions

View File

@ -92,7 +92,7 @@ const NavBar = ({
return (
<Paper
elevation={6}
sx={{ height: `${height}em`, width: `${width * 0.9}em`, position: 'fixed', bottom: 0 }}
sx={{ height: `${height}em`, width: `100%`, position: 'fixed', bottom: 0, borderRadius: 0 }}
>
<Tabs
TabIndicatorProps={{ sx: { height: '0.3em', position: 'absolute', top: 0 } }}
@ -176,472 +176,3 @@ const NavBar = ({
};
export default NavBar;
// constructor(props) {
// super(props);
// this.state = {
// profileShown: false,
// openStatsForNerds: false,
// openCommunity: false,
// openExchangeSummary: false,
// openClaimRewards: false,
// openProfile: false,
// showRewards: false,
// rewardInvoice: null,
// badInvoice: false,
// showRewardsSpinner: false,
// withdrawn: false,
// };
// }
// handleClickOpenStatsForNerds = () => {
// this.setState({ openStatsForNerds: true });
// };
// handleClickCloseStatsForNerds = () => {
// this.setState({ openStatsForNerds: false });
// };
// handleClickOpenCommunity = () => {
// this.setState({ openCommunity: true });
// };
// handleClickCloseCommunity = () => {
// this.setState({ openCommunity: false });
// };
// handleClickOpenProfile = () => {
// this.setState({ openProfile: true, profileShown: true });
// };
// handleClickCloseProfile = () => {
// this.setState({ openProfile: false });
// };
// handleClickOpenExchangeSummary = () => {
// this.setState({ openExchangeSummary: true });
// };
// handleClickCloseExchangeSummary = () => {
// this.setState({ openExchangeSummary: false });
// };
// handleSubmitInvoiceClicked = (e, rewardInvoice) => {
// this.setState({ badInvoice: false, showRewardsSpinner: true });
// apiClient
// .post('/api/reward/', {
// invoice: rewardInvoice,
// })
// .then((data) => {
// this.setState({ badInvoice: data.bad_invoice, showRewardsSpinner: false });
// this.props.setInfo({
// ...this.props.info,
// badInvoice: data.bad_invoice,
// openClaimRewards: !data.successful_withdrawal,
// withdrawn: !!data.successful_withdrawal,
// showRewardsSpinner: false,
// });
// this.props.setRobot({
// ...this.props.robot,
// earnedRewards: data.successful_withdrawal ? 0 : this.props.robot.earnedRewards,
// });
// });
// e.preventDefault();
// };
// handleSetStealthInvoice = (wantsStealth) => {
// apiClient
// .put('/api/stealth/', { wantsStealth })
// .then((data) =>
// this.props.setRobot({ ...this.props.robot, stealthInvoices: data?.wantsStealth }),
// );
// };
// showProfileButton = () => {
// return (
// this.props.robot.avatarLoaded &&
// (this.props.robot.token
// ? systemClient.getCookie('robot_token') === this.props.robot.token
// : true) &&
// systemClient.getCookie('sessionid')
// );
// };
// bottomBarDesktop = () => {
// const { t } = this.props;
// const hasRewards = this.props.robot.earnedRewards > 0;
// const hasOrder = !!(
// (this.props.robot.activeOrderId > 0) &
// !this.state.profileShown &
// this.props.robot.avatarLoaded
// );
// const fontSize = this.props.theme.typography.fontSize;
// const fontSizeFactor = fontSize / 14; // default fontSize is 14
// const typographyProps = {
// primaryTypographyProps: { fontSize },
// secondaryTypographyProps: { fontSize: (fontSize * 12) / 14 },
// };
// return (
// <Paper
// elevation={6}
// style={{ height: '2.5em', width: `${(this.props.windowSize.width / 16) * 14}em` }}
// >
// <Grid container>
// <Grid item xs={1.9}>
// <div style={{ display: this.showProfileButton() ? '' : 'none' }}>
// <ListItemButton onClick={this.handleClickOpenProfile}>
// <Tooltip
// open={(hasRewards || hasOrder) && this.showProfileButton()}
// title={
// (hasRewards ? t('You can claim satoshis!') + ' ' : '') +
// (hasOrder ? t('You have an active order') : '')
// }
// >
// <ListItemAvatar sx={{ width: 30 * fontSizeFactor, height: 30 * fontSizeFactor }}>
// <RobotAvatar
// style={{ marginTop: -13 }}
// statusColor={
// (this.props.robot.activeOrderId > 0) & !this.state.profileShown
// ? 'primary'
// : undefined
// }
// nickname={this.props.robot.nickname}
// onLoad={() =>
// this.props.setRobot({ ...this.props.robot, avatarLoaded: true })
// }
// />
// </ListItemAvatar>
// </Tooltip>
// <ListItemText primary={this.props.robot.nickname} />
// </ListItemButton>
// </div>
// </Grid>
// <Grid item xs={1.9}>
// <ListItem className='bottomItem'>
// <ListItemIcon size='small'>
// <IconButton
// disabled={!this.showProfileButton()}
// color='primary'
// to={`/book/`}
// component={LinkRouter}
// >
// <InventoryIcon />
// </IconButton>
// </ListItemIcon>
// <ListItemText
// {...typographyProps}
// primary={this.props.info.num_public_buy_orders}
// secondary={t('Public Buy Orders')}
// />
// </ListItem>
// </Grid>
// <Grid item xs={1.9}>
// <ListItem className='bottomItem'>
// <ListItemIcon size='small'>
// <IconButton
// disabled={!this.showProfileButton()}
// color='primary'
// to={`/book/`}
// component={LinkRouter}
// >
// <SellIcon />
// </IconButton>
// </ListItemIcon>
// <ListItemText
// {...typographyProps}
// primary={this.props.info.num_public_sell_orders}
// secondary={t('Public Sell Orders')}
// />
// </ListItem>
// </Grid>
// <Grid item xs={1.9}>
// <ListItem className='bottomItem'>
// <ListItemIcon size='small'>
// <IconButton
// disabled={!this.showProfileButton()}
// color='primary'
// to={`/`}
// component={LinkRouter}
// >
// <SmartToyIcon />
// </IconButton>
// </ListItemIcon>
// <ListItemText
// {...typographyProps}
// primary={this.props.info.active_robots_today}
// secondary={t('Today Active Robots')}
// />
// </ListItem>
// </Grid>
// <Grid item xs={1.9}>
// <ListItem className='bottomItem'>
// <ListItemIcon size='small'>
// <IconButton color='primary' onClick={this.handleClickOpenExchangeSummary}>
// <PriceChangeIcon />
// </IconButton>
// </ListItemIcon>
// <ListItemText
// {...typographyProps}
// primary={this.props.info.last_day_nonkyc_btc_premium + '%'}
// secondary={t('24h Avg Premium')}
// />
// </ListItem>
// </Grid>
// <Grid item xs={1.5}>
// <ListItem className='bottomItem'>
// <ListItemIcon size='small'>
// <IconButton color='primary' onClick={this.handleClickOpenExchangeSummary}>
// <PercentIcon />
// </IconButton>
// </ListItemIcon>
// <ListItemText
// {...typographyProps}
// primary={(this.props.info.maker_fee + this.props.info.taker_fee) * 100}
// secondary={t('Trade Fee')}
// />
// </ListItem>
// </Grid>
// <Grid container item xs={1}>
// <Grid item xs={6}>
// {this.LangSelect()}
// </Grid>
// <Grid item xs={3}>
// <Tooltip enterTouchDelay={250} title={t('Show community and support links')}>
// <IconButton
// color='primary'
// aria-label='Community'
// onClick={this.handleClickOpenCommunity}
// >
// <PeopleIcon />
// </IconButton>
// </Tooltip>
// </Grid>
// <Grid item xs={3}>
// <Tooltip enterTouchDelay={250} title={t('Show stats for nerds')}>
// <IconButton
// color='primary'
// aria-label='Stats for Nerds'
// onClick={this.handleClickOpenStatsForNerds}
// >
// <BarChartIcon />
// </IconButton>
// </Tooltip>
// </Grid>
// </Grid>
// </Grid>
// </Paper>
// );
// };
// bottomBarPhone = () => {
// const { t } = this.props;
// const hasRewards = this.props.robot.earnedRewards > 0;
// const hasOrder = !!(
// (this.props.info.active_order_id > 0) &
// !this.state.profileShown &
// this.props.robot.avatarLoaded
// );
// return (
// <Paper
// elevation={6}
// style={{ height: '2.85em', width: `${(this.props.windowSize.width / 16) * 14}em` }}
// >
// <Grid container>
// <Grid item xs={1.6}>
// <div style={{ display: this.showProfileButton() ? '' : 'none' }}>
// <Tooltip
// open={(hasRewards || hasOrder) && this.showProfileButton()}
// title={
// (hasRewards ? t('You can claim satoshis!') + ' ' : '') +
// (hasOrder ? t('You have an active order') : '')
// }
// >
// <IconButton
// onClick={this.handleClickOpenProfile}
// sx={{ margin: 0, bottom: 17, right: 8 }}
// >
// <RobotAvatar
// style={{ width: 55, height: 55 }}
// avatarClass='phoneFlippedSmallAvatar'
// statusColor={
// (this.props.activeOrderId > 0) & !this.state.profileShown
// ? 'primary'
// : undefined
// }
// nickname={this.props.robot.nickname}
// onLoad={() => this.props.setRobot({ ...this.props.robot, avatarLoaded: true })}
// />
// </IconButton>
// </Tooltip>
// </div>
// </Grid>
// <Grid item xs={1.6} align='center'>
// <Tooltip enterTouchDelay={300} title={t('Number of public BUY orders')}>
// <IconButton
// disabled={!this.showProfileButton()}
// color='primary'
// to={`/book/`}
// component={LinkRouter}
// >
// <Badge badgeContent={this.props.info.num_public_buy_orders} color='action'>
// <InventoryIcon />
// </Badge>
// </IconButton>
// </Tooltip>
// </Grid>
// <Grid item xs={1.6} align='center'>
// <Tooltip enterTouchDelay={300} title={t('Number of public SELL orders')}>
// <IconButton
// disabled={!this.showProfileButton()}
// color='primary'
// to={`/book/`}
// component={LinkRouter}
// >
// <Badge badgeContent={this.props.info.num_public_sell_orders} color='action'>
// <SellIcon />
// </Badge>
// </IconButton>
// </Tooltip>
// </Grid>
// <Grid item xs={1.6} align='center'>
// <Tooltip enterTouchDelay={300} title={t('Today active robots')}>
// <IconButton
// disabled={!this.showProfileButton()}
// color='primary'
// to={`/`}
// component={LinkRouter}
// >
// <Badge badgeContent={this.props.info.active_robots_today} color='action'>
// <SmartToyIcon />
// </Badge>
// </IconButton>
// </Tooltip>
// </Grid>
// <Grid item xs={1.8} align='center'>
// <Tooltip enterTouchDelay={300} title={t('24h non-KYC bitcoin premium')}>
// <IconButton color='primary' onClick={this.handleClickOpenExchangeSummary}>
// <Badge
// badgeContent={this.props.info.last_day_nonkyc_btc_premium + '%'}
// color='action'
// >
// <PriceChangeIcon />
// </Badge>
// </IconButton>
// </Tooltip>
// </Grid>
// <Grid container item xs={3.8}>
// <Grid item xs={6}>
// {this.LangSelect()}
// </Grid>
// <Grid item xs={3}>
// <Tooltip enterTouchDelay={250} title={t('Show community and support links')}>
// <IconButton
// color='primary'
// aria-label='Community'
// onClick={this.handleClickOpenCommunity}
// >
// <PeopleIcon />
// </IconButton>
// </Tooltip>
// </Grid>
// <Grid item xs={3}>
// <Tooltip enterTouchDelay={250} title={t('Show stats for nerds')}>
// <IconButton
// color='primary'
// aria-label='Stats for Nerds'
// onClick={() => this.props.fetchInfo()}
// onClick={this.handleClickOpenStatsForNerds}
// >
// <BarChartIcon />
// </IconButton>
// </Tooltip>
// </Grid>
// </Grid>
// </Grid>
// </Paper>
// );
// };
// render() {
// return (
// <div>
// <UpdateClientDialog
// open={this.state.openUpdateClient}
// coordinatorVersion={this.props.info.coordinatorVersion}
// clientVersion={this.props.info.clientVersion}
// handleClickClose={() =>
// this.props.setInfo({ ...this.props.info, openUpdateClient: false })
// }
// />
// <ExchangeSummaryDialog
// open={this.state.openExchangeSummary}
// handleClickCloseExchangeSummary={this.handleClickCloseExchangeSummary}
// numPublicBuyOrders={this.props.info.num_public_buy_orders}
// numPublicSellOrders={this.props.info.num_public_sell_orders}
// bookLiquidity={this.props.info.book_liquidity}
// activeRobotsToday={this.props.info.active_robots_today}
// lastDayNonkycBtcPremium={this.props.info.last_day_nonkyc_btc_premium}
// makerFee={this.props.info.maker_fee}
// takerFee={this.props.info.taker_fee}
// swapFeeRate={this.props.info.current_swap_fee_rate}
// />
// <ProfileDialog
// open={this.state.openProfile}
// handleClickCloseProfile={this.handleClickCloseProfile}
// nickname={this.props.robot.nickname}
// activeOrderId={this.props.robot.activeOrderId}
// lastOrderId={this.props.robot.lastOrderId}
// referralCode={this.props.robot.referralCode}
// tgEnabled={this.props.robot.tgEnabled}
// tgBotName={this.props.robot.tgBotName}
// tgToken={this.props.robot.tgToken}
// handleSubmitInvoiceClicked={this.handleSubmitInvoiceClicked}
// showRewardsSpinner={this.state.showRewardsSpinner}
// withdrawn={this.props.info.withdrawn}
// badInvoice={this.props.info.badInvoice}
// earnedRewards={this.props.robot.earnedRewards}
// updateRobot={(newParam) => this.props.setRobot({ ...robot, ...newParam })}
// stealthInvoices={this.props.robot.stealthInvoices}
// handleSetStealthInvoice={this.handleSetStealthInvoice}
// />
// <StatsDialog
// open={this.state.openStatsForNerds}
// handleClickCloseStatsForNerds={this.handleClickCloseStatsForNerds}
// coordinatorVersion={this.props.info.coordinatorVersion}
// clientVersion={this.props.info.clientVersion}
// lndVersion={this.props.info.lnd_version}
// network={this.props.info.network}
// nodeAlias={this.props.info.node_alias}
// nodeId={this.props.info.node_id}
// alternativeName={this.props.info.alternative_name}
// alternativeSite={this.props.info.alternative_site}
// commitHash={this.props.info.robosats_running_commit_hash}
// lastDayVolume={this.props.info.last_day_volume}
// lifetimeVolume={this.props.info.lifetime_volume}
// />
// <MediaQuery minWidth={1200}>{this.bottomBarDesktop()}</MediaQuery>
// <MediaQuery maxWidth={1199}>{this.bottomBarPhone()}</MediaQuery>
// </div>
// );
// }
// }
// export default NavBar;

View File

@ -0,0 +1,51 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import {
Dialog,
DialogTitle,
DialogActions,
DialogContent,
DialogContentText,
Button,
} from '@mui/material';
interface ConfirmDisputeDialogProps {
open: boolean;
onClose: () => void;
onAgreeClick: () => void;
}
export const ConfirmDisputeDialog = ({
open,
onClose,
onAgreeClick,
}: ConfirmDisputeDialogProps): JSX.Element => {
const { t } = useTranslation();
return (
<Dialog open={open} onClose={onClose}>
<DialogTitle>{t('Do you want to open a dispute?')}</DialogTitle>
<DialogContent>
<DialogContentText>
{t(
'The RoboSats staff will examine the statements and evidence provided. You need to build a complete case, as the staff cannot read the chat. It is best to provide a burner contact method with your statement. The satoshis in the trade escrow will be sent to the dispute winner, while the dispute loser will lose the bond.',
)}
</DialogContentText>
<br />
<DialogContentText>
{t(
'Make sure to EXPORT the chat log. The staff might request your exported chat log JSON in order to solve discrepancies. It is your responsibility to store it.',
)}
</DialogContentText>
</DialogContent>
<DialogActions>
<Button onClick={onClose} autoFocus>
{t('Disagree')}
</Button>
<Button onClick={onAgreeClick}>{t('Agree and open dispute')}</Button>
</DialogActions>
</Dialog>
);
};
export default ConfirmDisputeDialog;

View File

@ -0,0 +1,60 @@
import React from 'react';
import { useTranslation } from 'react-i18next';
import {
Dialog,
DialogTitle,
DialogActions,
DialogContent,
DialogContentText,
Button,
} from '@mui/material';
import { Order } from '../../../models';
import currencyDict from '../../../../static/assets/currencies.json';
import { pn } from '../../../utils';
import { LoadingButton } from '@mui/lab';
interface ConfirmFiatReceivedDialogProps {
open: boolean;
loadingButton: boolean;
order: Order;
onClose: () => void;
onConfirmClick: () => void;
}
export const ConfirmFiatReceivedDialog = ({
open,
loadingButton,
onClose,
order,
onConfirmClick,
}: ConfirmFiatReceivedDialogProps): JSX.Element => {
const { t } = useTranslation();
const currencyCode = currencyDict[order.currency.toString()];
const amount = pn(parseFloat(parseFloat(order.amount).toFixed(order.currency == 1000 ? 8 : 4)));
return (
<Dialog open={open} onClose={onClose}>
<DialogTitle>
{t('Confirm you received {{amount}} {{currencyCode}}?', { currencyCode, amount })}
</DialogTitle>
<DialogContent>
<DialogContentText id='alert-dialog-description'>
{t(
'Confirming that you received the fiat will finalize the trade. The satoshis in the escrow will be released to the buyer. Only confirm after the {{amount}} {{currencyCode}} have arrived to your account. In addition, if you have received the payment and do not confirm it, you risk losing your bond.',
{ currencyCode, amount },
)}
</DialogContentText>
</DialogContent>
<DialogActions>
<Button onClick={onClose} autoFocus>
{t('Go back')}
</Button>
<LoadingButton loading={loadingButton} onClick={onConfirmClick}>
{t('Confirm')}
</LoadingButton>
</DialogActions>
</Dialog>
);
};
export default ConfirmFiatReceivedDialog;

View File

@ -0,0 +1,2 @@
export { ConfirmDisputeDialog } from './ConfirmDispute';
export { ConfirmFiatReceivedDialog } from './ConfirmFiatReceived';

File diff suppressed because it is too large Load Diff