feat(админка): выгрузка данных клиента
This commit is contained in:
@@ -80,6 +80,19 @@ export function CustomerDrawer({ email, onClose, onDeleted, onChanged }) {
|
||||
} catch (e) { setNotice(e.message || 'Взнос не записан'); }
|
||||
finally { setBusy(false); }
|
||||
};
|
||||
const exportData = async () => {
|
||||
setBusy(true);
|
||||
try {
|
||||
const r = await fetch('/api/admin/v2/customers/' + encodeURIComponent(email) + '/export',
|
||||
{headers: {Authorization: 'Bearer ' + (localStorage.getItem('token') || '')}});
|
||||
if (!r.ok) throw new Error('Ошибка ' + r.status);
|
||||
const url = URL.createObjectURL(await r.blob());
|
||||
const a = document.createElement('a');
|
||||
a.href = url; a.download = 'export.zip'; a.click();
|
||||
URL.revokeObjectURL(url);
|
||||
} catch (e) { setNotice(e.message || 'Не удалось выгрузить'); }
|
||||
finally { setBusy(false); }
|
||||
};
|
||||
const del = async () => {
|
||||
if (!confirm('Удалить учётку ' + email + '? Переписка и файлы останутся, адрес освободится.')) return;
|
||||
setBusy(true); setNotice('');
|
||||
@@ -122,6 +135,7 @@ export function CustomerDrawer({ email, onClose, onDeleted, onChanged }) {
|
||||
{agent_access: !card.profile.agent_access}, card.profile.agent_access ? 'Доступ снят' : 'Доступ выдан')}>
|
||||
${card.profile.agent_access ? 'Снять агента' : 'Выдать агента'}</button>
|
||||
<button type="button" disabled=${busy} onClick=${topup}>Внести</button>
|
||||
<button type="button" disabled=${busy} onClick=${exportData}>Выгрузить</button>
|
||||
<button type="button" disabled=${busy} onClick=${del}>Удалить</button>
|
||||
</div>` : html`<div class="actions-bar">
|
||||
<button type="button" disabled=${busy} onClick=${restore}>Восстановить</button>
|
||||
|
||||
Reference in New Issue
Block a user