import { createTopBar } from '../components/topbar.js'; import { state } from '../state.js'; export const pageMeta = { id: 'registration-choice-view', title: 'Тип аккаунта', showAppChrome: false }; export function render({ navigate }) { const screen = document.createElement('section'); screen.className = 'stack registration-screen signup-choice'; const title = document.createElement('h1'); title.className = 'signup-title'; title.textContent = 'Выберите тип аккаунта'; const intro = document.createElement('p'); intro.className = 'signup-lead'; intro.textContent = 'Выберите способ регистрации. Полноценный аккаунт независим от одного сервера.'; function card({ type, icon, heading, price, lead, perks, button }) { const box = document.createElement('article'); box.className = `signup-plan signup-plan--${type}`; const top = document.createElement('div'); top.className = 'signup-plan__top'; const symbol = document.createElement('span'); symbol.className = 'signup-plan__symbol'; symbol.textContent = icon; const header = document.createElement('div'); const name = document.createElement('h2'); name.textContent = heading; const cost = document.createElement('p'); cost.className = 'signup-plan__price'; cost.textContent = price; header.append(name, cost); top.append(symbol, header); const description = document.createElement('p'); description.className = 'signup-plan__lead'; description.textContent = lead; const list = document.createElement('ul'); for (const perk of perks) { const li = document.createElement('li'); li.textContent = perk; list.append(li); } const action = document.createElement('button'); action.type = 'button'; action.className = type === 'paid' ? 'primary-btn' : 'secondary-btn'; action.textContent = button; action.addEventListener('click', () => { const draft = state.registrationDraft; if (draft.flowType !== type) { // При смене namespace старые ключи/коды больше не соответствуют выбранному аккаунту. draft.login = ''; draft.password = ''; draft.preGeneratedKeyBundle = null; draft.challengeId = ''; draft.challengeExpiresAtMs = 0; draft.email = ''; } draft.flowType = type; draft.uiStep = 1; navigate('register-view'); }); box.append(top, description, list, action); return box; } screen.append( createTopBar({ title: 'Регистрация в Сиянии', back: { label: '←', onClick: () => navigate('registration-intro-view') } }), title, intro, card({ type: 'paid', icon: '◇', heading: 'Зарегистрировать полноценный аккаунт', price: '≈ 0,02 SOL · разовая оплата', lead: 'Оплата создания личной записи (PDA) в блокчейне Solana. Точная сумма рассчитывается перед оплатой.', perks: ['Аккаунт не привязан к одному серверу Сияния.', 'Можно переходить между серверами или запустить собственный.', 'Поддерживается смена пароля.'], button: 'Выбрать полноценный аккаунт', }), card({ type: 'free', icon: '♧', heading: 'Зарегистрироваться бесплатно', price: '0 SOL · бесплатно', lead: 'Регистрация подтверждается ключом этого сервера и не требует оплаты.', perks: ['Аккаунт работает только через сервер доступа, который подтвердил регистрацию.', 'Смена пароля недоступна.', 'В любой момент можно оплатить полноценную регистрацию и получить полные возможности.'], button: 'Зарегистрироваться бесплатно', }), ); return screen; }