--- +++ @@ -57,3 +57,4 @@ mount(view, host); - drawSearch(host); + if (parts?.[0] && /^\d+$/.test(parts[0])) showUser(host,parts[0]); + else drawSearch(host); } @@ -61,3 +62,3 @@ function drawSearch(host) { - const input = el('input', { type: 'text', class: 'search-box', placeholder: t('usr_search_ph'), value: lastQuery }); + const input = el('input', { type: 'search', class: 'search-box', 'aria-label':t('usr_search_ph'), placeholder: t('usr_search_ph'), value: lastQuery }); const results = el('div', { class: 'user-results' }); @@ -125,3 +126,3 @@ // stats - wrap.appendChild(el('div', { class: 'stat-grid' }, [ + wrap.appendChild(el('div', { class: 'stat-grid profile-stats' }, [ statCard({ icon: '💰', label: t('usr_balance'), value: fmtNum(u.balance), accent: 'success' }), @@ -156,4 +157,7 @@ -function doToggle(ev, host, u, which) { - const btn = ev.currentTarget; busy(btn, true); +async function doToggle(ev, host, u, which) { + const btn = ev.currentTarget; + const action = which === 'block' ? (u.is_blocked ? 'رفع مسدودی' : 'مسدودسازی دسترسی به ربات') : (u.is_partner ? 'حذف دسترسی همکاری' : 'فعال‌سازی دسترسی همکاری'); + if (!await confirmDialog(action + ' برای «' + (u.full_name || u.id) + '» تأیید شود؟')) return; + busy(btn, true); api('/users/' + u.id + '/' + which, { method: 'POST' }) @@ -213,6 +217,9 @@ actions: [button({ - label: t('save'), onClick: function (ev) { + label: t('save'), onClick: async function (ev) { const amt = parseFloat(fieldValue(fAmount) || '0'); if (!(amt > 0)) { toast(t('usr_amount'), 'error'); return; } - const btn = ev.currentTarget; busy(btn, true); + const btn = ev.currentTarget; + if (fieldValue(fReason).trim().length < 3) { toast('دلیل را با حداقل ۳ نویسه بنویسید.','error'); return; } + if (type === 'DECREASE' && !await confirmDialog('مبلغ ' + fmtToman(amt) + ' از ' + fWallet._input.selectedOptions[0].textContent + ' «' + (u.full_name || u.id) + '» کسر شود؟')) return; + busy(btn, true); api('/users/' + u.id + '/wallet', {