feat: Implement Phase 1 critical features and fix API integration
This commit completes the first phase of feature parity implementation and resolves all API integration issues to match the backend API format. ## API Integration Fixes - Remove all hardcoded default values from transformers (tick_rate, kast, player_count, steam_updated) - Update TypeScript types to make fields optional where backend doesn't guarantee them - Update Zod schemas to validate optional fields correctly - Fix mock data to match real API response format (plain arrays, not wrapped objects) - Update UI components to handle undefined values with proper fallbacks - Add comprehensive API documentation for Match and Player endpoints ## Phase 1 Features Implemented (3/6) ### 1. Player Tracking System ✅ - Created TrackPlayerModal.svelte with auth code input - Integrated track/untrack player API endpoints - Added UI for providing optional share code - Displays tracked status on player profiles - Full validation and error handling ### 2. Share Code Parsing ✅ - Created ShareCodeInput.svelte component - Added to matches page for easy match submission - Real-time validation of share code format - Parse status feedback with loading states - Auto-redirect to match page on success ### 3. VAC/Game Ban Status ✅ - Added VAC and game ban count/date fields to Player type - Display status badges on player profile pages - Show ban count and date when available - Visual indicators using DaisyUI badge components ## Component Improvements - Modal.svelte: Added Svelte 5 Snippet types, actions slot support - ThemeToggle.svelte: Removed deprecated svelte:component usage - Tooltip.svelte: Fixed type safety with Snippet type - All new components follow Svelte 5 runes pattern ($state, $derived, $bindable) ## Type Safety & Linting - Fixed all ESLint errors (any types → proper types) - Fixed form label accessibility issues - Replaced error: any with error: unknown + proper type guards - Added Snippet type imports where needed - Updated all catch blocks to use instanceof Error checks ## Static Assets - Migrated all files from public/ to static/ directory per SvelteKit best practices - Moved 200+ map icons, screenshots, and other assets - Updated all import paths to use /images/ (served from static/) ## Documentation - Created IMPLEMENTATION_STATUS.md tracking all 15 missing features - Updated API.md with optional field annotations - Created MATCHES_API.md with comprehensive endpoint documentation - Added inline comments marking optional vs required fields ## Testing - Updated mock fixtures to remove default values - Fixed mock handlers to return plain arrays like real API - Ensured all components handle undefined gracefully ## Remaining Phase 1 Tasks - [ ] Add VAC status column to match scoreboard - [ ] Create weapons statistics tab for matches - [ ] Implement recently visited players on home page 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -7,7 +7,7 @@ import type { Player, Match, MatchPlayer, MatchListItem, PlayerMeta } from '$lib
|
||||
/** Mock players */
|
||||
export const mockPlayers: Player[] = [
|
||||
{
|
||||
id: 765611980123456, // Smaller mock Steam ID (safe integer)
|
||||
id: '765611980123456', // Smaller mock Steam ID (safe integer)
|
||||
name: 'TestPlayer1',
|
||||
avatar:
|
||||
'https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/fe/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb_full.jpg',
|
||||
@@ -21,7 +21,7 @@ export const mockPlayers: Player[] = [
|
||||
game_ban_count: 0
|
||||
},
|
||||
{
|
||||
id: 765611980876543, // Smaller mock Steam ID (safe integer)
|
||||
id: '765611980876543', // Smaller mock Steam ID (safe integer)
|
||||
name: 'TestPlayer2',
|
||||
avatar: 'https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/ab/abc123.jpg',
|
||||
steam_updated: '2024-11-04T11:15:00Z',
|
||||
@@ -50,7 +50,7 @@ export const mockPlayerMeta: PlayerMeta = {
|
||||
/** Mock match players */
|
||||
export const mockMatchPlayers: MatchPlayer[] = [
|
||||
{
|
||||
id: 765611980123456,
|
||||
id: '765611980123456',
|
||||
name: 'Player1',
|
||||
avatar:
|
||||
'https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/fe/fef49e7fa7e1997310d705b2a6158ff8dc1cdfeb_full.jpg',
|
||||
@@ -77,7 +77,7 @@ export const mockMatchPlayers: MatchPlayer[] = [
|
||||
color: 'yellow'
|
||||
},
|
||||
{
|
||||
id: 765611980876543,
|
||||
id: '765611980876543',
|
||||
name: 'Player2',
|
||||
avatar: 'https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/ab/abc123.jpg',
|
||||
team_id: 2,
|
||||
@@ -96,7 +96,7 @@ export const mockMatchPlayers: MatchPlayer[] = [
|
||||
color: 'blue'
|
||||
},
|
||||
{
|
||||
id: 765611980111111,
|
||||
id: '765611980111111',
|
||||
name: 'Player3',
|
||||
avatar: 'https://steamcdn-a.akamaihd.net/steamcommunity/public/images/avatars/cd/cde456.jpg',
|
||||
team_id: 3,
|
||||
@@ -119,7 +119,7 @@ export const mockMatchPlayers: MatchPlayer[] = [
|
||||
/** Mock matches */
|
||||
export const mockMatches: Match[] = [
|
||||
{
|
||||
match_id: 358948771684207, // Smaller mock match ID (safe integer)
|
||||
match_id: '358948771684207', // Smaller mock match ID (safe integer)
|
||||
share_code: 'CSGO-XXXXX-XXXXX-XXXXX-XXXXX-XXXXX',
|
||||
map: 'de_inferno',
|
||||
date: '2024-11-01T18:45:00Z',
|
||||
@@ -131,11 +131,11 @@ export const mockMatches: Match[] = [
|
||||
demo_parsed: true,
|
||||
vac_present: false,
|
||||
gameban_present: false,
|
||||
tick_rate: 64.0,
|
||||
// Note: tick_rate is not provided by the API
|
||||
players: mockMatchPlayers
|
||||
},
|
||||
{
|
||||
match_id: 358948771684208,
|
||||
match_id: '358948771684208',
|
||||
share_code: 'CSGO-YYYYY-YYYYY-YYYYY-YYYYY-YYYYY',
|
||||
map: 'de_mirage',
|
||||
date: '2024-11-02T20:15:00Z',
|
||||
@@ -146,11 +146,11 @@ export const mockMatches: Match[] = [
|
||||
max_rounds: 24,
|
||||
demo_parsed: true,
|
||||
vac_present: false,
|
||||
gameban_present: false,
|
||||
tick_rate: 64.0
|
||||
gameban_present: false
|
||||
// Note: tick_rate is not provided by the API
|
||||
},
|
||||
{
|
||||
match_id: 358948771684209,
|
||||
match_id: '358948771684209',
|
||||
share_code: 'CSGO-ZZZZZ-ZZZZZ-ZZZZZ-ZZZZZ-ZZZZZ',
|
||||
map: 'de_dust2',
|
||||
date: '2024-11-03T15:30:00Z',
|
||||
@@ -161,8 +161,8 @@ export const mockMatches: Match[] = [
|
||||
max_rounds: 24,
|
||||
demo_parsed: true,
|
||||
vac_present: false,
|
||||
gameban_present: false,
|
||||
tick_rate: 64.0
|
||||
gameban_present: false
|
||||
// Note: tick_rate is not provided by the API
|
||||
}
|
||||
];
|
||||
|
||||
@@ -174,8 +174,8 @@ export const mockMatchListItems: MatchListItem[] = mockMatches.map((match) => ({
|
||||
score_team_a: match.score_team_a,
|
||||
score_team_b: match.score_team_b,
|
||||
duration: match.duration,
|
||||
demo_parsed: match.demo_parsed,
|
||||
player_count: 10
|
||||
demo_parsed: match.demo_parsed
|
||||
// Note: player_count is not provided by the API, so it's omitted from mocks
|
||||
}));
|
||||
|
||||
/** Helper: Generate random Steam ID (safe integer) */
|
||||
@@ -184,11 +184,11 @@ export const generateSteamId = (): number => {
|
||||
};
|
||||
|
||||
/** Helper: Get mock player by ID */
|
||||
export const getMockPlayer = (id: number): Player | undefined => {
|
||||
export const getMockPlayer = (id: string): Player | undefined => {
|
||||
return mockPlayers.find((p) => p.id === id);
|
||||
};
|
||||
|
||||
/** Helper: Get mock match by ID */
|
||||
export const getMockMatch = (id: number): Match | undefined => {
|
||||
export const getMockMatch = (id: string): Match | undefined => {
|
||||
return mockMatches.find((m) => m.match_id === id);
|
||||
};
|
||||
|
||||
@@ -2,7 +2,6 @@ import { http, HttpResponse, delay } from 'msw';
|
||||
import { mockMatches, mockMatchListItems, getMockMatch } from '../fixtures';
|
||||
import type {
|
||||
MatchParseResponse,
|
||||
MatchesListResponse,
|
||||
MatchRoundsResponse,
|
||||
MatchWeaponsResponse,
|
||||
MatchChatResponse
|
||||
@@ -21,7 +20,7 @@ export const matchesHandlers = [
|
||||
await delay(500);
|
||||
|
||||
const response: MatchParseResponse = {
|
||||
match_id: 358948771684207,
|
||||
match_id: '358948771684207',
|
||||
status: 'parsing',
|
||||
message: 'Demo download and parsing initiated',
|
||||
estimated_time: 120
|
||||
@@ -33,7 +32,7 @@ export const matchesHandlers = [
|
||||
// GET /match/:id
|
||||
http.get(`${API_BASE_URL}/match/:id`, ({ params }) => {
|
||||
const { id } = params;
|
||||
const matchId = Number(id);
|
||||
const matchId = String(id);
|
||||
|
||||
const match = getMockMatch(matchId) || mockMatches[0];
|
||||
|
||||
@@ -165,14 +164,11 @@ export const matchesHandlers = [
|
||||
matches = matches.slice(0, Math.ceil(matches.length / 2));
|
||||
}
|
||||
|
||||
const response: MatchesListResponse = {
|
||||
matches: matches.slice(0, limit),
|
||||
next_page_time: Date.now() / 1000 - 86400,
|
||||
has_more: matches.length > limit,
|
||||
total_count: matches.length
|
||||
};
|
||||
// NOTE: The real API returns a plain array, not a MatchesListResponse object
|
||||
// The transformation to MatchesListResponse happens in the API client
|
||||
const matchArray = matches.slice(0, limit);
|
||||
|
||||
return HttpResponse.json(response);
|
||||
return HttpResponse.json(matchArray);
|
||||
}),
|
||||
|
||||
// GET /matches/next/:time
|
||||
@@ -181,12 +177,9 @@ export const matchesHandlers = [
|
||||
const limit = Number(url.searchParams.get('limit')) || 50;
|
||||
|
||||
// Return older matches for pagination
|
||||
const response: MatchesListResponse = {
|
||||
matches: mockMatchListItems.slice(limit, limit * 2),
|
||||
next_page_time: Date.now() / 1000 - 172800,
|
||||
has_more: mockMatchListItems.length > limit * 2
|
||||
};
|
||||
// NOTE: The real API returns a plain array, not a MatchesListResponse object
|
||||
const matchArray = mockMatchListItems.slice(limit, limit * 2);
|
||||
|
||||
return HttpResponse.json(response);
|
||||
return HttpResponse.json(matchArray);
|
||||
})
|
||||
];
|
||||
|
||||
@@ -12,7 +12,7 @@ export const playersHandlers = [
|
||||
// GET /player/:id
|
||||
http.get(`${API_BASE_URL}/player/:id`, ({ params }) => {
|
||||
const { id } = params;
|
||||
const playerId = Number(id);
|
||||
const playerId = String(id);
|
||||
|
||||
const player = getMockPlayer(playerId);
|
||||
if (!player) {
|
||||
@@ -25,7 +25,7 @@ export const playersHandlers = [
|
||||
// GET /player/:id/next/:time
|
||||
http.get(`${API_BASE_URL}/player/:id/next/:time`, ({ params }) => {
|
||||
const { id } = params;
|
||||
const playerId = Number(id);
|
||||
const playerId = String(id);
|
||||
|
||||
const player = getMockPlayer(playerId) ?? mockPlayers[0];
|
||||
|
||||
|
||||
Reference in New Issue
Block a user