Commit e75e09df authored by Bitcoin Please's avatar Bitcoin Please

Continuing to refactor to `assurances`.

parent 2ccccb1f
......@@ -11,8 +11,8 @@ const addAssurance = async ({ rootGetters }, _assurance) => {
// console.log('SIGNED PACKAGE', signedPkg)
/* Set api target. */
const target = 'http://localhost:6767/v1/assurance'
// const target = 'https://api.causes.cash/v1/assurance'
const target = 'http://localhost:6767/v1/assurances'
// const target = 'https://api.causes.cash/v1/assurances'
const result = await superagent
.post(target)
......
......@@ -141,8 +141,8 @@
</div>
<div v-if="showActions" class="button">
<a href="javascript://" class="btn-primary" @click="displaySupport">
Support this Campaign
<a href="javascript://" class="btn-primary" @click="addMySupport">
Add my support
</a>
<a href="javascript://" class="btn-secondary" @click="showActions = false; showReminder = true">
......@@ -432,7 +432,7 @@ export default {
const model = this.campaign.model
if (model === 'assurance') {
return JSON.stringify(this.campaign.assurance, null, 2)
return JSON.stringify(this.campaign.assurances, null, 2)
}
return null
......@@ -449,8 +449,10 @@ export default {
/* Set model. */
const model = this.campaign.model
const assuranceid = 0
if (model === 'assurance') {
return this.campaign.assurance.recipient.satoshis
return this.campaign.assurances[assuranceid].recipient.satoshis
}
return 0
......@@ -467,8 +469,10 @@ export default {
/* Set model. */
const model = this.campaign.model
const assuranceid = 0
if (model === 'assurance') {
return this.campaign.assurance.recipient.address
return this.campaign.assurances[assuranceid].recipient.address
}
return 0
......@@ -502,9 +506,11 @@ export default {
* Funding Goal
*/
fundingGoal() {
if (this.campaign && this.campaign.assurance) {
if (this.campaign && this.campaign.assurances) {
const assuranceid = 0
/* Set recipients. */
const recipient = this.campaign.assurance.recipient
const recipient = this.campaign.assurances[assuranceid].recipient
/* Validate recipients. */
if (!recipient) {
......@@ -523,9 +529,11 @@ export default {
* Funding Pledged
*/
fundingPledged() {
if (this.campaign && this.campaign.assurance) {
if (this.campaign && this.campaign.assurances) {
const assuranceid = 0
/* Set recipients. */
const recipient = this.campaign.assurance.recipient
const recipient = this.campaign.assurances[assuranceid].recipient
/* Validate recipients. */
if (!recipient) {
......@@ -560,14 +568,14 @@ export default {
]),
/**
* Display Support
* Add My Support
*/
displaySupport() {
addMySupport() {
/* Hide actions. */
this.showActions = false
/* Handle support window. */
if (this.campaign.assurance) {
if (this.campaign.assurances) {
/* Show assurance window. */
this.showAssurance = true
} else if (this.campaign.direct) {
......
......@@ -190,9 +190,20 @@ export default {
return this.getAddress('deposit')
},
/**
* Pledged Value
*
* States the current value of all funds pledged to this campaign.
*/
pledgedValue() {
const assuranceid = 0
if (!this.campaign.assurances[assuranceid].pledges) {
return 0
}
/* Calculate pledged (satoshis). */
const pledged = this.campaign.assurance.pledges
const pledged = this.campaign.assurances[assuranceid].pledges
.reduce((accumulator, pledge) => {
if (pledge.isSpent === true) {
return accumulator
......@@ -207,16 +218,18 @@ export default {
pledgeDetails() {
/* Validate assurance. */
if (!this.campaign.assurance) {
if (!this.campaign.assurances) {
return null
}
const assuranceid = 0
/* Build (pledge) package. */
const pkg = {
outputs: [
{
value: this.campaign.assurance.recipient.satoshis,
address: this.campaign.assurance.recipient.address
value: this.campaign.assurances[assuranceid].recipient.satoshis,
address: this.campaign.assurances[assuranceid].recipient.address
}
],
data: {
......@@ -226,7 +239,7 @@ export default {
donation: {
amount: this.pledgeSatoshis
},
expires: this.campaign.assurance.expiresAt
expires: this.campaign.assurances[assuranceid].expiresAt
}
/* Format to base-64. */
......@@ -445,10 +458,12 @@ export default {
this.pledgeUSD = 1 // FIXME
this.onPledgeUpdate()
const assuranceid = 0
/* Validate assurance. */
if (this.campaign.assurance) {
if (this.campaign.assurances) {
/* Set pledge goal. */
this.pledgeGoal = this.campaign.assurance.recipient.satoshis
this.pledgeGoal = this.campaign.assurances[assuranceid].recipient.satoshis
console.log('PLEDGE GOAL', this.pledgeGoal)
}
},
......
<template>
<div id="guide" class="tabs">
<div id="guide" class="tabs markdown">
<div v-if="guideDisplay" class="mt-3" v-html="guideDisplay" />
<div v-else>
......@@ -31,12 +31,12 @@ export default {
watch: {
campaign: function (_campaign) {
if (_campaign && _campaign.guide) {
console.log('CAMPAIGN HAS CHANGED, UPDATE GUIDE!!', _campaign)
// console.log('CAMPAIGN HAS CHANGED, UPDATE GUIDE!!', _campaign)
if (_campaign && _campaign.guide) {
/* Set summary. */
/* Set guide. */
this.guide = _campaign.guide
console.log('GUIDE', this.guide)
// console.log('GUIDE', this.guide)
}
}
},
......@@ -51,15 +51,14 @@ export default {
*/
guideDisplay() {
/* Validate guide. */
if (!this.guide) {
if (this.guide) {
/* Return guide (in markdown). */
return this.getMarkdown(this.guide)
} else {
return null
}
/* Return summary (in markdown). */
return this.getMarkdown(this.guide)
},
},
methods: {
...mapActions('campaigns', [
......
......@@ -5,26 +5,26 @@
<ol v-if="articleList" class="comments-list">
<li v-for="article of articleList" :key="article.id" class="comment clearfix">
<div class="comment-body">
<div class="comment-avatar">
<div class="comment-avatar float-left mr-3 mb-3">
<img class="avatar" :src="article.avatar" alt="">
</div>
<div class="comment-info">
<header class="comment-meta"></header>
<cite class="comment-author">
<div class="article-title">
<a :href="article.url" target="_blank">
{{article.title}}</a>
</cite>
</div>
<div class="comment-inline">
<span class="comment-date">{{article.timeAgo}}</span>
<!-- <a href="javascript://" class="comment-reply">Reply</a> -->
<div class="article-byline">
by <span class="comment-date">{{article.author}}</span>
&bullet; <span class="comment-date">{{article.timeAgo}}</span>
</div>
<div class="comment-content">
<p>
{{article.summary}}
{{formatSummary(article.summary)}}
</p>
</div>
</div>
......@@ -61,6 +61,32 @@ export default {
articles: [],
}
},
watch: {
campaign: function (_campaign) {
if (_campaign && _campaign.news) {
// console.log('CAMPAIGN HAS CHANGED, UPDATE NEWS!!', _campaign)
if (_campaign && _campaign.news) {
/* Set summary. */
const news = this.campaign.news
// console.log('NEWS', news)
/* Add each news article. */
news.forEach(article => {
this.articles.push({
id: article.id,
title: article.title,
summary: article.summary,
url: article.url,
avatar: article.avatar,
author: article.author,
createdAt: article.createdAt,
})
})
}
}
},
},
computed: {
...mapGetters('campaigns', [
'getAsset',
......@@ -88,29 +114,39 @@ export default {
return articles.reverse()
},
},
methods: {
...mapActions('campaigns', [
'updateAsset',
]),
formatSummary(_summary) {
if (_summary.length > 250) {
return _summary.slice(0, 250) + ' [ more... ]'
} else {
return _summary
}
},
},
created: function () {
/* Validate news. */
if (this.campaign && this.campaign.news) {
/* Set summary. */
this.news = this.campaign.news
console.log('NEWS', this.news)
const news = this.campaign.news
// console.log('NEWS', news)
/* Add each news article. */
this.news.forEach(news => {
news.forEach(article => {
this.articles.push({
id: news.id,
title: news.title,
summary: news.summary,
avatar: news.avatar,
url: news.url,
createdAt: news.createdAt,
id: article.id,
title: article.title,
summary: article.summary,
url: article.url,
avatar: article.avatar,
author: article.author,
createdAt: article.createdAt,
})
})
}
......@@ -136,4 +172,15 @@ export default {
span.comment-date {
font-style: italic;
}
div.article-title {
font-size: 1.7em;
font-weight: 600;
}
div.article-byline {
font-style: italic;
margin: 5px 0;
color: rgba(30, 30, 30, 0.5);
}
</style>
......@@ -141,8 +141,8 @@ export default {
</script>
<style scoped>
h1 {
/* h1 {
margin-bottom: 20px;
color: rgba(30, 30, 30, 0.2);
}
} */
</style>
......@@ -41,8 +41,17 @@ export default {
campaign: function (_campaign) {
/* Handle campaign supporters. */
if (_campaign && _campaign.assurances) {
console.log('CAMPAIGN HAS CHANGED, UPDATE SUPPORTERS!!', _campaign)
const assuranceid = 0
/* Set pledges. */
const pledges = _campaign.assurances.pledges
const pledges = _campaign.assurances[assuranceid].pledges
/* Validate pledges. */
if (!pledges) {
return
}
/* Handle all pledges. */
Object.keys(pledges).filter(pledgeId => {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment