/* global LIMITS */
const html = require('choo/html');
const { bytes } = require('../utils');
module.exports = function() {
return function(state, emit, close) {
setTimeout(function() {
document.getElementById('email-input').focus();
});
return html`
${state.translate('accountBenefitTitle')}
- ${state.translate('accountBenefitLargeFiles', {
size: bytes(LIMITS.MAX_FILE_SIZE)
})}
- ${state.translate('accountBenefitExpiry')}
- ${state.translate('accountBenefitSync')}
`;
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 submitEmail(event) {
event.preventDefault();
const el = document.getElementById('email-input');
const email = el.value;
emit('login', emailish(email) ? email : null);
}
};
};