var html = require('choo/html') var TITLE = 'double - main' function view (state, emit) { if (state.title !== TITLE) emit(state.events.DOMTITLECHANGE, TITLE) const form = html`



` const submit = html`
` const entries = html`
${state.entries.map(entry => ['debit', 'credit'].map(i => i === 'debit' ? html`` : html`` ))}
account debit credit
${entry.msg.debit} ${entry.msg.amount} -
${entry.msg.credit} - ${entry.msg.amount}
` return html`
double
${form} ${entries} ${submit}
${Object.keys(state.accounts).map(key => { if (state.accounts[key].archived) return html`
${state.accounts[key].name}
` return html`
${state.accounts[key].name}
` })}
` function generateAccountList () { return Object.keys(state.accounts).map(key => { if (state.accounts[key].archived) return const name = state.accounts[key].name return html`` }) } function handleEntry () { const amount = document.getElementById('amount').value const debit = document.getElementById('debit').value const credit = document.getElementById('credit').value const description = document.getElementById('description').value emit('entries', { type: 'entries', msg: { amount, debit, credit, description } }) } function handleAccountCreate () { const account = document.getElementById('account').value emit('accounts', { type: 'accounts', msg: { name: account, archived: false } }) } function handleAccountArchive () { const name = this.innerHTML emit('accounts', { type: 'accounts', msg: { name, type: 'TOGGLE' } }) } } module.exports = view