From 921c6dc281ef398ed41a0d724f16c83c680531d1 Mon Sep 17 00:00:00 2001 From: Stan Runge Date: Mon, 23 Dec 2024 15:54:09 +0100 Subject: [PATCH] fix: match play types --- .../resources/js/Pages/Matches/Play.svelte | 28 +++++++++---------- packages/web/resources/js/Types/app.ts | 27 ++++++++++++++++-- 2 files changed, 38 insertions(+), 17 deletions(-) diff --git a/packages/web/resources/js/Pages/Matches/Play.svelte b/packages/web/resources/js/Pages/Matches/Play.svelte index efc560b4..49b798e1 100644 --- a/packages/web/resources/js/Pages/Matches/Play.svelte +++ b/packages/web/resources/js/Pages/Matches/Play.svelte @@ -2,14 +2,14 @@ import Layout from '@/Shared/Layout.svelte' import { router, Link } from '@inertiajs/svelte' import { onMount } from 'svelte' - import type { TeamMember, MatchParticipant, MatchMap, Score } from '@/Types/app' + import type { Match, TeamMember, User, MatchParticipant, MatchMap, Score } from '@/Types/app' - let { match, user } = $props() + let { match, user }: { match: Match; user: User } = $props() console.log(match) let shareModalShown = $state(false) let forfeitModalShown = $state(false) - let matchEndedModalShown = $state(match.finished_at) + let matchEndedModalShown = $state(match.finished_at ? true : false) let mapPoolStatus = $state(getMapPoolStatus()) onMount(() => { @@ -31,14 +31,14 @@ }) function userCanBan() { - return user.profile.team_members.find((tm: TeamMember) => - tm.team?.match_participants?.find((mp: MatchParticipant) => mp.id == match.current_banner), + return user.profile.team_members?.find((tm) => + tm.team?.match_participants?.find((mp) => mp.id == match.current_banner), ) } function userCanPick() { - return user.profile.team_members.find((tm: TeamMember) => - tm.team?.match_participants?.find((mp: MatchParticipant) => mp.id == match.current_picker), + return user.profile.team_members?.find((tm) => + tm.team?.match_participants?.find((mp) => mp.id == match.current_picker), ) } @@ -83,7 +83,7 @@ -
+

{match.event?.name}

@@ -120,13 +120,13 @@
{#each match.match_participants as participant}
-
+

{participant.team.name}

Team Logo
{#each participant.match_participant_players as player} -
+
Player

{player.team_member.profile?.username}

{getPlayerStatusIcon()}

@@ -144,13 +144,13 @@
{#each getMatchParticipantScores(map.id, match.match_participants[0].id) as score} -
+

{score.score}

{/each}
-
+

{map.map_pool_map.map.map_set.artist} - {map.map_pool_map.map.map_set.title} [{map .map_pool_map.map.difficulty_name}] @@ -158,7 +158,7 @@

{#each getMatchParticipantScores(map.id, match.match_participants[1].id) as score} -
+

{score.score}

@@ -185,7 +185,7 @@ return acc }, {})) as [modsKey, maps]} -
+

{modsKey}

diff --git a/packages/web/resources/js/Types/app.ts b/packages/web/resources/js/Types/app.ts index 64e8d58e..eeab5cb0 100644 --- a/packages/web/resources/js/Types/app.ts +++ b/packages/web/resources/js/Types/app.ts @@ -37,12 +37,33 @@ export interface Map { export interface Match { id: number match_participants?: MatchParticipant[] - match_maps?: MatchMap[] + match_maps?: MatchMap[], + finished_at: string | null, + current_picker: number | null, + current_banner: number | null, + action_limit: string | null } -export interface Score { +export interface Score { id: number match_participant_player_id: number match_participant_player?: MatchParticipantPlayer score: number -} \ No newline at end of file +} + +export interface User { + id: number, + profile_id: number, + profile: Profile +} + +export interface Organisation { + id: number, +} + +export interface Profile { + id: number, + user_id: number, + user?: User + team_members?: TeamMember[] +}