Skip to content

Commit

Permalink
fix: add else arm for standings table on team page
Browse files Browse the repository at this point in the history
  • Loading branch information
Obnoxieux committed Feb 9, 2025
1 parent 95c8cde commit 094caf4
Showing 1 changed file with 44 additions and 42 deletions.
86 changes: 44 additions & 42 deletions src/routes/teams/[id]/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,62 +1,64 @@
<script lang="ts">
import type { ClubTeam } from "bsm.js";
import { ProgressRadial } from "@skeletonlabs/skeleton";
import BaseballStatsDatatable from "$lib/components/datatable/BaseballStatsDatatable.svelte";
import type { StatsDataset } from "$lib/types/StatsDataset";
import TeamDetailInfoCard from "$lib/components/team/TeamDetailInfoCard.svelte";
import StandingsTable from "$lib/components/table/StandingsTable.svelte";
import type {ClubTeam} from "bsm.js";
import {ProgressRadial} from "@skeletonlabs/skeleton";
import BaseballStatsDatatable from "$lib/components/datatable/BaseballStatsDatatable.svelte";
import type {StatsDataset} from "$lib/types/StatsDataset";
import TeamDetailInfoCard from "$lib/components/team/TeamDetailInfoCard.svelte";
import StandingsTable from "$lib/components/table/StandingsTable.svelte";
interface Props {
data: any;
}
interface Props {
data: any;
}
let { data }: Props = $props();
let clubTeam = $derived(data.clubTeam as ClubTeam);
let {data}: Props = $props();
let clubTeam = $derived(data.clubTeam as ClubTeam);
async function getData(): Promise<StatsDataset> {
return {
batting: await data.battingStats!,
pitching: await data.pitchingStats!,
fielding: await data.fieldingStats!,
};
}
async function getData(): Promise<StatsDataset> {
return {
batting: await data.battingStats!,
pitching: await data.pitchingStats!,
fielding: await data.fieldingStats!,
};
}
</script>

<h1 class="h1 my-4">{clubTeam.team.name} (Saison {clubTeam.team.season})</h1>

<section class="my-5 lg:max-w-[50%]">
<h2 class="h2">Information</h2>
<h2 class="h2">Information</h2>

<TeamDetailInfoCard {clubTeam} />
<TeamDetailInfoCard {clubTeam}/>
</section>

<section>
<h2 class="h2">Standings</h2>
<h2 class="h2">Standings</h2>

{#await data?.table}
<ProgressRadial />
{:then table}
{#if table}
<div class="col-span-2 standings-container">
<StandingsTable {table} />
</div>
{/if}
{:catch error}
<p>error loading: {error.message}</p>
{/await}
{#await data?.table}
<ProgressRadial/>
{:then table}
{#if table}
<div class="col-span-2 standings-container">
<StandingsTable {table}/>
</div>
{:else }
<p class="col-span-2">No Standings available.</p>
{/if}
{:catch error}
<p>error loading: {error.message}</p>
{/await}
</section>

<section class="my-2">
<h2 class="h2">Statistiken</h2>
{#await getData()}
<ProgressRadial />
{:then stats}
{#if stats.batting && stats.pitching && stats.fielding}
<BaseballStatsDatatable data={stats} tableType="personal" />
{/if}
{:catch error}
<p>error loading: {error.message}</p>
{/await}
<h2 class="h2">Statistiken</h2>
{#await getData()}
<ProgressRadial/>
{:then stats}
{#if stats.batting && stats.pitching && stats.fielding}
<BaseballStatsDatatable data={stats} tableType="personal"/>
{/if}
{:catch error}
<p>error loading: {error.message}</p>
{/await}
</section>

<style lang="postcss">
Expand Down

0 comments on commit 094caf4

Please sign in to comment.