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