Lib: Remove SkeletonData schema and use correct PageData types instead

This commit is contained in:
2025-02-17 23:31:57 +01:00
parent 4a1fcc6447
commit 5f73f0f952
7 changed files with 20 additions and 41 deletions

View File

@ -9,7 +9,7 @@
type ToastStore,
} from "@skeletonlabs/skeleton";
import { Button, Input, Card, Dropdown } from "$lib/components";
import type { Driver, SkeletonData } from "$lib/schema";
import type { Driver } from "$lib/schema";
import { DRIVER_HEADSHOT_HEIGHT, DRIVER_HEADSHOT_WIDTH } from "$lib/config";
import { team_dropdown_options } from "$lib/dropdown";
import { get_driver_headshot_template } from "$lib/database";
@ -17,10 +17,11 @@
import { pb } from "$lib/pocketbase";
import { invalidateAll } from "$app/navigation";
import { error } from "@sveltejs/kit";
import type { PageData } from "../../../routes/data/season/drivers/$types";
interface DriverCardProps {
/** Data passed from the page context */
data: SkeletonData;
data: PageData;
/** The [Driver] object used to prefill values. */
driver?: Driver;

View File

@ -8,7 +8,7 @@
type ToastStore,
} from "@skeletonlabs/skeleton";
import { Button, Card, Input } from "$lib/components";
import type { Race, SkeletonData } from "$lib/schema";
import type { Race } from "$lib/schema";
import { RACE_PICTOGRAM_HEIGHT, RACE_PICTOGRAM_WIDTH } from "$lib/config";
import { get_race_pictogram_template } from "$lib/database";
import { format_date } from "$lib/date";
@ -16,10 +16,11 @@
import { pb } from "$lib/pocketbase";
import { invalidateAll } from "$app/navigation";
import { error } from "@sveltejs/kit";
import type { PageData } from "../../../routes/data/season/races/$types";
interface RaceCardProps {
/** Data passed from the page context */
data: SkeletonData;
data: PageData;
/** The [Race] object used to prefill values. */
race?: Race;

View File

@ -1,14 +1,6 @@
<script lang="ts">
import { Card, Button, Dropdown } from "$lib/components";
import type {
CurrentPickedUser,
Driver,
Race,
RacePick,
RaceResult,
SkeletonData,
Substitution,
} from "$lib/schema";
import type { Driver, RacePick, Substitution } from "$lib/schema";
import { get_by_value, get_driver_headshot_template } from "$lib/database";
import {
getModalStore,
@ -21,15 +13,11 @@
import { get_error_toast } from "$lib/toast";
import { invalidateAll } from "$app/navigation";
import { pb } from "$lib/pocketbase";
import type { PageData } from "../../../routes/racepicks/$types";
interface RacePickCardProps {
/** Data passed from the page context */
data: SkeletonData & {
currentrace: Race;
racepicks: Promise<RacePick[]>;
currentpickedusers: Promise<CurrentPickedUser[]>;
raceresults: Promise<RaceResult[]>;
};
data: PageData;
/** The [RacePick] object used to prefill values. */
racepick?: RacePick;
@ -59,7 +47,7 @@
// Reactive state
let required: boolean = $derived(!racepick);
let disabled: boolean = $derived(!data.admin);
let disabled: boolean = false; // TODO: Datelock
let pxx_select_value: string = $state(racepick?.pxx ?? "");
let dnf_select_value: string = $state(racepick?.dnf ?? "");

View File

@ -9,16 +9,17 @@
type ToastStore,
} from "@skeletonlabs/skeleton";
import { Button, Card, Dropdown } from "$lib/components";
import type { Driver, Race, RaceResult, SkeletonData } from "$lib/schema";
import type { Driver, Race, RaceResult } from "$lib/schema";
import { get_by_value } from "$lib/database";
import { race_dropdown_options } from "$lib/dropdown";
import { pb } from "$lib/pocketbase";
import { get_error_toast } from "$lib/toast";
import { invalidateAll } from "$app/navigation";
import type { PageData } from "../../../routes/data/raceresults/$types";
interface RaceResultCardProps {
/** Data passed from the page context */
data: SkeletonData & { results: RaceResult[] };
data: PageData;
/** The [RaceResult] object used to prefill values. */
result?: RaceResult;

View File

@ -1,6 +1,6 @@
<script lang="ts">
import { Card, Button, Dropdown } from "$lib/components";
import type { Driver, SkeletonData, Substitution } from "$lib/schema";
import type { Driver, Substitution } from "$lib/schema";
import { get_by_value, get_driver_headshot_template } from "$lib/database";
import {
getModalStore,
@ -13,10 +13,11 @@
import { get_error_toast } from "$lib/toast";
import { pb } from "$lib/pocketbase";
import { invalidateAll } from "$app/navigation";
import type { PageData } from "../../../routes/data/season/substitutions/$types";
interface SubstitutionCardProps {
/** Data passed from the page context */
data: SkeletonData;
data: PageData;
/** The [Substitution] object used to prefill values. */
substitution?: Substitution;

View File

@ -8,7 +8,7 @@
type ToastStore,
} from "@skeletonlabs/skeleton";
import { Card, Button, Input, LazyImage } from "$lib/components";
import type { SkeletonData, Team } from "$lib/schema";
import type { Team } from "$lib/schema";
import {
TEAM_BANNER_HEIGHT,
TEAM_BANNER_WIDTH,
@ -20,10 +20,11 @@
import { pb } from "$lib/pocketbase";
import { invalidateAll } from "$app/navigation";
import { error } from "@sveltejs/kit";
import type { PageData } from "../../../routes/data/season/teams/$types";
interface TeamCardProps {
/** Data from the page context */
data: SkeletonData;
data: PageData;
/** The [Team] object used to prefill values. */
team?: Team;

View File

@ -3,20 +3,6 @@
// Application Data
/**
* The data returned from the root layout's [load]-function.
*/
export interface SkeletonData {
user: User;
admin: boolean;
graphics: Promise<Graphic[]>;
teams: Promise<Team[]>;
drivers: Promise<Driver[]>;
races: Promise<Race[]>;
substitutions: Promise<Substitution[]>;
}
export interface Graphic {
name: string;
file: string;
@ -27,7 +13,7 @@ export interface User {
id: string;
username: string;
firstname: string;
avatar: string;
avatar?: string;
avatar_url?: string;
admin: boolean;
}