Skip to content

Commit

Permalink
Implement user daily reward for post edit via actifit.io
Browse files Browse the repository at this point in the history
  • Loading branch information
Greateck committed Feb 5, 2019
1 parent 53ac9dd commit e0d7d01
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 1 deletion.
29 changes: 28 additions & 1 deletion components/EditReportModal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -185,9 +185,36 @@
author: this.editReport.author,
permlink: this.editReport.permlink
})
//reward the user for a new edit
this.RewardUserEdit();
}
)
}
},
async RewardUserEdit () {
let url = new URL(process.env.actiAppUrl + 'rewardActifitWebEdit/'+this.editReport.author);
//compile all needed data and send it along the request for processing
let params = {
web_edit_token: process.env.webEditToken,
url: this.editReport.permlink,
}
Object.keys(params).forEach(key => url.searchParams.append(key, params[key]))
try{
let res = await fetch(url);
let outcome = await res.json();
if (outcome.rewarded){
// notify the user that he received an additional reward
this.$notify({
group: 'success',
text: 'If this is your first edit today, you\'ve been rewarded '+outcome.amount + ' AFIT tokens. Congrats!',
position: 'top center'
})
}
console.log(outcome);
}catch(err){
console.error(err);
}
}
}
}
</script>
1 change: 1 addition & 0 deletions nuxt.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ module.exports = {
REWARD_REFERRAL_API_KEY: process.env.REWARD_REFERRAL_API_KEY,
DELEGATE_ACCOUNT_API_KEY: process.env.DELEGATE_ACCOUNT_API_KEY,
confirmPaymentToken: process.env.CONFIRM_PAYMENT_API_KEY,
webEditToken: process.env.WEB_EDIT_REWARD_KEY,
actiAppUrl: process.env.ACTI_API_URL || 'http://localhost:3120/',
},

Expand Down

0 comments on commit e0d7d01

Please sign in to comment.