confirmAccept?.addEventListener('click', async () => {
if (!confirmModal?.dataset.customerId) {
closeConfirmModal();
return;
}
const id = Number(confirmModal.dataset.customerId);
try {
const response = await fetch('/api/customers/delete.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({ customer_id: id })
});
const result = await response.json();
if (!response.ok) {
throw new Error(result?.message || 'Falha ao excluir cliente.');
}
removeCustomerRow(id);
closeConfirmModal();
const snapshot = result?.data ?? null;
showToast(result?.message || 'Cliente removido com sucesso.', {
duration: 6000,
action: snapshot ? {
label: 'Desfazer',
onClick: () => undoDeleteCustomer(snapshot)
} : null,
});
} catch (error) {
showToast(error instanceof Error ? error.message : 'Não foi possível remover o cliente.', 'error');
console.error(error);
}
});
async function undoDeleteCustomer(snapshot) {
const response = await fetch('/api/customers/restore.php', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify(snapshot)
});
const result = await response.json();
if (!response.ok) {
throw new Error(result?.message || 'Não foi possível restaurar o cliente.');
}
if (!result?.data) {
throw new Error('Resposta inválida ao restaurar cliente.');
}
upsertCustomerRow(result.data);
showToast('Cliente restaurado com sucesso.');
}
Admin · PeepStreaming · PeepStreaming
Central administrativa
Painel de controle da PeepStreaming
Aqui você configura o branding, gerencia planos, controla chaves Pix, monitora métricas e conecta APIs críticas. Tudo organizado com
visual glassmórfico e foco em produtividade.