dana-medical-site/internal/api/adminui/clinic.js
2026-10-14 13:33:13 +00:00

33 lines
1.7 KiB
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/* Клиника раздела «Отчёты»: DANA или «Очевидно». У каждой свои звонки АТС, отчёты по каналам
и дашборд; сервер получает её в ?clinic= (без параметра — DANA). Выбор запоминается в браузере. */
const ReportClinic = {
titles: { dana: 'DANA', ochevidno: 'Очевидно' },
brands: { dana: 'DANA Medical', ochevidno: 'Очевидно' },
key: 'dana',
init() {
try {
const saved = localStorage.getItem('rp-clinic');
if (saved && ReportClinic.titles[saved]) ReportClinic.key = saved;
} catch { /* без хранилища — DANA */ }
for (const b of document.querySelectorAll('#rp-clinic button[data-clinic]')) b.onclick = () => ReportClinic.set(b.dataset.clinic);
const share = document.getElementById('rp-share');
if (share) share.onclick = () => Reports.shareDialog();
ReportClinic.sync();
},
get title() { return ReportClinic.titles[ReportClinic.key]; },
get brand() { return ReportClinic.brands[ReportClinic.key]; },
q(path) { return path + (path.includes('?') ? '&' : '?') + 'clinic=' + encodeURIComponent(ReportClinic.key); },
sync() {
for (const b of document.querySelectorAll('#rp-clinic button[data-clinic]')) b.setAttribute('aria-pressed', String(b.dataset.clinic === ReportClinic.key));
},
set(key) {
if (!ReportClinic.titles[key] || key === ReportClinic.key) return;
ReportClinic.key = key;
try { localStorage.setItem('rp-clinic', key); } catch { /* выбор действует до перезагрузки */ }
ReportClinic.sync();
Reports.onClinicChange();
},
};
ReportClinic.init();