Commit 0fd65551 authored by Bitcoin Please's avatar Bitcoin Please

Fixed welcome PIF campaigns.

parent 087aaa66
......@@ -55,7 +55,7 @@
<div class="author-profile">
<a class="author-icon" href="javascript://">
<img :src="ownerAvatar" alt=""></a>
by <a class="author-name" href="javascript://">{{ownerLabel}}</a>
by <a class="author-name" href="javascript://">{{ownerNickname}}</a>
</div>
<div class="author-address">
......@@ -367,11 +367,11 @@ export default {
},
/**
* Owner Label
* Owner Nickname
*/
ownerLabel() {
if (this.campaign && this.campaign.owner.label) {
return this.campaign.owner.label
ownerNickname() {
if (this.campaign && this.campaign.owner.nickname) {
return this.campaign.owner.nickname
} else {
return null
}
......
......@@ -42,9 +42,6 @@ import Slideshow from '@/views/Welcome/Slideshow.vue'
import Footer from '@/components/Footer.vue'
import Header from '@/components/Header.vue'
/* Initialize ethers. */
import { ethers } from 'ethers'
export default {
components: {
Articles,
......@@ -58,177 +55,21 @@ export default {
Header,
},
methods: {
async initEthers () {
console.log('ETHERS')
if (typeof web3 !== 'undefined') {
const provider = new ethers.providers.Web3Provider(window.web3.currentProvider)
const balance = await provider.getBalance('0x27a9b30DBe015842098F4CD31f0301a1cEE74bfe')
console.log('BALANCE', balance)
var etherString = ethers.utils.formatEther(balance)
console.log("Balance: " + etherString);
const signer = provider.getSigner()
console.log('SIGNER', signer)
const message = 'hi there!'
const sig = await signer.signMessage(message)
console.log('SIG', sig)
}
},
// async initEthereum () {
// if (window.ethereum) {
// window.web3 = new Web3(ethereum)
// // const provider = new ethers.providers.Web3Provider(web3.currentProvider)
//
// try {
// // Request account access if needed
// console.log('window.ethereum')
//
// ethereum.enable()
// } catch (error) {
// // User denied account access...
// }
// } else if (window.web3) { // Legacy dapp browsers...
// window.web3 = new Web3(web3.currentProvider)
//
// console.log('window.currentProvider')
// // Acccounts always exposed
// } else { // Non-dapp browsers...
// alert('Non-Ethereum browser detected.\nYou should consider trying MetaMask!')
// }
//
// /* Validate web3. */
// if (window.web3) {
// /* Retrieve accounts. */
// const accounts = await window.web3.eth.getAccounts()
//
// if (typeof accounts !== 'undefined') {
// /* Set address. */
// const defaultAddress = accounts[0]
//
// console.log('Default address', defaultAddress)
//
// this.profileAddress = defaultAddress
// }
// }
// },
createSSPKWallet() {
console.log('SEND DONATION')
if (typeof window.web4bch !== 'undefined') {
/* Initialize Web4BCH. */
const web4bch = new window.Web4Bch(window.web4bch.currentProvider)
console.log('web4bch', web4bch)
/* Validate web4BCH. */
if (!web4bch) {
// return installBadger()
}
console.log('DEFAULT ACCOUNT', web4bch.bch.defaultAccount)
/* Validate account. */
if (web4bch.bch && web4bch.bch.defaultAccount === undefined) {
alert('please unlock your badgerwallet');
}
/* Set transaction parameters. */
// const txParams = {
// to: donationAddress,
// from: web4bch.bch.defaultAccount,
// value: donationAmount
// }
/* Initialize transaction function. */
// const txFunc = (err, res) => {
// if (err) {
// console.error('ERROR: sendTransaction', err)
//
// console.log('ERROR MSG', err.message)
//
// /* Validate user approval. */
// if (err && err.message) {
// if (err.message.indexOf('User denied transaction signature') !== -1) {
// // FIXME: Add a modal message here.
// alert('User rejected the signature transaction.')
// }
// }
//
// return
// }
//
// console.log('TRANSACTION RESULT', res)
// }
/* Set signature text. */
// const sigText = 'somethingnice'
// const sigText = {
// data: 'hi-there!'
// }
/* Set signature request. */
// const sigRequest = {
// type: 'eth_sign',
// data: 'cashid:',
// }
// const sigRequest = '0x' + Buffer.from(sigText, 'utf8').toString('hex')
// const sigRequest = JSON.stringify(sigText)
// const sigRequest = 'cashid:api.causes.cash/v1/cashid?x=476431778'
// const sigRequest = 'cashid:localhost?x=476431778'
// const sigRequest = 'cashid:'
// console.log('SIGNATURE REQUEST', sigRequest)
/* Send transaction. */
// web4bch.bch.sendTransaction(txParams, txFunc)
// console.log('WEB4BCH.BCH', web4bch)
// web4bch.personal.sign(
// 'qr5cv5xee23wdy8nundht82v6637etlq3u6kzrjknk',
// 'hi there!'
// )
// web4bch.bch.sign(
// web4bch.bch.defaultAccount,
// sigRequest,
// (err, res) => {
// console.log('SIGN ERROR', err)
// console.log('SIGN RESULT', res)
// }
// )
} else {
/* Install Badger. */
// installBadger()
}
},
},
created: function () {
console.log('WEB4BCH', window.web4bch)
// window.web4bch.bch.sign(
// window.web4bch.bch.defaultAccount,
// 'hello world',
// (err, res) => {
// console.log('SIGN ERROR', err)
// console.log('SIGN RESULT', res)
// }
// )
// this.createSSPKWallet()
// this.initEthereum()
// this.initEthers()
//
},
mounted: function () {
// setTimeout(function(){
// $('.preloading').fadeOut()
// }, 3000)
}
}
</script>
<style scoped>
.site-main .sideshow{
.site-main .sideshow {
position: relative;
height: 674px;
background-image: url('https://i.imgur.com/MazyCcK.jpg');
......
<template>
<div class="latest campaign">
<div class="container">
<h2 class="title">Discover Causes</h2>
<h2 class="title">Discover Campaigns</h2>
<div class="campaign-tabs filter-theme">
<button class="button" data-filter=".filterinteresting">
......@@ -24,72 +24,72 @@
<div class="campaign-content grid">
<div class="row">
<!-- Start causes. -->
<!-- Start campaigns. -->
<div
v-for="cause of causes"
:key="cause.id"
v-for="campaign of campaigns"
:key="campaign.id"
class="col-lg-4 col-md-6 col-sm-6 col-6 filterinteresting filterpopular filterlatest">
<div class="campaign-item">
<!-- <a class="overlay" href="javascript://" @click="loadDetails(cause)">
<img :src="cause.coverImgUrl" alt="">
<!-- <a class="overlay" href="javascript://" @click="loadDetails(campaign)">
<img :src="campaign.coverImgUrl" alt="">
<span class="ion-ios-search-strong"></span>
</a> -->
<a class="category" href="javascript://" @click="loadDetails(cause)">
<img :src="cause.coverImgUrl" alt="">
<a class="category" href="javascript://" @click="loadDetails(campaign)">
<img :src="displayImage(campaign)" alt="">
</a>
<div class="campaign-box">
<a class="category" href="javascript://" @click="loadCategory(cause)">
{{cause.category}}
<a class="category" href="javascript://" @click="loadCategory(campaign)">
{{campaign.category}}
</a>
<h3>
<a href="javascript://" @click="loadDetails(cause)">
{{cause.title}}
<a href="javascript://" @click="loadDetails(campaign)">
{{campaign.title}}
</a>
</h3>
<div class="campaign-description">
{{cause.summary}}
{{campaign.summary}}
</div>
<div class="campaign-author">
<a class="author-icon" :href="cause.ownerLink" target="_blank">
<img :src="cause.ownerAvatar" alt="">
by {{cause.ownerName}}
<a class="author-icon" :href="weblink(campaign)" target="_blank">
<img :src="avatar(campaign)" alt="">
by {{displayOwnerName(campaign)}}
</a>
</div>
<div class="process">
<div class="raised">
<span :style="{ width: completedPct(cause, true) + '%'}"></span>
<span :style="{ width: completedPct(campaign, true) + '%'}"></span>
</div>
<div class="process-info">
<div class="process-pledged">
<span>{{formatPledged(cause)}}</span>pledged
<span>{{formatPledged(campaign)}}</span>pledged
</div>
<div class="process-funded">
<span>{{formatFunded(cause)}}</span>funded
<span>{{formatFunded(campaign)}}</span>funded
</div>
<div class="process-time">
<span>{{cause.updatedAt}}</span>days ago
<span>{{campaign.updatedAt}}</span>days ago
</div>
</div>
</div>
</div>
</div>
</div>
<!-- End causes. -->
<!-- End campaigns. -->
</div>
</div>
<div class="latest-button">
<router-link to="/discover" class="btn-primary">
Discover More Causes
Discover More Campaigns
</router-link>
</div>
</div>
......@@ -113,7 +113,7 @@ export default {
},
data: () => {
return {
causes: [],
campaigns: [],
}
},
computed: {
......@@ -122,12 +122,68 @@ export default {
]),
},
methods: {
/**
* Load Featured Campaigns
*/
async loadFeatured() {
/* Request campaigns. */
const campaigns = await Promise.all([
this.getCampaign('bitcoinverde','bitcoin-verde-node-development'),
this.getCampaign('bchd', 'bchd-node-development'),
this.getCampaign('bitcoinabc', 'bitcoin-cash-protocol-development-fundraiser'),
this.getCampaign('knuth', 'knuth-platform-development'),
this.getCampaign('bchn', 'bitcoin-cash-node-initiative'),
this.getCampaign('eatbch', 'help-us-deliver-food-for-one-month'),
])
.catch(err => console.error(err))
// console.log('RETRIEVED CAMPAIGNS', campaigns)
/* Load campaigns. */
campaigns.forEach(campaign => {
this.campaigns.push(campaign)
})
},
avatar(_campaign) {
if (_campaign.owner && _campaign.owner.avatar) {
return _campaign.owner.avatar
} else {
return null
}
},
weblink(_campaign) {
if (_campaign.owner && _campaign.owner.link) {
return _campaign.owner.link
} else {
return null
}
},
displayImage(_campaign) {
if (_campaign.media && _campaign.media.main) {
return _campaign.media.main
} else {
return null
}
},
displayOwnerName(_campaign) {
if (_campaign && (_campaign.owner.label || _campaign.owner.nickname)) {
return _campaign.owner.label || _campaign.owner.nickname
} else {
return null
}
},
/**
* Load Category
*/
loadCategory(_cause) {
loadCategory(_campaign) {
/* Set category. */
const category = _cause.category
const category = _campaign.category
alert('goto ' + category)
},
......@@ -135,11 +191,11 @@ export default {
/**
* Load Details
*/
loadDetails(_cause) {
// console.log('CAUSE', _cause)
loadDetails(_campaign) {
// console.log('CAUSE', _campaign)
/* Set campaign id. */
const id = _cause.id
const id = _campaign.id
/* Validate id. */
if (!id) {
......@@ -147,7 +203,7 @@ export default {
}
/* Set slug. */
const slug = _cause.slug
const slug = _campaign.slug
/* Validate slug. */
if (!slug) {
......@@ -155,7 +211,7 @@ export default {
}
/* Set author id. */
const ownerId = _cause.ownerId
const ownerId = _campaign.ownerId
/* Validate author id. */
if (!ownerId) {
......@@ -172,9 +228,9 @@ export default {
/**
* Completed Percentage
*/
completedPct(_cause, _integer = false) {
completedPct(_campaign, _integer = false) {
/* Calculate completion percentage. */
const completedPct = (_cause.pledged / _cause.requested)
const completedPct = (_campaign.pledged / _campaign.requested)
/* Validate integer flag. */
if (_integer) {
......@@ -187,15 +243,15 @@ export default {
/**
* Format Pledged
*/
formatPledged(_cause) {
formatPledged(_campaign) {
/* Set pledged amount. */
const pledged = _cause.pledged
const pledged = _campaign.pledged
/* Initialize dollar value. */
let dollar = null
/* Calculate dollar value. */
if (_cause.currency === 'BCH') {
if (_campaign.currency === 'BCH') {
dollar = pledged * 244.18
} else {
dollar = pledged
......@@ -211,9 +267,9 @@ export default {
/**
* Format Funded
*/
formatFunded(_cause) {
formatFunded(_campaign) {
/* Set percentage. */
const pct = _cause.pct
const pct = _campaign.pct
/* Initialize formatted. */
let formatted = null
......@@ -221,7 +277,7 @@ export default {
if (pct === 0) {
formatted = 'ongoing'
} else {
const completePct = this.completedPct(_cause)
const completePct = this.completedPct(_campaign)
formatted = numeral(completePct).format('0.00%')
}
......@@ -232,23 +288,8 @@ export default {
},
created: function () {
/* Cause */
this.causes.push(this.getCampaign('bitcoin-verde-node-development-14214ea4cd41'))
/* Cause */
this.causes.push(this.getCampaign('bchd-node-development-8331b54814ea'))
/* Cause */
this.causes.push(this.getCampaign('bitcoin-cash-protocol-development-fundraiser-43eda61596e7'))
/* Cause */
this.causes.push(this.getCampaign('knuth-platform-development-158ef2f48aa0'))
/* Cause */
this.causes.push(this.getCampaign('bitcoin-cash-node-initiative-f837f2d17747'))
/* Cause */
this.causes.push(this.getCampaign('help-us-deliver-food-for-one-month-b6ce6ceb819f'))
/* Load featured campaigns. */
this.loadFeatured()
},
mounted: function () {
......
......@@ -7,71 +7,69 @@
<h2 class="title left-title">Most ❤️ By Our Community</h2>
<div class="description left-description">
Pay-It-Forward (PIF) and vote for YOUR favorite cause(s).
Pay-It-Forward (PIF) and vote for YOUR favorite campaign(s).
</div>
</div>
<ul class="project-love-slider">
<li v-for="cause of causes" :key="cause.id">
<li v-for="campaign of campaigns" :key="campaign.id">
<div class="project-love-item clearfix">
<!-- <router-link to="/details" class="project-love-image"> -->
<router-link to="/welcome" class="project-love-image">
<img :src="cause.imgUrl" class="img-rounded" alt="">
<img :src="displayImage(campaign)" class="img-rounded" alt="">
</router-link>
<div class="project-love-item-content project-love-box">
<router-link to="/discover" class="category category-link">
{{cause.category}}
{{displayCategory(campaign)}}
</router-link>
<h3>
<!-- <router-link to="/details"> -->
<router-link to="/welcome">
{{cause.title}}
{{campaign.title}}
</router-link>
</h3>
<div class="project-love-description">
{{cause.description}}
</div>
<div v-html="getMarkdown(campaign.summary)" class="project-love-description" />
<div class="project-love-author">
<div class="author-profile">
<a class="author-avatar" :href="cause.ownerLink" target="_blank">
<img :src="cause.ownerAvatar" alt="">
<a class="author-avatar" :href="weblink(campaign)" target="_blank">
<img :src="avatar(campaign)" alt="">
</a>
by
<a class="author-name" :href="cause.ownerLink" target="_blank">
{{cause.ownerName}}
<a class="author-name" :href="weblink(campaign)" target="_blank">
{{displayOwnerName(campaign)}}
</a>
</div>
<div class="author-address">
<span class="ion-location"></span>
{{cause.location}}
{{displayLocation(campaign)}}
</div>
</div>
<div class="process">
<div class="raised">
<span :style="{ width: completedPct(cause, true) + '%'}"></span>
<span :style="{ width: completedPct(campaign, true) + '%'}"></span>
</div>
<div class="process-info">
<div class="process-pledged">
<span>{{formatRequested(cause)}}</span>requested
<span>{{formatRequested(campaign)}}</span>requested
</div>
<div class="process-funded">
<span>{{formatPledged(cause)}}</span>pledged
<span>{{formatPledged(campaign)}}</span>pledged
</div>
<div class="process-time">
<span>{{cause.backers}}</span>backers
<span>{{displayBackers(campaign)}}</span>backers
</div>
<!-- <div class="process-time">
<span>{{cause.updatedAt}}</span>days ago
<span>{{campaign.updatedAt}}</span>days ago
</div> -->
</div>
</div>
......@@ -112,21 +110,75 @@ export default {
},
data: () => {
return {
causes: [],
campaigns: [],
}
},
computed: {
...mapGetters('campaigns', [
'getCampaign',
]),
...mapGetters('utils', [
'getCategoryDisplay',
'getMarkdown',
]),
},
methods: {
/**