Developer program fixes #296

Merged
NetOpWibby merged 3 commits from devprogram-fixes into master 2019-09-10 19:29:26 +02:00
3 changed files with 20 additions and 9 deletions
Showing only changes of commit ed6cfb239a - Show all commits

View file

@ -64,26 +64,30 @@ function syncWithApi(data) { // eslint-disable-line no-unused-vars
fetch(`https://api.lbry.com/reward/new?github_token=${code}&reward_type=github_developer&wallet_address=${address}`) fetch(`https://api.lbry.com/reward/new?github_token=${code}&reward_type=github_developer&wallet_address=${address}`)
.then(response => response.json()) .then(response => response.json())
.then(result => { .then(result => {
console.log(result);
switch(true) { switch(true) {
case result.error === "this reward is limited to 1 per person": case result.error === "this reward is limited to 1 per person":
document.querySelector("developer-program").innerHTML = document.querySelector("developer-program").innerHTML =
"<p>You have already claimed this reward. This reward is limited to <strong>ONE</strong> per person. Your enthusiasm is appreciated.</p>"; "<p>You have already claimed this reward. This reward is limited to <strong>ONE</strong> per person. Your enthusiasm is appreciated.</p>";
break; return;
case result.success: case result.success:
result = result.data; result = result.data;
document.querySelector("developer-program").innerHTML = document.querySelector("developer-program").innerHTML =
`<p><strong>Success!</strong> Your wallet has been credited with ${result.reward_amount} LBC.</p><p>We have a great reference for the <a href="/api/sdk">LBRY SDK here</a> to help you get started.</p><p>You can see proof of this transaction on <a href="https://explorer.lbry.com/tx/${result.transaction_id}">our Blockchain Explorer</a>.</p>`; `<p><strong>Success!</strong> Your wallet has been credited with ${result.reward_amount} LBC.</p><p>We have a great reference for the <a href="/api/sdk">LBRY SDK here</a> to help you get started.</p><p>You can see proof of this transaction on <a href="https://explorer.lbry.com/tx/${result.transaction_id}">our Blockchain Explorer</a>.</p>`;
break; return;
default: default:
console.log(data); // eslint-disable-line no-console console.info(data); // eslint-disable-line no-console
document.querySelector("developer-program").innerHTML = document.querySelector("developer-program").innerHTML =
"<p><strong>The LBRY API might be down. Please try again later.</strong></p>"; "<p><strong>The LBRY API might be down. Please try again later.</strong></p>";
break; return;
} }
}) })
.catch(() => { .catch(error => {
console.error(error);
// Idk what the error would be (probably a 500) so let's just have this message // Idk what the error would be (probably a 500) so let's just have this message
document.querySelector("developer-program").innerHTML = document.querySelector("developer-program").innerHTML =
"<p><strong>LBRY API is down. Please try again later.</strong></p>"; "<p><strong>LBRY API is down. Please try again later.</strong></p>";

View file

@ -3,6 +3,13 @@ developer-program {
input-submit { input-submit {
padding-top: 0.5rem; padding-top: 0.5rem;
button {
background-color: $lbry-black;
color: $lbry-white;
padding-right: 1.5rem;
padding-left: 1.5rem;
}
} }
.button { .button {

View file

@ -15,11 +15,11 @@ import { generateGitHubFeed } from "~helper/github";
import messageSlack from "~helper/slack"; import messageSlack from "~helper/slack";
import { URL } from "url"; import { URL } from "url";
const githubAppId = process.env.GITHUB_APP_ID; // const githubAppId = process.env.GITHUB_APP_ID;
const githubAppSecret = process.env.GITHUB_APP_SECRET; // const githubAppSecret = process.env.GITHUB_APP_SECRET;
// const githubAppId = process.env.GITHUB_APP_ID_TEST; const githubAppId = process.env.GITHUB_APP_ID_TEST;
// const githubAppSecret = process.env.GITHUB_APP_SECRET_TEST; const githubAppSecret = process.env.GITHUB_APP_SECRET_TEST;