Ограничить бесплатную регистрацию namespace сервера

This commit is contained in:
AidarKC
2026-11-21 01:09:37 +03:00
parent 792f368175
commit 80c70ebcdc
8 changed files with 101 additions and 20 deletions
+17 -8
View File
@@ -1,6 +1,7 @@
import { t } from '../i18n/index.js';
import { createTopBar } from '../components/topbar.js';
import { resetRegistrationFlow, state } from '../state.js';
import { getRegistrationNamespaces } from '../services/registration-v2-api.js';
export const pageMeta = { id: 'registration-choice-view', get title() { return t('screens.registration_choice_view.text_001'); }, showAppChrome: false };
@@ -55,23 +56,31 @@ export function render({ navigate }) {
box.append(top, description, list, action);
return box;
}
screen.append(
createTopBar({ title: t('screens.registration_choice_view.text_004'), back: { label: '←', onClick: () => navigate('registration-intro-view') } }),
title, intro,
card({
const topBar = createTopBar({ title: t('screens.registration_choice_view.text_004'), back: { label: '←', onClick: () => navigate('registration-intro-view') } });
const plans = document.createElement('div');
plans.className = 'stack';
const paidCard = card({
type: 'paid', icon: '◇', heading: t('screens.registration_choice_view.text_005'),
price: t('screens.registration_choice_view.text_007'),
lead: t('screens.registration_choice_view.text_008'),
perks: [t('screens.registration_choice_view.text_009'), t('screens.registration_choice_view.text_010'), t('screens.registration_choice_view.text_011')],
button: t('screens.registration_choice_view.text_012'),
}),
card({
});
plans.append(paidCard);
screen.append(topBar, title, intro, plans);
// Бесплатная регистрация доступна только если текущий сервер сам объявил
// привязанный к нему type-2 namespace. При ошибке запроса безопасно оставляем
// только платный сценарий.
void getRegistrationNamespaces().then(({ namespaces }) => {
if (!screen.isConnected || !Array.isArray(namespaces) || !namespaces.some(n => Number(n.type) === 2)) return;
plans.append(card({
type: 'free', icon: '♧', heading: t('screens.registration_choice_view.text_006'),
price: t('screens.registration_choice_view.text_013'),
lead: t('screens.registration_choice_view.text_014'),
perks: [t('screens.registration_choice_view.text_015'), t('screens.registration_choice_view.text_016'), t('screens.registration_choice_view.text_017')],
button: t('screens.registration_choice_view.text_018'),
}),
);
}));
});
return screen;
}