SHA256
HEADER v3, primary аккаунты и подтверждения
This commit is contained in:
@@ -12,7 +12,6 @@ import {
|
||||
PROFILE_GENDER_MALE,
|
||||
PROFILE_GENDER_UNKNOWN,
|
||||
PROFILE_ACCOUNT_ROLE_PRIMARY,
|
||||
PROFILE_ACCOUNT_ROLE_NON_VOTING,
|
||||
PROFILE_SHINE_SHINING,
|
||||
PROFILE_SHINE_UNKNOWN,
|
||||
loadProfileSnapshot,
|
||||
@@ -36,18 +35,6 @@ function shineStatusLabel(value) {
|
||||
|
||||
|
||||
|
||||
function officialSteps(firstName, lastName) {
|
||||
const name = `${firstName} ${lastName}`.trim();
|
||||
return [
|
||||
{ title: t('dialogs.final.consent.official_steps.odin_chelovek_odin_ofitsialnyy_akkaunt'), text: t('dialogs.final.consent.official_steps.ofitsialnyy_akkaunt_vashe_zayavlenie_chto_eto_vash') },
|
||||
{ title: t('dialogs.final.consent.official_steps.priznanie_zavisit_ot_drugih_lyudey'), text: t('dialogs.final.consent.official_steps.samo_zayavlenie_ne_delaet_lichnost_proverennoy_dru') },
|
||||
{ title: t('dialogs.final.consent.official_steps.istoriya_perezhivaet_akkaunt'), text: t('dialogs.final.consent.official_steps.esli_vy_poteryaete_dostup_mozhno_zaregistrirovat_n') },
|
||||
{ title: t('dialogs.final.consent.official_steps.eto_deystvitelno_vy'), text: t('dialogs.final.consent.official_steps.v_profile_ukazano_value1_podtverzhdayte_tolko_esli', { value1: name }), accept: t('dialogs.final.consent.official_steps.podtverzhdayu_chto_value1_moi_nastoyaschie_imya_i', { value1: name }) },
|
||||
{ title: t('dialogs.final.consent.official_steps.podtverzhdaya_drugih_otvechayte_za_svoi_slova'), text: t('dialogs.final.consent.official_steps.ofitsialnyy_akkaunt_mozhet_podtverzhdat_osnovnye_a'), accept: t('dialogs.final.consent.official_steps.ponimayu_otvetstvennost_za_svoi_podtverzhdeniya') },
|
||||
{ title: t('dialogs.final.consent.official_steps.publichnaya_zapis'), text: t('dialogs.final.consent.official_steps.zayavlenie_i_buduschie_podtverzhdeniya_popadayut_v'), accept: t('dialogs.final.consent.official_steps.ya_ponimayu_publichnost_i_dolgovremennoe_hranenie'), button: t('dialogs.final.consent.official_steps.stat_ofitsialnym') },
|
||||
];
|
||||
}
|
||||
|
||||
function shiningSteps() { return [
|
||||
{ title: t('dialogs.final.consent.shining_steps.siyayuschiy_ofitsialnyy'), text: t('dialogs.final.consent.shining_steps.otmetit_sebya_siyayuschim_mozhno_i_s_neofitsialnog') },
|
||||
{ title: t('dialogs.final.consent.shining_steps.chto_znachit_siyayuschiy'), text: t('dialogs.final.consent.shining_steps.v_shine_eto_chelovek_kotoryy_zanimaetsya_vnutrenni') },
|
||||
@@ -120,7 +107,7 @@ export function render({ navigate, chrome }) {
|
||||
const badgesRow = document.createElement('div');
|
||||
badgesRow.className = 'chip-row profile-edit-statuses';
|
||||
badgesRow.innerHTML = `
|
||||
<button class="chip profile-toggle-btn is-no" type="button" data-status="account_role">${th('screens.profile_edit_view.text_029')}</button>
|
||||
<span class="badge is-no" data-status="account_role">${th('screens.profile_edit_view.text_029')}</span>
|
||||
<button class="chip profile-toggle-btn is-no" type="button" data-status="shine">${th('screens.profile_edit_view.text_030')}</button>
|
||||
`;
|
||||
|
||||
@@ -138,6 +125,7 @@ export function render({ navigate, chrome }) {
|
||||
|
||||
let currentFields = [];
|
||||
let currentAccountRole = '';
|
||||
let currentAccountType = null;
|
||||
let currentShineStatus = '';
|
||||
let currentGender = PROFILE_GENDER_UNKNOWN;
|
||||
let statusFlowOpen = false;
|
||||
@@ -229,7 +217,9 @@ export function render({ navigate, chrome }) {
|
||||
|
||||
function updateStatusesUi() {
|
||||
if (accountRoleBtn) {
|
||||
accountRoleBtn.textContent = t('screens.profile_edit_view.text_020', { value1: accountRoleLabel(currentAccountRole) });
|
||||
accountRoleBtn.textContent = currentAccountType === 1 ? t('screens.profile_edit_view.text_009')
|
||||
: currentAccountType === 0 ? t('screens.registration_identity.alternative')
|
||||
: t('screens.profile_edit_view.text_020', { value1: accountRoleLabel(currentAccountRole) });
|
||||
accountRoleBtn.classList.remove('is-no', 'is-yes-official', 'is-yes-shine', 'is-not-interested');
|
||||
accountRoleBtn.classList.add(currentAccountRole === PROFILE_ACCOUNT_ROLE_PRIMARY ? 'is-yes-official' : 'is-no');
|
||||
}
|
||||
@@ -341,13 +331,13 @@ export function render({ navigate, chrome }) {
|
||||
status.className = 'status-line';
|
||||
status.textContent = t('dialogs.modals.profile_edit_view.label_003');
|
||||
reloadBtn.disabled = true;
|
||||
accountRoleBtn.disabled = true;
|
||||
shineBtn.disabled = true;
|
||||
|
||||
try {
|
||||
const snapshot = await loadProfileSnapshot(login);
|
||||
currentFields = snapshot.fields;
|
||||
currentAccountRole = snapshot.accountRole || '';
|
||||
currentAccountType = snapshot.accountType;
|
||||
currentShineStatus = snapshot.shineStatus || '';
|
||||
currentGender = snapshot.gender || PROFILE_GENDER_UNKNOWN;
|
||||
currentAvatar = snapshot.avatar || { value: '', source: '', txId: '', pr: '', timeMs: 0 };
|
||||
@@ -366,7 +356,6 @@ export function render({ navigate, chrome }) {
|
||||
showLocalErrorAlert(t('screens.profile_edit_view.text_007'), error);
|
||||
} finally {
|
||||
reloadBtn.disabled = false;
|
||||
accountRoleBtn.disabled = false;
|
||||
shineBtn.disabled = false;
|
||||
}
|
||||
}
|
||||
@@ -409,63 +398,28 @@ export function render({ navigate, chrome }) {
|
||||
}
|
||||
|
||||
async function onStatusClick(statusKey) {
|
||||
if (statusFlowOpen) return;
|
||||
if (statusKey !== 'shine' || statusFlowOpen) return;
|
||||
statusFlowOpen = true;
|
||||
try {
|
||||
const isAccountRole = statusKey === 'account_role';
|
||||
const alreadyOn = isAccountRole
|
||||
? currentAccountRole === PROFILE_ACCOUNT_ROLE_PRIMARY
|
||||
: currentShineStatus === PROFILE_SHINE_SHINING;
|
||||
let accepted = false;
|
||||
if (alreadyOn) {
|
||||
accepted = await confirmDialog({
|
||||
title: isAccountRole ? t('dialogs.final.consent.remove_official') : t('dialogs.final.consent.remove_shining'),
|
||||
text: t('dialogs.pages.profile_edit_view.text_001'),
|
||||
confirmLabel: t('dialogs.pages.profile_edit_view.confirmLabel_002'),
|
||||
});
|
||||
} else if (isAccountRole) {
|
||||
const firstName = String(currentFields.find((field) => field.key === 'first_name')?.value || '').trim();
|
||||
const lastName = String(currentFields.find((field) => field.key === 'last_name')?.value || '').trim();
|
||||
if (!firstName || !lastName) {
|
||||
await confirmDialog({
|
||||
title: t('dialogs.pages.profile_edit_view.title_003'),
|
||||
text: t('dialogs.pages.profile_edit_view.text_004'),
|
||||
confirmLabel: t('dialogs.pages.profile_edit_view.confirmLabel_005'),
|
||||
cancelLabel: t('dialogs.pages.profile_edit_view.cancelLabel_006'),
|
||||
});
|
||||
return;
|
||||
}
|
||||
accepted = await confirmConsentSteps({ title: t('dialogs.final.consent.official_title'), steps: officialSteps(firstName, lastName) });
|
||||
} else {
|
||||
accepted = await confirmConsentSteps({ title: t('dialogs.final.consent.shining_title'), steps: shiningSteps() });
|
||||
}
|
||||
const alreadyOn = currentShineStatus === PROFILE_SHINE_SHINING;
|
||||
const accepted = alreadyOn ? await confirmDialog({
|
||||
title: t('dialogs.final.consent.remove_shining'), text: t('dialogs.pages.profile_edit_view.text_001'),
|
||||
confirmLabel: t('dialogs.pages.profile_edit_view.confirmLabel_002'),
|
||||
}) : await confirmConsentSteps({ title: t('dialogs.final.consent.shining_title'), steps: shiningSteps() });
|
||||
if (!accepted || !screen.isConnected) return;
|
||||
const nextValue = isAccountRole
|
||||
? (alreadyOn ? PROFILE_ACCOUNT_ROLE_NON_VOTING : PROFILE_ACCOUNT_ROLE_PRIMARY)
|
||||
: (alreadyOn ? PROFILE_SHINE_UNKNOWN : PROFILE_SHINE_SHINING);
|
||||
status.className = 'status-line';
|
||||
status.textContent = t('dialogs.modals.profile_edit_view.label_009');
|
||||
accountRoleBtn.disabled = true;
|
||||
status.className = 'status-line'; status.textContent = t('dialogs.modals.profile_edit_view.label_009');
|
||||
shineBtn.disabled = true;
|
||||
try {
|
||||
await saveProfileStatus(login, statusKey, nextValue);
|
||||
if (!screen.isConnected) return;
|
||||
await refreshProfileSnapshot();
|
||||
await saveProfileStatus(login, 'shine', alreadyOn ? PROFILE_SHINE_UNKNOWN : PROFILE_SHINE_SHINING);
|
||||
if (screen.isConnected) await refreshProfileSnapshot();
|
||||
} catch (error) {
|
||||
if (!screen.isConnected) return;
|
||||
status.className = 'status-line is-unavailable';
|
||||
const what = isAccountRole ? t('screens.profile_edit_view.text_017') : t('screens.profile_edit_view.text_018');
|
||||
const what = t('screens.profile_edit_view.text_018');
|
||||
status.textContent = t('screens.profile_edit_view.text_022', { value1: what, value2: toUserMessage(error, t('dialogs.modals.profile_edit_view.label_010')) });
|
||||
showLocalErrorAlert(t('screens.profile_edit_view.text_023', { value1: what }), error);
|
||||
} finally {
|
||||
if (screen.isConnected) {
|
||||
accountRoleBtn.disabled = false;
|
||||
shineBtn.disabled = false;
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
statusFlowOpen = false;
|
||||
}
|
||||
} finally { if (screen.isConnected) shineBtn.disabled = false; }
|
||||
} finally { statusFlowOpen = false; }
|
||||
}
|
||||
|
||||
async function onEditFieldClick(fieldKey) {
|
||||
@@ -547,7 +501,7 @@ export function render({ navigate, chrome }) {
|
||||
});
|
||||
|
||||
reloadBtn.addEventListener('click', refreshProfileSnapshot);
|
||||
accountRoleBtn.addEventListener('click', () => onStatusClick('account_role'));
|
||||
accountRoleBtn.title = t('screens.registration_identity.immutable');
|
||||
shineBtn.addEventListener('click', () => onStatusClick('shine'));
|
||||
avatarActionEl?.addEventListener('click', () => { void onChangeAvatarClick(); });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user