send/app/ui/signupDialog.js

90 lines
3 KiB
JavaScript
Raw Normal View History

2018-10-25 02:07:10 +00:00
const html = require('choo/html');
2019-03-01 20:56:10 +00:00
const assets = require('../../common/assets');
const { bytes } = require('../utils');
2018-10-25 02:07:10 +00:00
2021-03-15 18:56:51 +00:00
module.exports = function() {
2018-10-25 02:07:10 +00:00
return function(state, emit, close) {
const DAYS = Math.floor(state.LIMITS.MAX_EXPIRE_SECONDS / 86400);
let submitting = false;
2018-10-25 02:07:10 +00:00
return html`
2019-03-01 20:56:10 +00:00
<send-signup-dialog
class="flex flex-col justify-center my-16 md:my-0 px-8 md:px-24 w-full h-full"
2019-03-01 20:56:10 +00:00
>
2019-05-30 02:22:03 +00:00
<img src="${assets.get('master-logo.svg')}" class="h-16 mt-1 mb-4" />
<section class="flex flex-col flex-shrink-0 self-center">
<h1 class="text-3xl font-bold text-center">
${state.translate('accountBenefitTitle')}
</h1>
<ul
2019-09-09 17:34:55 +00:00
class="leading-normal list-disc text-grey-80 my-2 mt-4 pl-4 md:self-center dark:text-grey-40"
>
2019-03-01 20:56:10 +00:00
<li>
${state.translate('accountBenefitLargeFiles', {
size: bytes(state.LIMITS.MAX_FILE_SIZE)
})}
</li>
<li>${state.translate('accountBenefitDownloadCount')}</li>
2019-03-01 20:56:10 +00:00
<li>
${state.translate('accountBenefitTimeLimit', { count: DAYS })}
2019-03-01 20:56:10 +00:00
</li>
<li>${state.translate('accountBenefitSync')}</li>
</ul>
</section>
<section class="flex flex-col flex-grow m-4 md:self-center md:w-128">
2019-03-01 20:56:10 +00:00
<form onsubmit=${submitEmail} data-no-csrf>
<input
id="email-input"
2019-03-03 01:05:58 +00:00
type="email"
class="hidden border rounded-lg w-full px-2 py-1 h-12 mb-3 text-lg text-grey-70 leading-loose dark:bg-grey-80 dark:text-white"
placeholder=${state.translate('emailPlaceholder')}
2019-03-01 20:56:10 +00:00
/>
<input
2019-06-14 18:30:43 +00:00
class="btn rounded-lg w-full flex flex-shrink-0 items-center justify-center"
value="${state.translate('signInOnlyButton')}"
title="${state.translate('signInOnlyButton')}"
2019-03-01 20:56:10 +00:00
id="email-submit"
type="submit"
/>
</form>
${state.user.loginRequired
? ''
: html`
<button
class="my-3 link-blue font-medium"
title="${state.translate('deletePopupCancel')}"
onclick=${cancel}
>
${state.translate('deletePopupCancel')}
</button>
`}
2019-03-01 20:56:10 +00:00
</section>
</send-signup-dialog>
`;
2018-10-25 02:07:10 +00:00
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);
}
2019-02-12 19:50:06 +00:00
function cancel(event) {
close(event);
}
2018-10-25 02:07:10 +00:00
function submitEmail(event) {
event.preventDefault();
if (submitting) {
return;
}
submitting = true;
2018-10-25 02:07:10 +00:00
const el = document.getElementById('email-input');
const email = el.value;
emit('login', emailish(email) ? email : null);
2018-10-25 02:07:10 +00:00
}
};
};