Merge branch 'codex/add-personal-data-to-blockchain-api'
# Conflicts: # shine-UI/js/pages/profile-view.js # shine-UI/js/services/auth-service.js # task/2.md
This commit is contained in:
commit
3a412fcd51
@ -1,20 +1,33 @@
|
||||
import { renderHeader } from '../components/header.js?v=20260405171816';
|
||||
import { profile } from '../mock-data.js?v=20260405171816';
|
||||
import { state } from '../state.js?v=20260405171816';
|
||||
import {
|
||||
loadProfileSnapshot,
|
||||
profileFieldDefs,
|
||||
saveProfileParams,
|
||||
saveProfileToggle,
|
||||
} from '../services/user-profile-params.js?v=20260405171816';
|
||||
|
||||
export const pageMeta = { id: 'profile-view', title: 'Профиль' };
|
||||
|
||||
function formatDateTime(timeMs) {
|
||||
if (!timeMs) return 'ещё не заполнено';
|
||||
return new Date(timeMs).toLocaleString('ru-RU');
|
||||
}
|
||||
|
||||
function getDisplayName(fieldMap) {
|
||||
const firstName = fieldMap.get('first_name')?.value?.trim() || '';
|
||||
const lastName = fieldMap.get('last_name')?.value?.trim() || '';
|
||||
const fullName = `${firstName} ${lastName}`.trim();
|
||||
return fullName || profile.name;
|
||||
}
|
||||
|
||||
function toggleText(enabled) {
|
||||
return enabled ? 'yes' : 'no';
|
||||
}
|
||||
|
||||
export function render({ navigate }) {
|
||||
const badgeHelp = {
|
||||
official: {
|
||||
title: 'Официальный аккаунт',
|
||||
text: 'Эта настройка включает или отключает отметку официального аккаунта в профиле. Используйте её, когда нужно показать или скрыть подтверждённый статус.',
|
||||
},
|
||||
shine: {
|
||||
title: 'Сияющий',
|
||||
text: 'Этот переключатель включает или отключает режим «Сияющий». Он управляет отображением дополнительного визуального акцента для профиля.',
|
||||
},
|
||||
};
|
||||
const login = state.session.login || profile.login;
|
||||
|
||||
const screen = document.createElement('section');
|
||||
screen.className = 'stack';
|
||||
@ -26,83 +39,223 @@ export function render({ navigate }) {
|
||||
{ label: 'Кошелёк', onClick: () => navigate('wallet-view') },
|
||||
{ label: 'Настройки', onClick: () => navigate('settings-view') },
|
||||
],
|
||||
})
|
||||
}),
|
||||
);
|
||||
|
||||
const card = document.createElement('div');
|
||||
card.className = 'card stack';
|
||||
card.innerHTML = `
|
||||
<div class="row">
|
||||
|
||||
const topRow = document.createElement('div');
|
||||
topRow.className = 'row';
|
||||
topRow.innerHTML = `
|
||||
<div class="row" style="gap:12px; align-items:center;">
|
||||
<div class="avatar large">${profile.avatarInitials}</div>
|
||||
<div class="stack" style="justify-items:end; text-align:right;">
|
||||
<button class="badge profile-badge-trigger" type="button" data-badge="official">✔ ${profile.badges[0]}</button>
|
||||
<button class="badge alt profile-badge-trigger" type="button" data-badge="shine">✨ ${profile.badges[1]}</button>
|
||||
</div>
|
||||
</div>
|
||||
<div>
|
||||
<h2 style="font-size:22px; margin-bottom:2px;">${profile.name}</h2>
|
||||
<p class="meta-muted">${state.session.login || profile.login}</p>
|
||||
<h2 style="font-size:22px; margin-bottom:2px;" data-profile-name="true">${profile.name}</h2>
|
||||
<p class="meta-muted">${login}</p>
|
||||
</div>
|
||||
<div class="stack" style="gap:8px;">
|
||||
<div class="card" style="padding:10px;"><span class="meta-muted">Телефон:</span> ${profile.phone}</div>
|
||||
<div class="card" style="padding:10px;"><span class="meta-muted">Адрес:</span> ${profile.address}</div>
|
||||
<div class="card" style="padding:10px;"><span class="meta-muted">Email:</span> ${profile.email}</div>
|
||||
<div class="card" style="padding:10px;"><span class="meta-muted">Соцсети:</span> ${profile.socials}</div>
|
||||
</div>
|
||||
<button class="primary-btn" type="button" data-open-edit="true">Обновить</button>
|
||||
`;
|
||||
|
||||
const modal = document.createElement('div');
|
||||
modal.className = 'profile-help-modal';
|
||||
modal.hidden = true;
|
||||
modal.innerHTML = `
|
||||
const badgesRow = document.createElement('div');
|
||||
badgesRow.className = 'row';
|
||||
badgesRow.innerHTML = `
|
||||
<button class="badge profile-toggle-btn" type="button" data-toggle="official">✔ Официальный: no</button>
|
||||
<button class="badge alt profile-toggle-btn" type="button" data-toggle="shine">✨ Сияющий: no</button>
|
||||
`;
|
||||
|
||||
const hint = document.createElement('div');
|
||||
hint.className = 'card profile-data-help';
|
||||
hint.innerHTML = `
|
||||
<div class="meta-muted">Личные данные пользователя</div>
|
||||
<p>Поля ниже читаются из реальных пользовательских параметров сервера (ListUserParams). Любое изменение отправляется как блокчейн-запись параметра и требует подпись ключом пользователя.</p>
|
||||
`;
|
||||
|
||||
const status = document.createElement('div');
|
||||
status.className = 'status-line';
|
||||
status.textContent = 'Загрузка параметров...';
|
||||
|
||||
const listWrap = document.createElement('div');
|
||||
listWrap.className = 'stack profile-param-list';
|
||||
|
||||
const editModal = document.createElement('div');
|
||||
editModal.className = 'profile-help-modal';
|
||||
editModal.hidden = true;
|
||||
editModal.innerHTML = `
|
||||
<div class="profile-help-backdrop" data-close="true"></div>
|
||||
<div class="profile-help-dialog card" role="dialog" aria-modal="true" aria-labelledby="profile-help-title" tabindex="-1">
|
||||
<div class="profile-help-dialog card" role="dialog" aria-modal="true" aria-labelledby="profile-edit-title" tabindex="-1">
|
||||
<div class="row" style="align-items:flex-start;">
|
||||
<div>
|
||||
<div class="meta-muted" style="margin-bottom:4px;">Управление функцией</div>
|
||||
<h3 id="profile-help-title" style="font-size:18px;"></h3>
|
||||
<div class="meta-muted" style="margin-bottom:4px;">Обновление личных данных</div>
|
||||
<h3 id="profile-edit-title" style="font-size:18px;">Редактирование профиля</h3>
|
||||
</div>
|
||||
<button class="icon-btn profile-help-close" type="button" aria-label="Закрыть">✕</button>
|
||||
</div>
|
||||
<p class="profile-help-text"></p>
|
||||
<p class="profile-help-text">После сохранения по каждому полю отправляется запись параметра в блокчейн. Для подписи используется ключ пользователя на устройстве.</p>
|
||||
<form class="stack" data-profile-form="true"></form>
|
||||
<div class="row">
|
||||
<button class="ghost-btn" type="button" data-cancel-edit="true">Отмена</button>
|
||||
<button class="primary-btn" type="button" data-save-profile="true">Сохранить</button>
|
||||
</div>
|
||||
</div>
|
||||
`;
|
||||
|
||||
const titleEl = modal.querySelector('#profile-help-title');
|
||||
const textEl = modal.querySelector('.profile-help-text');
|
||||
const dialogEl = modal.querySelector('.profile-help-dialog');
|
||||
const profileNameEl = topRow.querySelector('[data-profile-name="true"]');
|
||||
const openEditBtn = topRow.querySelector('[data-open-edit="true"]');
|
||||
const officialBtn = badgesRow.querySelector('[data-toggle="official"]');
|
||||
const shineBtn = badgesRow.querySelector('[data-toggle="shine"]');
|
||||
const formEl = editModal.querySelector('[data-profile-form="true"]');
|
||||
const dialogEl = editModal.querySelector('.profile-help-dialog');
|
||||
const saveBtn = editModal.querySelector('[data-save-profile="true"]');
|
||||
|
||||
function closeModal() {
|
||||
modal.hidden = true;
|
||||
let currentFields = profileFieldDefs.map((field) => ({ ...field, value: '', timeMs: 0 }));
|
||||
let currentToggles = [
|
||||
{ key: 'official', enabled: false, timeMs: 0 },
|
||||
{ key: 'shine', enabled: false, timeMs: 0 },
|
||||
];
|
||||
|
||||
function updateTogglesUi() {
|
||||
const official = currentToggles.find((item) => item.key === 'official') || { enabled: false };
|
||||
const shine = currentToggles.find((item) => item.key === 'shine') || { enabled: false };
|
||||
|
||||
officialBtn.textContent = `✔ Официальный: ${toggleText(official.enabled)}`;
|
||||
shineBtn.textContent = `✨ Сияющий: ${toggleText(shine.enabled)}`;
|
||||
}
|
||||
|
||||
function openModal(type) {
|
||||
const content = badgeHelp[type];
|
||||
if (!content) return;
|
||||
function renderFields(fields) {
|
||||
const fieldMap = new Map(fields.map((field) => [field.key, field]));
|
||||
profileNameEl.textContent = getDisplayName(fieldMap);
|
||||
|
||||
titleEl.textContent = content.title;
|
||||
textEl.textContent = content.text;
|
||||
modal.hidden = false;
|
||||
listWrap.innerHTML = '';
|
||||
fields.forEach((field) => {
|
||||
const row = document.createElement('div');
|
||||
row.className = 'card profile-param-item';
|
||||
row.innerHTML = `
|
||||
<div class="profile-param-head">
|
||||
<span class="meta-muted">${field.label}</span>
|
||||
<span class="meta-muted">${field.key}</span>
|
||||
</div>
|
||||
<div class="profile-param-value">${field.value || '—'}</div>
|
||||
<div class="meta-muted profile-param-time">Обновлено: ${formatDateTime(field.timeMs)}</div>
|
||||
`;
|
||||
listWrap.append(row);
|
||||
});
|
||||
}
|
||||
|
||||
async function refreshProfileSnapshot() {
|
||||
status.className = 'status-line';
|
||||
status.textContent = 'Загрузка параметров...';
|
||||
openEditBtn.disabled = true;
|
||||
officialBtn.disabled = true;
|
||||
shineBtn.disabled = true;
|
||||
|
||||
try {
|
||||
const snapshot = await loadProfileSnapshot(login);
|
||||
currentFields = snapshot.fields;
|
||||
currentToggles = snapshot.toggles;
|
||||
renderFields(snapshot.fields);
|
||||
updateTogglesUi();
|
||||
status.className = 'status-line is-available';
|
||||
status.textContent = 'Актуальные параметры загружены с сервера.';
|
||||
} catch (error) {
|
||||
renderFields(currentFields);
|
||||
updateTogglesUi();
|
||||
status.className = 'status-line is-unavailable';
|
||||
status.textContent = `Не удалось загрузить параметры: ${error.message || 'ошибка сети'}`;
|
||||
} finally {
|
||||
openEditBtn.disabled = false;
|
||||
officialBtn.disabled = false;
|
||||
shineBtn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
function closeEditModal() {
|
||||
editModal.hidden = true;
|
||||
}
|
||||
|
||||
function openEditModal() {
|
||||
formEl.innerHTML = '';
|
||||
|
||||
currentFields.forEach((field) => {
|
||||
const fieldWrap = document.createElement('label');
|
||||
fieldWrap.className = 'stack';
|
||||
fieldWrap.innerHTML = `
|
||||
<span class="field-label">${field.label}</span>
|
||||
<input class="input" type="text" name="${field.key}" placeholder="${field.placeholder || ''}" value="${field.value || ''}" />
|
||||
`;
|
||||
formEl.append(fieldWrap);
|
||||
});
|
||||
|
||||
editModal.hidden = false;
|
||||
dialogEl.focus();
|
||||
}
|
||||
|
||||
card.querySelectorAll('.profile-badge-trigger').forEach((button) => {
|
||||
button.addEventListener('click', () => openModal(button.dataset.badge));
|
||||
async function saveChanges() {
|
||||
const valuesByKey = {};
|
||||
currentFields.forEach((field) => {
|
||||
const input = formEl.querySelector(`input[name="${field.key}"]`);
|
||||
valuesByKey[field.key] = input instanceof HTMLInputElement ? input.value : '';
|
||||
});
|
||||
|
||||
modal.addEventListener('click', (event) => {
|
||||
saveBtn.disabled = true;
|
||||
try {
|
||||
await saveProfileParams(login, valuesByKey);
|
||||
closeEditModal();
|
||||
await refreshProfileSnapshot();
|
||||
} catch (error) {
|
||||
status.className = 'status-line is-unavailable';
|
||||
status.textContent = `Не удалось сохранить: ${error.message || 'ошибка сети'}`;
|
||||
} finally {
|
||||
saveBtn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
async function onToggleClick(toggleKey) {
|
||||
const toggle = currentToggles.find((item) => item.key === toggleKey) || { enabled: false };
|
||||
const nextEnabled = !toggle.enabled;
|
||||
const title = toggleKey === 'official' ? 'Официальный аккаунт' : 'Сияющий аккаунт';
|
||||
|
||||
const confirmed = window.confirm(
|
||||
`Изменить параметр «${title}» на ${toggleText(nextEnabled)}?\n\n` +
|
||||
'Внимание: изменение будет записано как блокчейн-параметр пользователя и требует подписи ключом блокчейна/пользователя на устройстве.',
|
||||
);
|
||||
|
||||
if (!confirmed) return;
|
||||
|
||||
status.className = 'status-line';
|
||||
status.textContent = 'Отправка изменения в блокчейн...';
|
||||
|
||||
try {
|
||||
await saveProfileToggle(login, toggleKey, nextEnabled);
|
||||
await refreshProfileSnapshot();
|
||||
} catch (error) {
|
||||
status.className = 'status-line is-unavailable';
|
||||
status.textContent = `Не удалось изменить ${toggleKey}: ${error.message || 'ошибка сети'}`;
|
||||
}
|
||||
}
|
||||
|
||||
openEditBtn.addEventListener('click', openEditModal);
|
||||
saveBtn.addEventListener('click', saveChanges);
|
||||
officialBtn.addEventListener('click', () => onToggleClick('official'));
|
||||
shineBtn.addEventListener('click', () => onToggleClick('shine'));
|
||||
editModal.querySelector('[data-cancel-edit="true"]').addEventListener('click', closeEditModal);
|
||||
|
||||
editModal.addEventListener('click', (event) => {
|
||||
const target = event.target;
|
||||
if (target instanceof HTMLElement && (target.dataset.close === 'true' || target.classList.contains('profile-help-close'))) {
|
||||
closeModal();
|
||||
closeEditModal();
|
||||
}
|
||||
});
|
||||
|
||||
modal.addEventListener('keydown', (event) => {
|
||||
if (event.key === 'Escape') {
|
||||
closeModal();
|
||||
}
|
||||
editModal.addEventListener('keydown', (event) => {
|
||||
if (event.key === 'Escape') closeEditModal();
|
||||
});
|
||||
|
||||
screen.append(card, modal);
|
||||
card.append(topRow, badgesRow, hint, status, listWrap);
|
||||
screen.append(card, editModal);
|
||||
|
||||
refreshProfileSnapshot();
|
||||
|
||||
return screen;
|
||||
}
|
||||
|
||||
@ -8,9 +8,15 @@ import {
|
||||
randomBase64,
|
||||
signBase64,
|
||||
} from './crypto-utils.js?v=20260405171816';
|
||||
import { loadSessionMaterial, saveEncryptedUserSecrets, saveSessionMaterial } from './key-vault.js?v=20260405171816';
|
||||
import {
|
||||
loadEncryptedUserSecrets,
|
||||
loadSessionMaterial,
|
||||
saveEncryptedUserSecrets,
|
||||
saveSessionMaterial,
|
||||
} from './key-vault.js?v=20260405171816';
|
||||
|
||||
const BCH_SUFFIX = '001';
|
||||
const USER_PARAMETER_PREFIX = 'SHiNe/UserParameter:';
|
||||
|
||||
function normalizeServerUrl(url) {
|
||||
const value = (url || '').trim();
|
||||
@ -283,6 +289,50 @@ export class AuthService {
|
||||
return response.payload?.logins || [];
|
||||
}
|
||||
|
||||
async listUserParams(login) {
|
||||
const cleanLogin = (login || '').trim();
|
||||
if (!cleanLogin) throw new Error('Не передан login');
|
||||
const response = await this.ws.request('ListUserParams', { login: cleanLogin });
|
||||
if (response.status !== 200) throw opError('ListUserParams', response);
|
||||
return response.payload || {};
|
||||
}
|
||||
|
||||
async upsertUserParam({ login, param, value, timeMs = Date.now(), storagePwd }) {
|
||||
const cleanLogin = (login || '').trim();
|
||||
const cleanParam = (param || '').trim();
|
||||
if (!cleanLogin || !cleanParam) throw new Error('Не переданы login/param');
|
||||
if (!storagePwd) throw new Error('Не передан storagePwd для подписи UserParam');
|
||||
|
||||
const user = await this.getUser(cleanLogin);
|
||||
const deviceKey = String(user?.deviceKey || '').trim();
|
||||
if (!deviceKey) {
|
||||
throw new Error('GetUser не вернул deviceKey для подписи UserParam');
|
||||
}
|
||||
|
||||
const savedKeys = await loadEncryptedUserSecrets(cleanLogin, storagePwd);
|
||||
const devicePrivatePkcs8 = savedKeys?.deviceKey;
|
||||
if (!devicePrivatePkcs8) {
|
||||
throw new Error('На устройстве нет сохраненного приватного deviceKey');
|
||||
}
|
||||
|
||||
const privateKey = await importPkcs8Ed25519(devicePrivatePkcs8);
|
||||
const cleanValue = String(value ?? '');
|
||||
const signText = `${USER_PARAMETER_PREFIX}${cleanLogin}${cleanParam}${timeMs}${cleanValue}`;
|
||||
const signature = await signBase64(privateKey, signText);
|
||||
|
||||
const response = await this.ws.request('UpsertUserParam', {
|
||||
login: cleanLogin,
|
||||
param: cleanParam,
|
||||
time_ms: Number(timeMs),
|
||||
value: cleanValue,
|
||||
device_key: deviceKey,
|
||||
signature,
|
||||
});
|
||||
|
||||
if (response.status !== 200) throw opError('UpsertUserParam', response);
|
||||
return response.payload || {};
|
||||
}
|
||||
|
||||
async reportClientError(details) {
|
||||
try {
|
||||
const response = await this.ws.request('ClientErrorLog', details || {}, 3000);
|
||||
|
||||
106
shine-UI/js/services/user-profile-params.js
Normal file
106
shine-UI/js/services/user-profile-params.js
Normal file
@ -0,0 +1,106 @@
|
||||
import { authService, state } from '../state.js?v=20260403081123';
|
||||
|
||||
export const profileFieldDefs = [
|
||||
{ key: 'first_name', readKeys: ['first_name', 'name'], label: 'First name', placeholder: 'Введите имя' },
|
||||
{ key: 'last_name', readKeys: ['last_name'], label: 'Last name', placeholder: 'Введите фамилию' },
|
||||
{ key: 'address_physical', readKeys: ['address_physical'], label: 'Address physical', placeholder: 'Город, улица, дом' },
|
||||
{ key: 'address_web', readKeys: ['address_web'], label: 'Address web', placeholder: 'Сайт или профиль' },
|
||||
{ key: 'phone', readKeys: ['phone'], label: 'Phone', placeholder: '+7 ...' },
|
||||
];
|
||||
|
||||
export const profileToggleDefs = [
|
||||
{ key: 'official', label: 'Официальный' },
|
||||
{ key: 'shine', label: 'Сияющий' },
|
||||
];
|
||||
|
||||
function normalizeItems(responsePayload) {
|
||||
const params = responsePayload?.params;
|
||||
if (!Array.isArray(params)) return [];
|
||||
return params
|
||||
.map((item) => ({
|
||||
param: String(item?.param || '').trim(),
|
||||
value: String(item?.value || ''),
|
||||
timeMs: Number(item?.time_ms || 0),
|
||||
}))
|
||||
.filter((item) => item.param);
|
||||
}
|
||||
|
||||
function getLatestByAliases(items, aliases) {
|
||||
let latest = null;
|
||||
items.forEach((item) => {
|
||||
if (!aliases.includes(item.param)) return;
|
||||
if (!latest || item.timeMs >= latest.timeMs) {
|
||||
latest = item;
|
||||
}
|
||||
});
|
||||
return latest;
|
||||
}
|
||||
|
||||
function parseToggleValue(value) {
|
||||
const normalized = String(value || '').trim().toLowerCase();
|
||||
return normalized === 'true' || normalized === 'yes' || normalized === '1';
|
||||
}
|
||||
|
||||
async function getStoragePwd() {
|
||||
const storagePwd = state.session.storagePwdInMemory;
|
||||
if (!storagePwd) {
|
||||
throw new Error('Нет storagePwd в памяти сессии. Выполните вход заново.');
|
||||
}
|
||||
return storagePwd;
|
||||
}
|
||||
|
||||
export async function loadProfileSnapshot(login) {
|
||||
const payload = await authService.listUserParams(login);
|
||||
const items = normalizeItems(payload);
|
||||
|
||||
const fields = profileFieldDefs.map((field) => {
|
||||
const latest = getLatestByAliases(items, field.readKeys);
|
||||
return {
|
||||
key: field.key,
|
||||
label: field.label,
|
||||
placeholder: field.placeholder,
|
||||
value: latest?.value || '',
|
||||
timeMs: latest?.timeMs || 0,
|
||||
};
|
||||
});
|
||||
|
||||
const toggles = profileToggleDefs.map((toggle) => {
|
||||
const latest = getLatestByAliases(items, [toggle.key]);
|
||||
return {
|
||||
key: toggle.key,
|
||||
label: toggle.label,
|
||||
enabled: latest ? parseToggleValue(latest.value) : false,
|
||||
rawValue: latest?.value || 'no',
|
||||
timeMs: latest?.timeMs || 0,
|
||||
};
|
||||
});
|
||||
|
||||
return { fields, toggles };
|
||||
}
|
||||
|
||||
export async function saveProfileParams(login, valuesByKey) {
|
||||
const storagePwd = await getStoragePwd();
|
||||
const baseTime = Date.now();
|
||||
|
||||
for (let i = 0; i < profileFieldDefs.length; i += 1) {
|
||||
const field = profileFieldDefs[i];
|
||||
await authService.upsertUserParam({
|
||||
login,
|
||||
param: field.key,
|
||||
value: String(valuesByKey[field.key] || '').trim(),
|
||||
timeMs: baseTime + i,
|
||||
storagePwd,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
export async function saveProfileToggle(login, key, enabled) {
|
||||
const storagePwd = await getStoragePwd();
|
||||
await authService.upsertUserParam({
|
||||
login,
|
||||
param: key,
|
||||
value: enabled ? 'yes' : 'no',
|
||||
timeMs: Date.now(),
|
||||
storagePwd,
|
||||
});
|
||||
}
|
||||
@ -131,6 +131,38 @@
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
|
||||
.profile-data-help p {
|
||||
margin-top: 6px;
|
||||
line-height: 1.4;
|
||||
color: #d8e3ff;
|
||||
}
|
||||
|
||||
.profile-param-list {
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.profile-param-item {
|
||||
padding: 10px;
|
||||
gap: 6px;
|
||||
}
|
||||
|
||||
.profile-param-head {
|
||||
display: flex;
|
||||
justify-content: space-between;
|
||||
gap: 8px;
|
||||
}
|
||||
|
||||
.profile-param-value {
|
||||
font-size: 15px;
|
||||
color: #eef3ff;
|
||||
word-break: break-word;
|
||||
}
|
||||
|
||||
.profile-param-time {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.auth-screen {
|
||||
min-height: calc(100dvh - 48px - env(safe-area-inset-bottom));
|
||||
display: grid;
|
||||
|
||||
42
task/2.md
42
task/2.md
@ -1,17 +1,31 @@
|
||||
# Задача 2 — Проверка API-доков по личным данным и сессиям
|
||||
# Задача 2 — Проверка работы личных данных и статусов профиля (правая вкладка)
|
||||
|
||||
## Что проверяем
|
||||
1. В `03_Session_Management_API.md` описан формат `sessionId` и правило «передавать как есть».
|
||||
2. В `04_Add_Block_to_Blockchain_API.md` описан набор ключей USER_PARAM для личных данных.
|
||||
3. В `05_Technical_Requests_API.md` зафиксировано, что отдельного RPC для direct tech message в конкретную сессию пока нет.
|
||||
## Что реализовано
|
||||
- На правой вкладке `Профиль` отображаются реальные пользовательские параметры, загружаемые через `ListUserParams`.
|
||||
- Поля профиля:
|
||||
- `first_name` (чтение с обратной совместимостью с `name`)
|
||||
- `last_name`
|
||||
- `address_physical`
|
||||
- `address_web`
|
||||
- `phone`
|
||||
- Кнопка `Обновить` открывает форму редактирования и сохраняет изменения в пользовательские параметры блокчейна.
|
||||
- Добавлены рабочие переключатели:
|
||||
- `official`
|
||||
- `shine`
|
||||
- Для `official`/`shine` используется подтверждение перед записью, с предупреждением, что изменение идёт через блокчейн-параметры и требует подписи ключом пользователя.
|
||||
- Если `official`/`shine` отсутствуют в параметрах, они считаются `no` по умолчанию.
|
||||
|
||||
## Как должна выглядеть рабочая логика
|
||||
- Клиент сохраняет личные данные через `UpsertUserParam` по стандартным ключам.
|
||||
- При повторном изменении поля клиент пишет новую запись с более поздним временем.
|
||||
- Актуальное значение получается через `ListUserParams` (берётся самая новая запись по ключу).
|
||||
- Для отправки техсообщений в конкретную сессию нужен отдельный RPC, которого пока нет.
|
||||
## Что проверить вручную
|
||||
1. Авторизоваться и открыть правую вкладку `Профиль`.
|
||||
2. Убедиться, что поля профиля читаются из `ListUserParams`, а не из заглушек.
|
||||
3. Нажать `Обновить`, изменить `first_name/last_name/address_physical/address_web/phone`, нажать `Сохранить`.
|
||||
4. Убедиться, что после сохранения данные перечитались и обновились на экране.
|
||||
5. Нажать `Официальный`, подтвердить изменение и проверить смену `no -> yes` (или `yes -> no`).
|
||||
6. Нажать `Сияющий`, подтвердить изменение и проверить смену `no -> yes` (или `yes -> no`).
|
||||
7. Обновить страницу и убедиться, что состояния `official/shine` и личные поля сохраняются.
|
||||
8. Проверить кейс отсутствия `official/shine` в истории: UI должен показывать `no`.
|
||||
|
||||
## Критерии приёмки
|
||||
- Термины и пояснения в документации понятны без чтения кода.
|
||||
- Примеры ключей единообразны (`name`, `last_name`, `address_physical`, `address_web`, `phone`).
|
||||
- Ограничения MVP явно указаны (ACL/валидация/отдельный direct-session RPC).
|
||||
## Ожидаемый результат
|
||||
- Правая вкладка профиля работает с реальными данными пользователя.
|
||||
- `official` и `shine` работают как настоящие параметры (yes/no), а не заглушки.
|
||||
- После каждой записи UI делает повторный `ListUserParams` и показывает актуальное состояние.
|
||||
|
||||
Loading…
Reference in New Issue
Block a user