diff --git a/app/components/confirmed-in/template.hbs b/app/components/confirmed-in/template.hbs index 44614dc..65ac4f0 100644 --- a/app/components/confirmed-in/template.hbs +++ b/app/components/confirmed-in/template.hbs @@ -1,3 +1,5 @@ -{{#unless this.isConfirmed}} +{{#if this.isConfirmed}} +Confirmed at block {{@confirmedAtBlock}} (~ {{this.confirmedInHumanTime}} ago) +{{else}} Confirming in {{this.confirmedInBlocks}} blocks (~ {{this.confirmedInHumanTime}}) -{{/unless}} +{{/if}} diff --git a/app/components/reimbursement-item/component.js b/app/components/reimbursement-item/component.js new file mode 100644 index 0000000..e3a7f3a --- /dev/null +++ b/app/components/reimbursement-item/component.js @@ -0,0 +1,68 @@ +import Component from '@glimmer/component'; +import { action } from '@ember/object'; +import { tracked } from '@glimmer/tracking'; +import { inject as service } from '@ember/service'; +import config from 'kredits-web/config/environment'; +import fmtDateLocalized from 'kredits-web/helpers/fmt-date-localized'; + +export default class ReimbursementItemComponent extends Component { + @service kredits; + @tracked showExpenseDetails = false; + + constructor(owner, args) { + super(owner, args); + if (this.isUnconfirmed && !this.isVetoed) { + this.showExpenseDetails = true; + } + } + + get ipfsGatewayUrl () { + return config.ipfs.gatewayUrl; + } + + get isConfirmed () { + return (this.args.reimbursement.confirmedAt - this.kredits.currentBlock) <= 0; + } + + get isUnconfirmed () { + return !this.isConfirmed; + } + + get isVetoed () { + return this.args.reimbursement.vetoed; + } + + get showVetoButton () { + return this.isUnconfirmed && this.kredits.currentUserIsCore; + } + + get showConfirmedIn () { + return !this.isVetoed && + (this.showExpenseDetails || this.isUnconfirmed); + } + + get expenses () { + return this.args.reimbursement.expenses; + } + + get expensesDateRange () { + const dates = this.expenses.map(e => e.date).uniq().sort(); + let out = fmtDateLocalized.compute(dates.firstObject) + if (dates.length > 1) { + out += ' - ' + fmtDateLocalized.compute(dates.lastObject) + } + return out; + } + + @action + toggleExpenseDetails () { + this.showExpenseDetails = !this.showExpenseDetails; + } + + @action + veto (id) { + this.kredits.vetoReimbursement(id).then(transaction => { + console.debug('[controllers:budget] Veto submitted to chain: '+transaction.hash); + }); + } +} diff --git a/app/components/reimbursement-item/template.hbs b/app/components/reimbursement-item/template.hbs new file mode 100644 index 0000000..408860e --- /dev/null +++ b/app/components/reimbursement-item/template.hbs @@ -0,0 +1,41 @@ +
+ + {{sats-to-btc @reimbursement.amount}} BTC +
+ + {{#if this.showExpenseDetails}} +- - {{sats-to-btc reimbursement.amount}} BTC -
- -