feat: add excel export to reports and video view counter increment [TASK-26.20]
Deploy Canina / deploy (push) Waiting to run
Deploy Canina / deploy (push) Waiting to run
This commit is contained in:
1 parent
8a05854aa0
commit
187aa7c962
4 files changed
+37
-3
No files matched your search
@@ -94,7 +94,30 @@ export default function Reports() {
|
||||
</h2>
|
||||
<p className="text-gray-500 font-medium mt-1">آمار فروش، رفتار کاربران و عملکرد تخفیفها</p>
|
||||
</div>
|
||||
<button className="bg-white border-2 border-purple-200 text-purple-700 hover:bg-purple-50 px-5 py-2.5 rounded-xl flex items-center gap-2 font-bold transition-all shadow-sm">
|
||||
<button
|
||||
onClick={() => {
|
||||
if (!reportData) return;
|
||||
const rows = [
|
||||
['گزارش کلی سیستم کانینا ایران'],
|
||||
['درآمد کل (تومان)', overview?.totalRevenue || 0],
|
||||
['تعداد سفارشات', overview?.totalOrders || 0],
|
||||
['تعداد کاربران', overview?.totalUsers || 0],
|
||||
['میانگین ارزش سفارش', overview?.avgOrderValue || 0],
|
||||
[],
|
||||
['محصولات پرفروش', 'تعداد فروش'],
|
||||
...(bestSellers || []).map(b => [b.name, b.quantity]),
|
||||
];
|
||||
const csvContent = 'data:text/csv;charset=utf-8,\uFEFF' + rows.map(e => e.join(',')).join('\n');
|
||||
const encodedUri = encodeURI(csvContent);
|
||||
const link = document.createElement('a');
|
||||
link.setAttribute('href', encodedUri);
|
||||
link.setAttribute('download', `Canina_Sales_Report_${new Date().toISOString().split('T')[0]}.csv`);
|
||||
document.body.appendChild(link);
|
||||
link.click();
|
||||
document.body.removeChild(link);
|
||||
}}
|
||||
className="bg-white border-2 border-purple-200 text-purple-700 hover:bg-purple-50 px-5 py-2.5 rounded-xl flex items-center gap-2 font-bold transition-all shadow-sm"
|
||||
>
|
||||
<Download className="w-5 h-5" />
|
||||
خروجی اکسل (Excel)
|
||||
</button>
|
||||
|
||||
Reference in new issue
Block a user