17-04-2026

Добавил вкладку пол
This commit is contained in:
AidarKC
2026-04-17 17:39:04 +03:00
parent 7591fbdace
commit c7bf8051b9
4 changed files with 129 additions and 2 deletions
+1
View File
@@ -183,6 +183,7 @@ export async function loadUserProfileCard(login) {
address: fields.address || '',
web: fields.web || '',
phone: fields.phone || '',
gender: String(snapshot?.gender || 'unknown').trim().toLowerCase() || 'unknown',
official: Boolean(toggles.official),
shine: Boolean(toggles.shine),
};
+36 -1
View File
@@ -13,6 +13,15 @@ export const profileToggleDefs = [
{ key: 'shine', label: 'Сияющий' },
];
export const PROFILE_GENDER_MALE = 'male';
export const PROFILE_GENDER_FEMALE = 'female';
export const PROFILE_GENDER_UNKNOWN = 'unknown';
export const PROFILE_GENDER_VALUES = Object.freeze([
PROFILE_GENDER_MALE,
PROFILE_GENDER_FEMALE,
PROFILE_GENDER_UNKNOWN,
]);
function normalizeItem(param, payload) {
if (!param) return null;
@@ -31,6 +40,13 @@ function parseToggleValue(value) {
return normalized === 'true' || normalized === 'yes' || normalized === '1';
}
function normalizeGenderValue(value) {
const normalized = String(value || '').trim().toLowerCase();
if (normalized === PROFILE_GENDER_MALE) return PROFILE_GENDER_MALE;
if (normalized === PROFILE_GENDER_FEMALE) return PROFILE_GENDER_FEMALE;
return PROFILE_GENDER_UNKNOWN;
}
async function getStoragePwd() {
const storagePwd = state.session.storagePwdInMemory;
if (!storagePwd) {
@@ -100,7 +116,15 @@ export async function loadProfileSnapshot(login) {
});
}
return { fields, toggles };
const latestGender = loadLatestByAliasesFromItems(items, ['gender']);
const gender = normalizeGenderValue(latestGender?.value || PROFILE_GENDER_UNKNOWN);
return {
fields,
toggles,
gender,
genderTimeMs: latestGender?.timeMs || 0,
};
}
export async function saveProfileParamBlock(login, key, value) {
@@ -122,3 +146,14 @@ export async function saveProfileToggle(login, key, enabled) {
storagePwd,
});
}
export async function saveProfileGender(login, gender) {
const normalized = normalizeGenderValue(gender);
const storagePwd = await getStoragePwd();
await authService.addBlockUserParam({
login,
param: 'gender',
value: normalized,
storagePwd,
});
}