Files
SHiNE-server/shine-UI/js/pages/registration-licenses-view.js
T

47 lines
3.4 KiB
JavaScript

import { t } from '../i18n/index.js';
import { createTopBar } from '../components/topbar.js';
import { state } from '../state.js';
const LICENSES = [
{ name: 'CC BY-NC 4.0', original: 'https://arweave.net/Xtym3vUAyt7OgFBINBh1ene-5360Ah76c6D-O9ywxVE', russian: 'https://creativecommons.org/licenses/by-nc/4.0/legalcode.ru' },
{ name: 'SCDL 1.0', original: 'https://arweave.net/NPckIo-nQUP2-ZM6PIoDYnx-6wwLeErH39jXCddOxPE', russian: './static-sites/licenses/SHiNE-SCDL-1.0-ru.html' },
];
export const pageMeta = { id: 'registration-licenses-view', get title() { return t('screens.registration_licenses.title'); }, showAppChrome: false };
export function render({ navigate }) {
const draft = state.registrationDraft;
const screen = document.createElement('section');
screen.className = 'stack registration-screen signup-wizard';
if (!['free', 'paid'].includes(draft.flowType) || !draft.login || !draft.preGeneratedKeyBundle || ![0, 1].includes(draft.accountType)) {
queueMicrotask(() => navigate('register-view'));
return screen;
}
const body = document.createElement('div');
body.className = 'card stack registration-form signup-wizard__body';
const back = () => navigate('register-view');
screen.append(createTopBar({ title: t('screens.registration_licenses.title'), back: { label: '←', onClick: back } }), body);
const heading = document.createElement('h1'); heading.className = 'signup-title'; heading.textContent = t('screens.registration_licenses.title'); body.append(heading);
const paragraph = (key, className = '') => { const p = document.createElement('p'); if (className) p.className = className; p.textContent = t(`screens.registration_licenses.${key}`); body.append(p); };
paragraph('intro'); paragraph('rights');
for (const [index, license] of LICENSES.entries()) {
const title = document.createElement('h2'); title.textContent = license.name; body.append(title);
paragraph(index === 0 ? 'cc_description' : 'scdl_description');
const links = document.createElement('p'); links.className = 'signup-guidance';
const original = document.createElement('a'); original.href = license.original; original.target = '_blank'; original.rel = 'noopener noreferrer'; original.textContent = t('screens.registration_licenses.original');
const russian = document.createElement('a'); russian.href = license.russian; russian.target = '_blank'; russian.rel = 'noopener noreferrer'; russian.textContent = t('screens.registration_licenses.russian');
links.append(original, document.createTextNode(' · '), russian); body.append(links);
}
const important = document.createElement('h2'); important.textContent = t('screens.registration_licenses.important'); body.append(important);
const list = document.createElement('ul');
for (const key of ['copyright', 'irrevocable', 'permanent', 'owned_rights', 'private_messages']) {
const item = document.createElement('li'); item.textContent = t(`screens.registration_licenses.${key}`); list.append(item);
}
body.append(list);
paragraph('confirmation'); paragraph('signature');
const accept = document.createElement('button'); accept.type = 'button'; accept.className = 'primary-btn signup-next'; accept.textContent = t('screens.registration_licenses.accept');
accept.addEventListener('click', () => { draft.licensesAccepted = true; navigate(draft.flowType === 'free' ? 'registration-email-view' : 'registration-payment-view'); });
body.append(accept);
return screen;
}