Implement responsive order page

This commit is contained in:
Reckless_Satoshi 2022-01-27 14:51:57 -08:00
parent 753e80c589
commit 51e21f7f6b
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
4 changed files with 111 additions and 34 deletions

View File

@ -33,6 +33,7 @@ export default class BottomBar extends Component {
today_avg_nonkyc_btc_premium: 0, today_avg_nonkyc_btc_premium: 0,
today_total_volume: 0, today_total_volume: 0,
lifetime_satoshis_settled: 0, lifetime_satoshis_settled: 0,
robosats_running_commit_hash: '000000000000000',
}; };
this.getInfo(); this.getInfo();
} }
@ -45,14 +46,13 @@ export default class BottomBar extends Component {
this.setState(null) this.setState(null)
fetch('/api/info/') fetch('/api/info/')
.then((response) => response.json()) .then((response) => response.json())
.then((data) => {console.log(data) & .then((data) => this.setState(data));
this.setState(data)
});
} }
handleClickOpenStatsForNerds = () => { handleClickOpenStatsForNerds = () => {
this.setState({openStatsForNerds: true}); this.setState({openStatsForNerds: true});
}; };
handleClickCloseStatsForNerds = () => { handleClickCloseStatsForNerds = () => {
this.setState({openStatsForNerds: false}); this.setState({openStatsForNerds: false});
}; };
@ -79,7 +79,7 @@ export default class BottomBar extends Component {
<ListItemIcon><GitHubIcon/></ListItemIcon> <ListItemIcon><GitHubIcon/></ListItemIcon>
<ListItemText secondary="Currently running commit hash"> <ListItemText secondary="Currently running commit hash">
<a href={"https://github.com/Reckless-Satoshi/robosats/tree/" <a href={"https://github.com/Reckless-Satoshi/robosats/tree/"
+ this.state.robosats_running_commit_hash}>{this.state.robosats_running_commit_hash} + this.state.robosats_running_commit_hash}>{this.state.robosats_running_commit_hash.slice(0, 12)+"..."}
</a> </a>
</ListItemText> </ListItemText>
</ListItem> </ListItem>

View File

@ -111,7 +111,7 @@ export default class Chat extends Component {
</Grid> </Grid>
</Grid> </Grid>
</form> </form>
<FormHelperText>This chat has no memory. If you reload the page messages are lost.</FormHelperText> <FormHelperText>This chat has no memory. If you leave and come back the messages are lost.</FormHelperText>
</Container> </Container>
) )
} }

View File

@ -1,6 +1,9 @@
import React, { Component } from "react"; import React, { Component } from "react";
import { Alert, Paper, CircularProgress, Button , Grid, Typography, List, ListItem, ListItemIcon, ListItemText, ListItemAvatar, Avatar, Divider, Box, LinearProgress, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle} from "@mui/material" import PropTypes from 'prop-types';
import { Tab, Tabs, Alert, Paper, CircularProgress, Button , Grid, Typography, List, ListItem, ListItemIcon, ListItemText, ListItemAvatar, Avatar, Divider, Box, LinearProgress, Dialog, DialogActions, DialogContent, DialogContentText, DialogTitle} from "@mui/material"
import Countdown, { zeroPad, calcTimeDelta } from 'react-countdown'; import Countdown, { zeroPad, calcTimeDelta } from 'react-countdown';
import MediaQuery from 'react-responsive'
import TradeBox from "./TradeBox"; import TradeBox from "./TradeBox";
import getFlags from './getFlags' import getFlags from './getFlags'
@ -33,6 +36,39 @@ function pn(x) {
return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ","); return x.toString().replace(/\B(?=(\d{3})+(?!\d))/g, ",");
} }
function TabPanel(props) {
const { children, value, index, ...other } = props;
return (
<div
role="tabpanel"
hidden={value !== index}
id={`simple-tabpanel-${index}`}
aria-labelledby={`simple-tab-${index}`}
{...other}
>
{value === index && (
<Box sx={{ p: 3 }}>
<Typography>{children}</Typography>
</Box>
)}
</div>
);
}
TabPanel.propTypes = {
children: PropTypes.node,
index: PropTypes.number.isRequired,
value: PropTypes.number.isRequired,
};
function a11yProps(index) {
return {
id: `simple-tab-${index}`,
'aria-controls': `simple-tabpanel-${index}`,
};
}
export default class OrderPage extends Component { export default class OrderPage extends Component {
constructor(props) { constructor(props) {
super(props); super(props);
@ -342,11 +378,13 @@ export default class OrderPage extends Component {
orderBox=()=>{ orderBox=()=>{
return( return(
<Grid container spacing={1}> <Grid container spacing={1} >
<Grid item xs={12} align="center"> <Grid item xs={12} align="center">
<Typography component="h5" variant="h5"> <MediaQuery minWidth={920}>
Order Details <Typography component="h5" variant="h5">
</Typography> Order Details
</Typography>
</MediaQuery>
<Paper elevation={12} style={{ padding: 8,}}> <Paper elevation={12} style={{ padding: 8,}}>
<List dense="true"> <List dense="true">
<ListItem > <ListItem >
@ -497,6 +535,47 @@ export default class OrderPage extends Component {
) )
} }
doubleOrderPageDesktop=()=>{
return(
<Grid container xs={12} align="center" spacing={2} >
<Grid item xs={6} align="left" style={{ width:330}} >
{this.orderBox()}
</Grid>
<Grid item xs={6} align="left">
<TradeBox data={this.state} completeSetState={this.completeSetState} />
</Grid>
</Grid>
)
}
doubleOrderPagePhone=()=>{
const [value, setValue] = React.useState(1);
const handleChange = (event, newValue) => {
setValue(newValue);
};
return(
<Box sx={{ width: '100%' }}>
<Box sx={{ borderBottom: 1, borderColor: 'divider' }}>
<Tabs value={value} onChange={handleChange} aria-label="basic tabs" variant="fullWidth">
<Tab label="Order Details" {...a11yProps(0)} />
<Tab label="Contract Box" {...a11yProps(1)} />
</Tabs>
</Box>
<TabPanel value={value} index={0}>
<Grid container style={{ width:330}}>
{this.orderBox()}
</Grid>
</TabPanel>
<TabPanel value={value} index={1}>
<TradeBox data={this.state} completeSetState={this.completeSetState} />
</TabPanel>
</Box>
);
}
orderDetailsPage (){ orderDetailsPage (){
return( return(
this.state.bad_request ? this.state.bad_request ?
@ -508,16 +587,19 @@ export default class OrderPage extends Component {
</div> </div>
: :
(this.state.is_participant ? (this.state.is_participant ?
<Grid container xs={12} align="center" spacing={2}> <>
<Grid item xs={6} align="left"> {/* Desktop View */}
{this.orderBox()} <MediaQuery minWidth={920}>
</Grid> <this.doubleOrderPageDesktop/>
<Grid item xs={6} align="left"> </MediaQuery>
<TradeBox data={this.state} completeSetState={this.completeSetState} />
</Grid> {/* SmarPhone View */}
</Grid> <MediaQuery maxWidth={919}>
<this.doubleOrderPagePhone/>
</MediaQuery>
</>
: :
<Grid item xs={12} align="center"> <Grid item xs={12} align="center" style={{ width:330}}>
{this.orderBox()} {this.orderBox()}
</Grid>) </Grid>)
) )

View File

@ -3,14 +3,12 @@ import { Paper, Rating, Button, Grid, Typography, TextField, List, ListItem, Lis
import QRCode from "react-qr-code"; import QRCode from "react-qr-code";
import Countdown from 'react-countdown'; import Countdown from 'react-countdown';
import Chat from "./Chat" import Chat from "./Chat"
import MediaQuery from 'react-responsive'
// Icons // Icons
import SmartToyIcon from '@mui/icons-material/SmartToy';
import PercentIcon from '@mui/icons-material/Percent'; import PercentIcon from '@mui/icons-material/Percent';
import BookIcon from '@mui/icons-material/Book'; import BookIcon from '@mui/icons-material/Book';
function getCookie(name) { function getCookie(name) {
let cookieValue = null; let cookieValue = null;
if (document.cookie && document.cookie !== '') { if (document.cookie && document.cookie !== '') {
@ -265,14 +263,6 @@ export default class TradeBox extends Component {
</Typography> </Typography>
</ListItem> </ListItem>
{/* TODO API sends data for a more confortable wait */} {/* TODO API sends data for a more confortable wait */}
<Divider/>
<ListItem>
<ListItemIcon>
<SmartToyIcon/>
</ListItemIcon>
<ListItemText primary={'coming soon'} secondary="Robots looking at the book"/>
</ListItem>
<Divider/> <Divider/>
<ListItem> <ListItem>
<ListItemIcon> <ListItemIcon>
@ -374,9 +364,12 @@ export default class TradeBox extends Component {
label={"Payout Lightning Invoice"} label={"Payout Lightning Invoice"}
required required
inputProps={{ inputProps={{
style: {textAlign:"center"} style: {textAlign:"center"},
maxHeight: 200,
}} }}
multiline multiline
minRows={4}
maxRows={12}
onChange={this.handleInputInvoiceChanged} onChange={this.handleInputInvoiceChanged}
/> />
</Grid> </Grid>
@ -750,9 +743,11 @@ handleRatingChange=(e)=>{
<this.ConfirmDisputeDialog/> <this.ConfirmDisputeDialog/>
<this.ConfirmFiatReceivedDialog/> <this.ConfirmFiatReceivedDialog/>
<Grid item xs={12} align="center"> <Grid item xs={12} align="center">
<Typography component="h5" variant="h5"> <MediaQuery minWidth={920}>
Contract Box <Typography component="h5" variant="h5">
</Typography> Contract Box
</Typography>
</MediaQuery>
<Paper elevation={12} style={{ padding: 8,}}> <Paper elevation={12} style={{ padding: 8,}}>
{/* Maker and taker Bond request */} {/* Maker and taker Bond request */}
{this.props.data.is_maker & this.props.data.status == 0 ? this.showQRInvoice() : ""} {this.props.data.is_maker & this.props.data.status == 0 ? this.showQRInvoice() : ""}