Interactive Dropshipping Refund & Chargeback Analyzer

Interactive Dropshipping Refund & Chargeback Analyzer

Analyze dispute data to identify trends and reduce revenue loss.

Dispute Analysis Report

Disputes by Reason

Reason Total Cases Total Value Refunds Chargebacks

Manage Dispute Data

Order Value ($) Type Reason Status

Total Refund Value

$${data.totalRefundValue.toFixed(2)}

Total Chargeback Value

$${data.totalChargebackValue.toFixed(2)}

Total Disputes

${data.totalDisputes}

Chargeback Win Rate

${data.chargebackWinRate.toFixed(1)}%

`; dashboardTableBody.innerHTML = ''; const sortedReasons = Object.keys(data.reasonsSummary).sort((a,b) => data.reasonsSummary[b].cases - data.reasonsSummary[a].cases); if (sortedReasons.length === 0) { dashboardTableBody.innerHTML = `No dispute data entered.`; return; } sortedReasons.forEach(reason => { const r = data.reasonsSummary[reason]; const tr = document.createElement('tr'); tr.className = 'bg-white border-b hover:bg-gray-50'; tr.innerHTML = ` ${reason} ${r.cases} $${r.value.toFixed(2)} ${r.refunds} ${r.chargebacks} `; dashboardTableBody.appendChild(tr); }); document.getElementById('dashboard-date').textContent = `Report generated on: ${new Date().toLocaleDateString()}`; } // --- Tab & Navigation Logic --- function switchTab(targetTabId) { if (targetTabId === 'dashboard') { const data = analyzeDisputes(); if (data === null) return; renderDashboard(data); } currentTab = targetTabId; tabs.forEach(tab => tab.classList.toggle('active', tab.dataset.tab === currentTab)); tabContents.forEach(content => content.classList.toggle('active', content.id === currentTab)); updateNavButtons(); } tabs.forEach(tab => tab.addEventListener('click', () => switchTab(tab.dataset.tab))); nextBtn.addEventListener('click', () => currentTab === 'dashboard' ? switchTab('config') : switchTab('dashboard')); prevBtn.addEventListener('click', () => currentTab === 'config' ? switchTab('dashboard') : switchTab('config')); function updateNavButtons() { if (currentTab === 'dashboard') { nextBtn.textContent = 'Configure Data'; prevBtn.style.display = 'none'; pdfButtonContainer.style.display = 'block'; } else { nextBtn.textContent = 'Update Dashboard'; prevBtn.style.display = 'inline-flex'; pdfButtonContainer.style.display = 'none'; } } // --- PDF Download --- downloadPdfBtn.addEventListener('click', async () => { const { jsPDF } = window.jspdf; const doc = new jsPDF({ orientation: 'l', unit: 'mm', format: 'a4' }); const content = document.getElementById('pdf-content'); await new Promise(r => setTimeout(r, 100)); // Allow DOM update const canvas = await html2canvas(content, { scale: 2 }); const imgData = canvas.toDataURL('image/jpeg', 1.0); doc.setFont('helvetica', 'bold'); doc.setFontSize(18); doc.text('Dropshipping Dispute Analysis Report', 14, 22); const imgProps = doc.getImageProperties(imgData); const pdfWidth = doc.internal.pageSize.getWidth() - 28; const pdfHeight = (imgProps.height * pdfWidth) / imgProps.width; doc.addImage(imgData, 'JPEG', 14, 30, pdfWidth, pdfHeight); doc.save(`Dispute-Analysis-Report-${new Date().toISOString().slice(0,10)}.pdf`); }); // --- Initial Load --- function populateSampleData() { [ { value: '79.99', type: 'Chargeback', reason: 'Item not received', status: 'Lost' }, { value: '45.50', type: 'Refund', reason: 'Product damaged', status: 'Lost' }, { value: '120.00', type: 'Chargeback', reason: 'Fraudulent transaction', status: 'Won' }, { value: '45.50', type: 'Refund', reason: 'Product damaged', status: 'Lost' }, { value: '29.99', type: 'Refund', reason: 'Product not as described', status: 'Lost' }, { value: '85.00', type: 'Chargeback', reason: 'Item not received', status: 'In Progress' }, { value: '29.99', type: 'Chargeback', reason: 'Product not as described', status: 'Lost' }, ].forEach(d => createDisputeRow(d)); } populateSampleData(); switchTab('dashboard'); // Analyze and show dashboard on load });
Scroll to Top