Improve routing within app components

This commit is contained in:
Reckless_Satoshi 2022-01-31 04:53:20 -08:00
parent f03210b69d
commit 24347682c3
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
8 changed files with 35 additions and 30 deletions

View File

@ -81,7 +81,7 @@ class LNNode():
memo=description,
value=num_satoshis,
hash=r_hash,
expiry=int(invoice_expiry*1.15), # actual expiry is padded by 15%
expiry=int(invoice_expiry*1.5), # actual expiry is padded by 50%, if tight, wrong client system clock will say invoice is expired.
cltv_expiry=cltv_expiry_blocks,
)
response = cls.invoicesstub.AddHoldInvoice(request, metadata=[('macaroon', MACAROON.hex())])

View File

@ -21,7 +21,7 @@ def users_cleansing():
for user in queryset:
if not user.profile.total_contracts == 0:
continue
valid, _ = Logics.validate_already_maker_or_taker(user)
valid, _, _ = Logics.validate_already_maker_or_taker(user)
if valid:
deleted_users.append(str(user))
user.delete()

View File

@ -20,12 +20,7 @@ export default class App extends Component {
render() {
return (
<>
<div className='appCenter'>
<HomePage setAppState={this.setAppState}/>
</div>
<div className='bottomBar'>
<BottomBar {...this.state} setAppState={this.setAppState} />
</div>
</>
);
}

View File

@ -1,6 +1,7 @@
import React, { Component } from 'react'
import {Badge, TextField, ListItemAvatar, Avatar,Paper, Grid, IconButton, Typography, Select, MenuItem, List, ListItemText, ListItem, ListItemIcon, ListItemButton, Divider, Dialog, DialogContent} from "@mui/material";
import MediaQuery from 'react-responsive'
import { Link } from 'react-router-dom'
// Icons
import SettingsIcon from '@mui/icons-material/Settings';
@ -209,7 +210,7 @@ export default class BottomBar extends Component {
<Divider/>
{this.state.active_order_id ?
// TODO Link to router and do this.props.history.push
<ListItemButton component="a" href={window.location.origin +'/order/'+this.state.active_order_id}>
<ListItemButton onClick={this.handleClickCloseProfile} to={'/order/'+this.state.active_order_id} component={Link}>
<ListItemIcon>
<Badge badgeContent="" color="primary">
<NumbersIcon color="primary"/>

View File

@ -1,24 +1,43 @@
import React, { Component } from "react";
import { BrowserRouter as Router, Switch, Route, Link, Redirect } from "react-router-dom";
import { BrowserRouter as Router, Switch, Route, Link, Redirect,useHistory } from "react-router-dom";
import UserGenPage from "./UserGenPage";
import MakerPage from "./MakerPage";
import BookPage from "./BookPage";
import OrderPage from "./OrderPage";
import BottomBar from "./BottomBar";
export default class HomePage extends Component {
constructor(props) {
super(props);
this.state = {
nickname: null,
token: null,
}
}
setAppState=(newState)=>{
this.setState(newState)
}
redirectTo(location) {
this.props.history.push(location);
}
render() {
return (
<Router >
<Switch>
<Route exact path='/' render={(props) => <UserGenPage setAppState={this.props.setAppState}/>}/>
<Route path='/make' component={MakerPage}/>
<Route path='/book' component={BookPage}/>
<Route path="/order/:orderId" component={OrderPage}/>
</Switch>
<div className='appCenter'>
<Switch>
<Route exact path='/' render={(props) => <UserGenPage setAppState={this.setAppState}/>}/>
<Route path='/make' component={MakerPage}/>
<Route path='/book' component={BookPage}/>
<Route path="/order/:orderId" component={OrderPage}/>
</Switch>
</div>
<div className='bottomBar'>
<BottomBar redirectTo={this.redirectTo} {...this.state} setAppState={this.setAppState} />
</div>
</Router>
);
}

View File

@ -40,15 +40,10 @@ export default class InfoDialog extends Component {
<Typography component="body2" variant="body2">
<p>It is a BTC/FIAT peer-to-peer exchange over lightning. It simplifies
matchmaking and minimizes the need of trust. RoboSats focuses in privacy and speed.</p>
<Grid align="center"><div style={{maxWidth:'75%', maxHeight:'75%'}}>
<Image
className='newAvatar'
disableError='true'
cover='true'
color='null'
src={window.location.origin +'/static/assets/images/robosats_0.1.0.png'}
<img
width='100%'
src={window.location.origin +'/static/assets/images/robosats_0.1.0_banner.png'}
/>
</div></Grid>
<p>RoboSats is an open source project <a
href='https://github.com/reckless-satoshi/robosats'>(GitHub).</a>
</p>

View File

@ -120,11 +120,6 @@ export default class OrderPage extends Component {
this.getOrderDetails();
}
// Fix to use proper react props
handleClickBackButton=()=>{
window.history.back();
}
// Countdown Renderer callback with condition
countdownRenderer = ({ total, hours, minutes, seconds, completed }) => {
if (completed) {
@ -506,7 +501,7 @@ export default class OrderPage extends Component {
<Button variant='contained' color='primary' onClick={this.handleClickTakeOrderButton}>Take Order</Button>
</Grid>
<Grid item xs={12} align="center">
<Button variant='contained' color='secondary' onClick={this.handleClickBackButton}>Back</Button>
<Button variant='contained' color='secondary' onClick={this.props.history.goBack}>Back</Button>
</Grid>
</Grid>
}
@ -573,7 +568,7 @@ export default class OrderPage extends Component {
<Typography component="subtitle2" variant="subtitle2" color="secondary" >
{this.state.bad_request}<br/>
</Typography>
<Button variant='contained' color='secondary' onClick={this.handleClickBackButton}>Back</Button>
<Button variant='contained' color='secondary' onClick={this.props.history.goBack}>Back</Button>
</div>
:
(this.state.is_participant ?

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 KiB