Files
csgowtf/src/routes/match/[id]/details/+page.ts
vikingowl 62bfdc8090 fix: Fix match page SSR, tab errors, and table consistency
- Enable SSR for match pages by detecting server vs client context in API client
- Fix 500 errors on economy, chat, and details tabs by adding data loaders
- Handle unparsed matches gracefully with "Match Not Parsed" messages
- Fix dynamic team ID detection instead of hardcoding team IDs 2/3
- Fix DataTable component to properly render HTML in render functions
- Add fixed column widths to tables for visual consistency
- Add meta titles to all tab page loaders
- Fix Svelte 5 $derived syntax errors
- Fix ESLint errors (unused imports, any types, reactive state)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-05 00:27:47 +01:00

40 lines
898 B
TypeScript

import { api } from '$lib/api';
import type { PageLoad } from './$types';
export const load: PageLoad = async ({ parent, params }) => {
const { match } = await parent();
// Only load weapons data if match is parsed
if (!match.demo_parsed) {
return {
match,
weaponsData: null,
meta: {
title: `${match.map || 'Match'} Details - Match ${match.match_id} - CS2.WTF`
}
};
}
try {
const weaponsData = await api.matches.getMatchWeapons(params.id);
return {
match,
weaponsData,
meta: {
title: `${match.map || 'Match'} Details - Match ${match.match_id} - CS2.WTF`
}
};
} catch (err) {
console.error(`Failed to load weapons data for match ${params.id}:`, err);
// Return null instead of throwing error
return {
match,
weaponsData: null,
meta: {
title: `${match.map || 'Match'} Details - Match ${match.match_id} - CS2.WTF`
}
};
}
};