mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-31 10:31:35 +00:00
Store robot token in cookies. Add renew order after success for makers.
This commit is contained in:
parent
4abfe91587
commit
2b44d32b01
12
api/views.py
12
api/views.py
@ -384,15 +384,17 @@ class OrderView(viewsets.ViewSet):
|
|||||||
# Add invoice amount once again if invoice was expired.
|
# Add invoice amount once again if invoice was expired.
|
||||||
data["invoice_amount"] = Logics.payout_amount(order,request.user)[1]["invoice_amount"]
|
data["invoice_amount"] = Logics.payout_amount(order,request.user)[1]["invoice_amount"]
|
||||||
|
|
||||||
# 10) If status is 'Expired', add expiry reason.
|
# 10) If status is 'Expired', "Sending", "Finished" or "failed routing", add info for renewal:
|
||||||
elif (order.status == Order.Status.EXP):
|
elif order.status in [Order.Status.EXP, Order.Status.SUC, Order.Status.PAY, Order.Status.FAI]:
|
||||||
data["expiry_reason"] = order.expiry_reason
|
|
||||||
data["expiry_message"] = Order.ExpiryReasons(order.expiry_reason).label
|
|
||||||
# other pieces of info useful to renew an identical order
|
|
||||||
data["public_duration"] = order.public_duration
|
data["public_duration"] = order.public_duration
|
||||||
data["bond_size"] = order.bond_size
|
data["bond_size"] = order.bond_size
|
||||||
data["bondless_taker"] = order.bondless_taker
|
data["bondless_taker"] = order.bondless_taker
|
||||||
|
|
||||||
|
# If status is 'Expired' add expiry reason
|
||||||
|
if order.status == Order.Status.EXP:
|
||||||
|
data["expiry_reason"] = order.expiry_reason
|
||||||
|
data["expiry_message"] = Order.ExpiryReasons(order.expiry_reason).label
|
||||||
|
|
||||||
return Response(data, status.HTTP_200_OK)
|
return Response(data, status.HTTP_200_OK)
|
||||||
|
|
||||||
def take_update_confirm_dispute_cancel(self, request, format=None):
|
def take_update_confirm_dispute_cancel(self, request, format=None):
|
||||||
|
@ -26,7 +26,7 @@ class BookPage extends Component {
|
|||||||
pageSize: 6,
|
pageSize: 6,
|
||||||
};
|
};
|
||||||
|
|
||||||
if(this.props.orders.length == 0){
|
if(this.props.bookOrders.length == 0){
|
||||||
this.getOrderDetails(2, 0)
|
this.getOrderDetails(2, 0)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -85,8 +85,8 @@ class BookPage extends Component {
|
|||||||
<div style={{ height: 422, width: '100%' }}>
|
<div style={{ height: 422, width: '100%' }}>
|
||||||
<DataGrid
|
<DataGrid
|
||||||
rows={
|
rows={
|
||||||
this.props.orders.filter(order => order.type == this.props.type || this.props.type == 2)
|
this.props.bookOrders.filter(order => order.type == this.props.bookType || this.props.bookType == 2)
|
||||||
.filter(order => order.currency == this.props.currency || this.props.currency == 0)
|
.filter(order => order.currency == this.props.bookCurrency || this.props.bookCurrency == 0)
|
||||||
.map((order) =>
|
.map((order) =>
|
||||||
({id: order.id,
|
({id: order.id,
|
||||||
avatar: window.location.origin +'/static/assets/avatars/' + order.maker_nick + '.png',
|
avatar: window.location.origin +'/static/assets/avatars/' + order.maker_nick + '.png',
|
||||||
@ -103,7 +103,7 @@ class BookPage extends Component {
|
|||||||
premium: order.premium,
|
premium: order.premium,
|
||||||
})
|
})
|
||||||
)}
|
)}
|
||||||
loading={this.props.loading}
|
loading={this.props.bookLoading}
|
||||||
columns={[
|
columns={[
|
||||||
// { field: 'id', headerName: 'ID', width: 40 },
|
// { field: 'id', headerName: 'ID', width: 40 },
|
||||||
{ field: 'robot', headerName: t("Robot"), width: 240,
|
{ field: 'robot', headerName: t("Robot"), width: 240,
|
||||||
@ -166,7 +166,7 @@ class BookPage extends Component {
|
|||||||
</Stack>
|
</Stack>
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
pageSize={this.props.loading ? 0 : this.state.pageSize}
|
pageSize={this.props.bookLoading ? 0 : this.state.pageSize}
|
||||||
rowsPerPageOptions={[6,20,50]}
|
rowsPerPageOptions={[6,20,50]}
|
||||||
onPageSizeChange={(newPageSize) => this.setState({pageSize:newPageSize})}
|
onPageSizeChange={(newPageSize) => this.setState({pageSize:newPageSize})}
|
||||||
onRowClick={(params) => this.handleRowClick(params.row.id)} // Whole row is clickable, but the mouse only looks clickly in some places.
|
onRowClick={(params) => this.handleRowClick(params.row.id)} // Whole row is clickable, but the mouse only looks clickly in some places.
|
||||||
@ -180,10 +180,10 @@ class BookPage extends Component {
|
|||||||
return (
|
return (
|
||||||
<div style={{ height: 422, width: '100%' }}>
|
<div style={{ height: 422, width: '100%' }}>
|
||||||
<DataGrid
|
<DataGrid
|
||||||
loading={this.props.loading}
|
loading={this.props.bookLoading}
|
||||||
rows={
|
rows={
|
||||||
this.props.orders.filter(order => order.type == this.props.type || this.props.type == 2)
|
this.props.bookOrders.filter(order => order.type == this.props.bookType || this.props.bookType == 2)
|
||||||
.filter(order => order.currency == this.props.currency || this.props.currency == 0)
|
.filter(order => order.currency == this.props.bookCurrency || this.props.bookCurrency == 0)
|
||||||
.map((order) =>
|
.map((order) =>
|
||||||
({id: order.id,
|
({id: order.id,
|
||||||
avatar: window.location.origin +'/static/assets/avatars/' + order.maker_nick + '.png',
|
avatar: window.location.origin +'/static/assets/avatars/' + order.maker_nick + '.png',
|
||||||
@ -267,7 +267,7 @@ class BookPage extends Component {
|
|||||||
</Stack>
|
</Stack>
|
||||||
)
|
)
|
||||||
}}
|
}}
|
||||||
pageSize={this.props.loading ? 0 : this.state.pageSize}
|
pageSize={this.props.bookLoading ? 0 : this.state.pageSize}
|
||||||
rowsPerPageOptions={[6,20,50]}
|
rowsPerPageOptions={[6,20,50]}
|
||||||
onPageSizeChange={(newPageSize) => this.setState({pageSize:newPageSize})}
|
onPageSizeChange={(newPageSize) => this.setState({pageSize:newPageSize})}
|
||||||
onRowClick={(params) => this.handleRowClick(params.row.id)} // Whole row is clickable, but the mouse only looks clickly in some places.
|
onRowClick={(params) => this.handleRowClick(params.row.id)} // Whole row is clickable, but the mouse only looks clickly in some places.
|
||||||
@ -308,10 +308,10 @@ class BookPage extends Component {
|
|||||||
<Grid item xs={12} align="center">
|
<Grid item xs={12} align="center">
|
||||||
<Grid item xs={12} align="center">
|
<Grid item xs={12} align="center">
|
||||||
<Typography component="h5" variant="h5">
|
<Typography component="h5" variant="h5">
|
||||||
{this.props.type == 0 ?
|
{this.props.bookType == 0 ?
|
||||||
t("No orders found to sell BTC for {{currencyCode}}",{currencyCode:this.props.currencyCode})
|
t("No orders found to sell BTC for {{currencyCode}}",{currencyCode:this.props.bookCurrencyCode})
|
||||||
:
|
:
|
||||||
t("No orders found to buy BTC for {{currencyCode}}",{currencyCode:this.props.currencyCode})
|
t("No orders found to buy BTC for {{currencyCode}}",{currencyCode:this.props.bookCurrencyCode})
|
||||||
}
|
}
|
||||||
</Typography>
|
</Typography>
|
||||||
</Grid>
|
</Grid>
|
||||||
@ -382,7 +382,7 @@ class BookPage extends Component {
|
|||||||
<FormControl align="center">
|
<FormControl align="center">
|
||||||
<FormHelperText align="center">
|
<FormHelperText align="center">
|
||||||
<div style={{textAlign:"center", position:"relative", left:"-5px"}}>
|
<div style={{textAlign:"center", position:"relative", left:"-5px"}}>
|
||||||
{this.props.type == 0 ? t("and receive") : (this.props.type == 1 ? t("and pay with") : t("and use") )}
|
{this.props.bookType == 0 ? t("and receive") : (this.props.bookType == 1 ? t("and pay with") : t("and use") )}
|
||||||
</div>
|
</div>
|
||||||
</FormHelperText>
|
</FormHelperText>
|
||||||
<Select
|
<Select
|
||||||
@ -390,7 +390,7 @@ class BookPage extends Component {
|
|||||||
sx={{width:120}}
|
sx={{width:120}}
|
||||||
label={t("Select Payment Currency")}
|
label={t("Select Payment Currency")}
|
||||||
required="true"
|
required="true"
|
||||||
value={this.props.currency}
|
value={this.props.bookCurrency}
|
||||||
inputProps={{
|
inputProps={{
|
||||||
style: {textAlign:"center"}
|
style: {textAlign:"center"}
|
||||||
}}
|
}}
|
||||||
@ -403,14 +403,14 @@ class BookPage extends Component {
|
|||||||
</Select>
|
</Select>
|
||||||
</FormControl>
|
</FormControl>
|
||||||
</Grid>
|
</Grid>
|
||||||
{ this.props.notFound ? "" :
|
{ this.props.bookNotFound ? "" :
|
||||||
<Grid item xs={12} align="center">
|
<Grid item xs={12} align="center">
|
||||||
<Typography component="h5" variant="h5">
|
<Typography component="h5" variant="h5">
|
||||||
{this.props.type == 0 ?
|
{this.props.bookType == 0 ?
|
||||||
t("You are SELLING BTC for {{currencyCode}}",{currencyCode:this.props.currencyCode})
|
t("You are SELLING BTC for {{currencyCode}}",{currencyCode:this.props.bookCurrencyCode})
|
||||||
:
|
:
|
||||||
(this.props.type == 1 ?
|
(this.props.bookType == 1 ?
|
||||||
t("You are BUYING BTC for {{currencyCode}}",{currencyCode:this.props.currencyCode})
|
t("You are BUYING BTC for {{currencyCode}}",{currencyCode:this.props.bookCurrencyCode})
|
||||||
:
|
:
|
||||||
t("You are looking at all")
|
t("You are looking at all")
|
||||||
)
|
)
|
||||||
@ -419,7 +419,7 @@ class BookPage extends Component {
|
|||||||
</Grid>
|
</Grid>
|
||||||
}
|
}
|
||||||
|
|
||||||
{ this.props.notFound ?
|
{ this.props.bookNotFound ?
|
||||||
<this.NoOrdersFound/>
|
<this.NoOrdersFound/>
|
||||||
:
|
:
|
||||||
<Grid item xs={12} align="center">
|
<Grid item xs={12} align="center">
|
||||||
|
@ -326,18 +326,18 @@ class BottomBar extends Component {
|
|||||||
<PasswordIcon/>
|
<PasswordIcon/>
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
<ListItemText secondary={t("Your token (will not remain here)")}>
|
<ListItemText secondary={t("Your token (will not remain here)")}>
|
||||||
{this.props.token ?
|
{getCookie("robot_token") ?
|
||||||
<TextField
|
<TextField
|
||||||
disabled
|
disabled
|
||||||
label={t("Back it up!")}
|
label={t("Back it up!")}
|
||||||
value={this.props.token }
|
value={getCookie("robot_token") }
|
||||||
variant='filled'
|
variant='filled'
|
||||||
size='small'
|
size='small'
|
||||||
InputProps={{
|
InputProps={{
|
||||||
endAdornment:
|
endAdornment:
|
||||||
<Tooltip disableHoverListener enterTouchDelay="0" title={t("Copied!")}>
|
<Tooltip disableHoverListener enterTouchDelay="0" title={t("Copied!")}>
|
||||||
<IconButton onClick= {()=>navigator.clipboard.writeText(this.props.token)}>
|
<IconButton onClick= {()=> (navigator.clipboard.writeText(getCookie("robot_token")) & this.props.setAppState({copiedToken:true}))}>
|
||||||
<ContentCopy />
|
<ContentCopy color={this.props.copiedToken ? "inherit" : "primary"}/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>,
|
</Tooltip>,
|
||||||
}}
|
}}
|
||||||
|
@ -13,6 +13,7 @@ export default class HomePage extends Component {
|
|||||||
this.state = {
|
this.state = {
|
||||||
nickname: null,
|
nickname: null,
|
||||||
token: null,
|
token: null,
|
||||||
|
copiedToken: false,
|
||||||
avatarLoaded: false,
|
avatarLoaded: false,
|
||||||
buyChecked: false,
|
buyChecked: false,
|
||||||
sellChecked: false,
|
sellChecked: false,
|
||||||
@ -40,7 +41,7 @@ export default class HomePage extends Component {
|
|||||||
<Route exact path='/' render={(props) => <UserGenPage {...props} {...this.state} setAppState={this.setAppState}/>}/>
|
<Route exact path='/' render={(props) => <UserGenPage {...props} {...this.state} setAppState={this.setAppState}/>}/>
|
||||||
<Route path='/ref/:refCode' render={(props) => <UserGenPage {...props} {...this.state} setAppState={this.setAppState}/>}/>
|
<Route path='/ref/:refCode' render={(props) => <UserGenPage {...props} {...this.state} setAppState={this.setAppState}/>}/>
|
||||||
<Route path='/make' component={MakerPage}/>
|
<Route path='/make' component={MakerPage}/>
|
||||||
<Route path='/book' render={(props) => <BookPage {...props} buyChecked={this.state.buyChecked} sellChecked={this.state.sellChecked} orders={this.state.bookOrders} loading={this.state.bookLoading} notFound={this.state.bookNotFound} type={this.state.bookType} currencyCode={this.state.bookCurrencyCode} currency={this.state.bookCurrency} setAppState={this.setAppState} />}/>
|
<Route path='/book' render={(props) => <BookPage {...props} {...this.state} setAppState={this.setAppState} />}/>
|
||||||
<Route path="/order/:orderId" component={OrderPage}/>
|
<Route path="/order/:orderId" component={OrderPage}/>
|
||||||
</Switch>
|
</Switch>
|
||||||
</div>
|
</div>
|
||||||
|
@ -276,7 +276,7 @@ class MakerPage extends Component {
|
|||||||
/>
|
/>
|
||||||
<FormControlLabel
|
<FormControlLabel
|
||||||
value="1"
|
value="1"
|
||||||
control={<Radio icon={<SellSatsIcon sx={{width:"30px",height:"30px"}} color="text.secondary"/>} checkedIcon={<SellSatsCheckedIcon sx={{width:"30px",height:"30px"}} color="secondary"/>}/>}
|
control={<Radio color="secondary" icon={<SellSatsIcon sx={{width:"30px",height:"30px"}} color="text.secondary"/>} checkedIcon={<SellSatsCheckedIcon sx={{width:"30px",height:"30px"}} color="secondary"/>}/>}
|
||||||
label={this.state.type == 1 ? <Typography color="secondary"><b>{t("Sell")}</b></Typography>: <Typography color="text.secondary">{t("Sell")}</Typography>}
|
label={this.state.type == 1 ? <Typography color="secondary"><b>{t("Sell")}</b></Typography>: <Typography color="text.secondary">{t("Sell")}</Typography>}
|
||||||
labelPlacement="end"
|
labelPlacement="end"
|
||||||
/>
|
/>
|
||||||
|
@ -446,7 +446,7 @@ class TradeBox extends Component {
|
|||||||
<ListItemIcon>
|
<ListItemIcon>
|
||||||
<PercentIcon/>
|
<PercentIcon/>
|
||||||
</ListItemIcon>
|
</ListItemIcon>
|
||||||
<ListItemText primary={t("Premium rank") +" "+Number(this.props.data.premium_percentile*100).toPrecision(2)+"%"}
|
<ListItemText primary={t("Premium rank") +" "+parseInt(this.props.data.premium_percentile*100)+"%"}
|
||||||
secondary={t("Among public {{currencyCode}} orders (higher is cheaper)",{ currencyCode: this.props.data.currencyCode })}/>
|
secondary={t("Among public {{currencyCode}} orders (higher is cheaper)",{ currencyCode: this.props.data.currencyCode })}/>
|
||||||
</ListItem>
|
</ListItem>
|
||||||
<Divider/>
|
<Divider/>
|
||||||
@ -984,6 +984,8 @@ handleRatingRobosatsChange=(e)=>{
|
|||||||
|
|
||||||
showRateSelect(){
|
showRateSelect(){
|
||||||
const { t } = this.props;
|
const { t } = this.props;
|
||||||
|
var show_renew = this.props.data.is_maker;
|
||||||
|
|
||||||
return(
|
return(
|
||||||
<Grid container spacing={1}>
|
<Grid container spacing={1}>
|
||||||
{/* Make confirmation sound for Chat Open. */}
|
{/* Make confirmation sound for Chat Open. */}
|
||||||
@ -1028,6 +1030,17 @@ handleRatingRobosatsChange=(e)=>{
|
|||||||
<Grid item xs={12} align="center">
|
<Grid item xs={12} align="center">
|
||||||
<Button color='primary' onClick={() => {this.props.push('/')}}>{t("Start Again")}</Button>
|
<Button color='primary' onClick={() => {this.props.push('/')}}>{t("Start Again")}</Button>
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|
||||||
|
{show_renew ?
|
||||||
|
<Grid item xs={12} align="center">
|
||||||
|
{this.state.renewLoading ?
|
||||||
|
<CircularProgress/>
|
||||||
|
:
|
||||||
|
<Button color='primary' onClick={this.handleRenewOrderButtonPressed}>{t("Renew Order")}</Button>
|
||||||
|
}
|
||||||
|
</Grid>
|
||||||
|
: null}
|
||||||
|
|
||||||
{this.showBondIsReturned()}
|
{this.showBondIsReturned()}
|
||||||
</Grid>
|
</Grid>
|
||||||
)
|
)
|
||||||
|
@ -11,7 +11,7 @@ import ContentCopy from "@mui/icons-material/ContentCopy";
|
|||||||
import RoboSatsNoTextIcon from "./icons/RoboSatsNoTextIcon"
|
import RoboSatsNoTextIcon from "./icons/RoboSatsNoTextIcon"
|
||||||
import BoltIcon from '@mui/icons-material/Bolt';
|
import BoltIcon from '@mui/icons-material/Bolt';
|
||||||
|
|
||||||
import { getCookie } from "../utils/cookies";
|
import { getCookie, writeCookie } from "../utils/cookies";
|
||||||
|
|
||||||
class UserGenPage extends Component {
|
class UserGenPage extends Component {
|
||||||
constructor(props) {
|
constructor(props) {
|
||||||
@ -37,7 +37,7 @@ class UserGenPage extends Component {
|
|||||||
var newToken = this.genBase62Token(36)
|
var newToken = this.genBase62Token(36)
|
||||||
this.state = {
|
this.state = {
|
||||||
token: newToken
|
token: newToken
|
||||||
}
|
};
|
||||||
this.getGeneratedUser(newToken);
|
this.getGeneratedUser(newToken);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -73,11 +73,11 @@ class UserGenPage extends Component {
|
|||||||
avatarLoaded: false,
|
avatarLoaded: false,
|
||||||
})
|
})
|
||||||
:
|
:
|
||||||
this.props.setAppState({
|
(console.log(token) & this.props.setAppState({
|
||||||
nickname: data.nickname,
|
nickname: data.nickname,
|
||||||
token: this.state.token,
|
token: token,
|
||||||
avatarLoaded: false,
|
avatarLoaded: false,
|
||||||
}));
|
})) & writeCookie("robot_token",token))
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -91,11 +91,12 @@ class UserGenPage extends Component {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleClickNewRandomToken=()=>{
|
handleClickNewRandomToken=()=>{
|
||||||
|
var token = this.genBase62Token(36);
|
||||||
this.setState({
|
this.setState({
|
||||||
token: this.genBase62Token(36),
|
token: token,
|
||||||
tokenHasChanged: true,
|
tokenHasChanged: true,
|
||||||
copied: true,
|
|
||||||
});
|
});
|
||||||
|
this.props.setAppState({copiedToken: true})
|
||||||
}
|
}
|
||||||
|
|
||||||
handleChangeToken=(e)=>{
|
handleChangeToken=(e)=>{
|
||||||
@ -108,8 +109,8 @@ class UserGenPage extends Component {
|
|||||||
handleClickSubmitToken=()=>{
|
handleClickSubmitToken=()=>{
|
||||||
this.delGeneratedUser();
|
this.delGeneratedUser();
|
||||||
this.getGeneratedUser(this.state.token);
|
this.getGeneratedUser(this.state.token);
|
||||||
this.setState({loadingRobot: true, tokenHasChanged: false, copied: false});
|
this.setState({loadingRobot: true, tokenHasChanged: false});
|
||||||
this.props.setAppState({avatarLoaded: false, nickname: null, token: null});
|
this.props.setAppState({avatarLoaded: false, nickname: null, token: null, copiedToken: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
handleClickOpenInfo = () => {
|
handleClickOpenInfo = () => {
|
||||||
@ -196,9 +197,9 @@ class UserGenPage extends Component {
|
|||||||
}}
|
}}
|
||||||
InputProps={{
|
InputProps={{
|
||||||
startAdornment:
|
startAdornment:
|
||||||
<Tooltip disableHoverListener open={this.state.copied} enterTouchDelay="0" title={t("Copied!")}>
|
<Tooltip disableHoverListener enterTouchDelay="0" title={t("Copied!")}>
|
||||||
<IconButton onClick= {()=> (navigator.clipboard.writeText(this.state.token) & this.setState({copied:true}))}>
|
<IconButton onClick= {()=> (navigator.clipboard.writeText(this.state.token) & this.props.setAppState({copiedToken:true}))}>
|
||||||
<ContentCopy color={this.props.avatarLoaded & !this.state.copied & !this.state.bad_request ? 'primary' : 'inherit' } sx={{width:18, height:18}}/>
|
<ContentCopy color={this.props.avatarLoaded & !this.props.copiedToken & !this.state.bad_request ? 'primary' : 'inherit' } sx={{width:18, height:18}}/>
|
||||||
</IconButton>
|
</IconButton>
|
||||||
</Tooltip>,
|
</Tooltip>,
|
||||||
endAdornment:
|
endAdornment:
|
||||||
|
@ -13,3 +13,7 @@ export const getCookie = (name) => {
|
|||||||
}
|
}
|
||||||
return cookieValue;
|
return cookieValue;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
export const writeCookie = (key,value) => {
|
||||||
|
document.cookie=key+"="+value;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user