fix: Fix match detail data loading and add API transformation layer

- Update Zod schemas to match raw API response formats
- Create transformation layer (rounds, weapons, chat) to convert raw API to structured format
- Add player name mapping in transformers for better UX
- Fix Svelte 5 reactivity issues in chat page (replace $effect with $derived)
- Fix Chart.js compatibility with Svelte 5 state proxies using JSON serialization
- Add economy advantage chart with halftime perspective flip (WIP)
- Remove stray comment from details page
- Update layout to load match data first, then pass to API methods

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-13 00:37:41 +01:00
parent 12115198b7
commit 05a6c10458
26 changed files with 575 additions and 279 deletions

View File

@@ -43,6 +43,10 @@
let canvas: HTMLCanvasElement;
let chart: Chart<'bar'> | null = null;
// Convert Svelte 5 $state proxy to plain object for Chart.js compatibility
// Using JSON parse/stringify to handle Svelte proxies that structuredClone can't handle
const plainData = $derived(JSON.parse(JSON.stringify(data)));
const defaultOptions: ChartConfiguration<'bar'>['options'] = {
responsive: true,
maintainAspectRatio: false,
@@ -99,7 +103,7 @@
if (ctx) {
chart = new Chart(ctx, {
type: 'bar',
data: data,
data: plainData,
options: { ...defaultOptions, ...options }
});
}
@@ -113,8 +117,8 @@
// Watch for data changes and update chart
$effect(() => {
if (chart) {
chart.data = data;
if (chart && plainData) {
chart.data = plainData;
chart.options = { ...defaultOptions, ...options };
chart.update();
}