Store token in App.js state, show temporarily in profile

This commit is contained in:
Reckless_Satoshi 2022-01-29 12:17:30 -08:00
parent 5ab97453f0
commit 4eb136c249
No known key found for this signature in database
GPG Key ID: 9C4585B561315571
3 changed files with 25 additions and 5 deletions

View File

@ -9,6 +9,7 @@ export default class App extends Component {
super(props); super(props);
this.state = { this.state = {
nickname: null, nickname: null,
token: null,
} }
} }
@ -23,7 +24,7 @@ export default class App extends Component {
<HomePage setAppState={this.setAppState}/> <HomePage setAppState={this.setAppState}/>
</div> </div>
<div className='bottomBar'> <div className='bottomBar'>
<BottomBar nickname={this.state.nickname} setAppState={this.setAppState} /> <BottomBar {...this.state} setAppState={this.setAppState} />
</div> </div>
</> </>
); );

View File

@ -1,5 +1,5 @@
import React, { Component } from 'react' import React, { Component } from 'react'
import {Badge, ListItemAvatar, Avatar,Paper, Grid, IconButton, Typography, Select, MenuItem, List, ListItemText, ListItem, ListItemIcon, ListItemButton, Divider, Dialog, DialogContent} from "@mui/material"; 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 MediaQuery from 'react-responsive'
// Icons // Icons
@ -16,6 +16,7 @@ import EqualizerIcon from '@mui/icons-material/Equalizer';
import SendIcon from '@mui/icons-material/Send'; import SendIcon from '@mui/icons-material/Send';
import PublicIcon from '@mui/icons-material/Public'; import PublicIcon from '@mui/icons-material/Public';
import NumbersIcon from '@mui/icons-material/Numbers'; import NumbersIcon from '@mui/icons-material/Numbers';
import PasswordIcon from '@mui/icons-material/Password';
// pretty numbers // pretty numbers
function pn(x) { function pn(x) {
@ -191,7 +192,7 @@ export default class BottomBar extends Component {
<List> <List>
<Divider/> <Divider/>
<ListItem className="profileNickname"> <ListItem className="profileNickname">
<ListItemText secondary="Your robot pseudonymous"> <ListItemText secondary="Your robot">
<Typography component="h6" variant="h6"> <Typography component="h6" variant="h6">
{this.props.nickname ? "⚡"+this.props.nickname+"⚡" : ""} {this.props.nickname ? "⚡"+this.props.nickname+"⚡" : ""}
</Typography> </Typography>
@ -211,14 +212,31 @@ export default class BottomBar extends Component {
<ListItemIcon> <ListItemIcon>
<NumbersIcon color="primary"/> <NumbersIcon color="primary"/>
</ListItemIcon> </ListItemIcon>
<ListItemText color="primary" primary={'One active order #'+this.state.active_order_id} secondary="Your current order"/> <ListItemText primary={'One active order #'+this.state.active_order_id} secondary="Your current order"/>
</ListItemButton> </ListItemButton>
: :
<ListItem> <ListItem>
<ListItemIcon><NumbersIcon/></ListItemIcon> <ListItemIcon><NumbersIcon/></ListItemIcon>
<ListItemText primary="No active orders" secondary="Your current order"/> <ListItemText secondary="Your current order"/>
</ListItem> </ListItem>
} }
<ListItem>
<ListItemIcon>
<PasswordIcon/>
</ListItemIcon>
<ListItemText secondary="Last generated token.">
{this.props.token ?
<TextField
disabled
label='Store safely'
value={this.props.token }
variant='filled'
size='small'/>
:
'Cannot remember'}
</ListItemText>
</ListItem>
</List> </List>
</DialogContent> </DialogContent>

View File

@ -61,6 +61,7 @@ export default class UserGenPage extends Component {
& &
this.props.setAppState({ this.props.setAppState({
nickname: data.nickname, nickname: data.nickname,
token: this.state.token,
}); });
}); });
} }