Files
analytics/resources/views/reports/events/detail.blade.php
T

79 lines
3.9 KiB
PHP
Raw Normal View History

2026-03-24 21:12:21 +01:00
<x-report-layout :website="$website" :from="$from" :to="$to" :title="'Event: ' . $eventName">
<div class="space-y-6">
<div class="rounded-xl border border-gray-200 bg-white overflow-hidden p-6">
<h3 class="text-base font-semibold text-gray-900 mb-4">Trend</h3>
<div style="height: 240px;">
<canvas id="event-trend-chart"></canvas>
</div>
</div>
<div class="rounded-xl border border-gray-200 bg-white overflow-hidden">
@if ($details->isEmpty())
<x-empty-state message="No detail breakdown available." />
@else
<div class="overflow-x-auto">
<table class="min-w-full divide-y divide-gray-200">
<thead class="bg-gray-50">
<tr>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Action</th>
<th class="px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider">Label</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Count</th>
<th class="px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider">Total Value</th>
</tr>
</thead>
<tbody class="divide-y divide-gray-200">
@foreach ($details as $row)
<tr>
<td class="px-6 py-3 text-sm text-gray-900">{{ $row->action ?? '—' }}</td>
<td class="px-6 py-3 text-sm text-gray-500">{{ $row->label ?? '—' }}</td>
<td class="px-6 py-3 text-sm text-gray-900 text-right">{{ number_format($row->total) }}</td>
<td class="px-6 py-3 text-sm text-gray-900 text-right">{{ $row->total_value ? number_format($row->total_value, 2) : '—' }}</td>
</tr>
@endforeach
</tbody>
</table>
</div>
@endif
</div>
</div>
<x-slot name="scripts">
<script src="https://cdn.jsdelivr.net/npm/chart.js@4/dist/chart.umd.min.js"></script>
<script>
document.addEventListener('DOMContentLoaded', function () {
const raw = @json($trending);
new Chart(document.getElementById('event-trend-chart'), {
type: 'bar',
data: {
labels: raw.map(d => d.period),
datasets: [{
label: '{{ $eventName }}',
data: raw.map(d => d.total),
backgroundColor: 'rgba(99, 102, 241, 0.7)',
borderRadius: 4,
}],
},
options: {
responsive: true,
maintainAspectRatio: false,
plugins: {
legend: { display: false },
tooltip: {
backgroundColor: 'rgba(17,24,39,0.95)',
padding: 10,
cornerRadius: 8,
},
},
scales: {
x: { grid: { display: false }, ticks: { maxTicksLimit: 12, font: { size: 11 }, color: '#9ca3af' } },
y: { beginAtZero: true, grid: { color: 'rgba(0,0,0,0.04)' }, ticks: { precision: 0, font: { size: 11 }, color: '#9ca3af' } },
},
},
});
});
</script>
</x-slot>
</x-report-layout>