mirror of
https://github.com/RoboSats/robosats.git
synced 2024-12-13 10:56:24 +00:00
Add rewards and referral code on usergen api responses
This commit is contained in:
parent
20432dfce1
commit
c397ff63e5
@ -748,6 +748,8 @@ class UserView(APIView):
|
||||
login(request, user)
|
||||
context["public_key"] = user.profile.public_key
|
||||
context["encrypted_private_key"] = user.profile.encrypted_private_key
|
||||
context["earned_rewards"] = user.profile.earned_rewards
|
||||
context["referral_code"] = str(user.profile.referral_code)
|
||||
|
||||
# return active order or last made order if any
|
||||
has_no_active_order, _, order = Logics.validate_already_maker_or_taker(request.user)
|
||||
|
@ -46,8 +46,6 @@ class BottomBar extends Component {
|
||||
alternative_site: 'robosats...',
|
||||
node_id: '00000000',
|
||||
showRewards: false,
|
||||
referral_code: '',
|
||||
earned_rewards: 0,
|
||||
rewardInvoice: null,
|
||||
badInvoice: false,
|
||||
showRewardsSpinner: false,
|
||||
@ -67,7 +65,9 @@ class BottomBar extends Component {
|
||||
& this.props.setAppState({nickname:data.nickname,
|
||||
loading:false,
|
||||
activeOrderId: data.active_order_id ? data.active_order_id : null,
|
||||
lastOrderId: data.last_order_id ? data.last_order_id : null}));
|
||||
lastOrderId: data.last_order_id ? data.last_order_id : null,
|
||||
referralCode: data.referral_code,
|
||||
earnedRewards: data.earned_rewards,}));
|
||||
}
|
||||
|
||||
handleClickOpenStatsForNerds = () => {
|
||||
@ -111,10 +111,13 @@ class BottomBar extends Component {
|
||||
.then((data) => this.setState({
|
||||
badInvoice:data.bad_invoice,
|
||||
openClaimRewards: data.successful_withdrawal ? false : true,
|
||||
earned_rewards: data.successful_withdrawal ? 0 : this.state.earned_rewards,
|
||||
withdrawn: data.successful_withdrawal ? true : false,
|
||||
showRewardsSpinner: false,
|
||||
}));
|
||||
})
|
||||
& this.props.setAppState({
|
||||
earnedRewards: data.successful_withdrawal ? 0 : this.props.earnedRewards,
|
||||
})
|
||||
);
|
||||
e.preventDefault();
|
||||
}
|
||||
|
||||
@ -129,7 +132,7 @@ class BottomBar extends Component {
|
||||
|
||||
bottomBarDesktop =()=>{
|
||||
const { t } = this.props;
|
||||
var hasRewards = this.state.earned_rewards > 0 ? true: false;
|
||||
var hasRewards = this.props.earnedRewards > 0 ? true: false;
|
||||
var hasOrder = this.props.activeOrderId > 0 & !this.state.profileShown & this.props.avatarLoaded ? true : false;
|
||||
|
||||
return(
|
||||
@ -316,7 +319,10 @@ bottomBarDesktop =()=>{
|
||||
}
|
||||
|
||||
handleClickOpenExchangeSummary = () => {
|
||||
this.getInfo();
|
||||
// avoid calling getInfo while sessionid not yet set. Temporary fix.
|
||||
if(getCookie('sessionid')){
|
||||
this.getInfo();
|
||||
}
|
||||
this.setState({openExchangeSummary: true});
|
||||
};
|
||||
handleClickCloseExchangeSummary = () => {
|
||||
@ -325,7 +331,7 @@ bottomBarDesktop =()=>{
|
||||
|
||||
bottomBarPhone =()=>{
|
||||
const { t } = this.props;
|
||||
var hasRewards = this.state.earned_rewards > 0 ? true: false;
|
||||
var hasRewards = this.props.earnedRewards > 0 ? true: false;
|
||||
var hasOrder = this.state.active_order_id > 0 & !this.state.profileShown & this.props.avatarLoaded ? true : false;
|
||||
return(
|
||||
<Paper elevation={6} style={{height:40}}>
|
||||
@ -464,13 +470,13 @@ bottomBarPhone =()=>{
|
||||
nickname={this.props.nickname}
|
||||
activeOrderId={this.props.activeOrderId}
|
||||
lastOrderId={this.props.lastOrderId}
|
||||
referralCode={this.state.referral_code}
|
||||
referralCode={this.props.referralCode}
|
||||
handleSubmitInvoiceClicked={this.handleSubmitInvoiceClicked}
|
||||
host={this.getHost()}
|
||||
showRewardsSpinner={this.state.showRewardsSpinner}
|
||||
withdrawn={this.state.withdrawn}
|
||||
badInvoice={this.state.badInvoice}
|
||||
earnedRewards={this.state.earned_rewards}
|
||||
earnedRewards={this.props.earnedRewards}
|
||||
setAppState={this.props.setAppState}
|
||||
/>
|
||||
|
||||
|
@ -24,6 +24,8 @@ export default class HomePage extends Component {
|
||||
bookLoading: true,
|
||||
activeOrderId: null,
|
||||
lastOrderId: null,
|
||||
earnedRewards: 0,
|
||||
referralCode:'',
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -93,6 +93,8 @@ class UserGenPage extends Component {
|
||||
nickname: data.nickname,
|
||||
avatarLoaded: false,
|
||||
activeOrderId: data.active_order_id ? data.active_order_id : null,
|
||||
referralCode: data.referral_code,
|
||||
earnedRewards: data.earned_rewards,
|
||||
lastOrderId: data.last_order_id ? data.last_order_id : null,
|
||||
})
|
||||
:
|
||||
@ -102,6 +104,8 @@ class UserGenPage extends Component {
|
||||
avatarLoaded: false,
|
||||
activeOrderId: data.active_order_id ? data.active_order_id : null,
|
||||
lastOrderId: data.last_order_id ? data.last_order_id : null,
|
||||
referralCode: data.referral_code,
|
||||
earnedRewards: data.earned_rewards,
|
||||
})) & writeCookie("robot_token",token)
|
||||
& writeCookie("pub_key",data.public_key.split('\n').join('\\'))
|
||||
& writeCookie("enc_priv_key",data.encrypted_private_key.split('\n').join('\\')))
|
||||
|
Loading…
Reference in New Issue
Block a user