const html = require('choo/html'); const assets = require('../../common/assets'); const { bytes } = require('../utils'); module.exports = function() { return function(state, emit, close) { const DAYS = Math.floor(state.LIMITS.MAX_EXPIRE_SECONDS / 86400); let submitting = false; return html`

${state.translate('accountBenefitTitle')}

${state.user.loginRequired ? '' : html` `}
`; function emailish(str) { if (!str) { return false; } // just check if it's the right shape const a = str.split('@'); return a.length === 2 && a.every(s => s.length > 0); } function cancel(event) { close(event); } function submitEmail(event) { event.preventDefault(); if (submitting) { return; } submitting = true; const el = document.getElementById('email-input'); const email = el.value; emit('login', emailish(email) ? email : null); } }; };