index.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. const html = require('choo/html');
  2. const downloadButton = require('../../templates/downloadButton');
  3. const downloadedFiles = require('../../templates/uploadedFileList');
  4. const split = require('../split');
  5. module.exports = function(state, emit) {
  6. const fileInfo = state.fileInfo;
  7. const trySendLink = html`
  8. <a class="link link--action" href="/">
  9. ${state.translate('sendYourFilesLink')}
  10. </a>`;
  11. const cancelButton = html`
  12. <button class="btn--cancel"
  13. onclick=${cancel}
  14. >
  15. ${state.translate('downloadCancel')}
  16. </button>
  17. `;
  18. const bottomLink =
  19. state.transfer.state === 'downloading' ? cancelButton : trySendLink;
  20. return split(
  21. state,
  22. emit,
  23. downloadedFiles(fileInfo, state, emit),
  24. html`
  25. <div class="copySection">
  26. <div class="description">${state.translate('downloadMessage2')}</div>
  27. ${downloadButton(state, emit)}
  28. ${bottomLink}
  29. </div>`
  30. );
  31. function cancel() {
  32. if (state.transfer.state === 'downloading') {
  33. emit('cancel');
  34. }
  35. }
  36. };