Data: Disable "Create" buttons for non-admins
This commit is contained in:
@ -5,9 +5,12 @@
|
||||
import { get_by_value } from "$lib/database";
|
||||
import { PXX_COLORS } from "$lib/config";
|
||||
import type { RaceResult } from "$lib/schema";
|
||||
import { pbUser } from "$lib/pocketbase";
|
||||
|
||||
let { data }: { data: PageData } = $props();
|
||||
|
||||
let disabled: boolean = $derived(!$pbUser?.admin);
|
||||
|
||||
const modalStore: ModalStore = getModalStore();
|
||||
|
||||
const result_handler = async (event: Event, id?: string) => {
|
||||
@ -92,7 +95,7 @@
|
||||
</svelte:head>
|
||||
|
||||
<div class="pb-2">
|
||||
<Button width="w-full" color="tertiary" onclick={result_handler} shadow>
|
||||
<Button width="w-full" color="tertiary" onclick={result_handler} shadow {disabled}>
|
||||
<span class="font-bold">Create Race Result</span>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@ -4,9 +4,12 @@
|
||||
import type { Driver, Team } from "$lib/schema";
|
||||
import { getModalStore, type ModalSettings, type ModalStore } from "@skeletonlabs/skeleton";
|
||||
import type { PageData } from "./$types";
|
||||
import { pbUser } from "$lib/pocketbase";
|
||||
|
||||
let { data }: { data: PageData } = $props();
|
||||
|
||||
let disabled: boolean = $derived(!$pbUser?.admin);
|
||||
|
||||
const modalStore: ModalStore = getModalStore();
|
||||
const driver_handler = async (event: Event, id?: string) => {
|
||||
const driver: Driver | undefined = get_by_value(await data.drivers, "id", id ?? "Invalid");
|
||||
@ -73,10 +76,10 @@
|
||||
</svelte:head>
|
||||
|
||||
<div class="flex gap-2 pb-2">
|
||||
<Button width="w-full" color="tertiary" onclick={driver_handler} shadow>
|
||||
<Button width="w-full" color="tertiary" onclick={driver_handler} shadow {disabled}>
|
||||
<span class="font-bold">Create New Driver</span>
|
||||
</Button>
|
||||
<Button width="w-full" color="secondary" onclick={teamswitch_handler} shadow>
|
||||
<Button width="w-full" color="secondary" onclick={teamswitch_handler} shadow {disabled}>
|
||||
<span class="font-bold">Switch Driver Team</span>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@ -5,9 +5,12 @@
|
||||
import { get_by_value } from "$lib/database";
|
||||
import type { Race } from "$lib/schema";
|
||||
import { format_date, shortdatetimeformat } from "$lib/date";
|
||||
import { pbUser } from "$lib/pocketbase";
|
||||
|
||||
let { data }: { data: PageData } = $props();
|
||||
|
||||
let disabled: boolean = $derived(!$pbUser?.admin);
|
||||
|
||||
const modalStore: ModalStore = getModalStore();
|
||||
|
||||
const race_handler = async (event: Event, id?: string) => {
|
||||
@ -64,7 +67,7 @@
|
||||
</svelte:head>
|
||||
|
||||
<div class="pb-2">
|
||||
<Button width="w-full" color="tertiary" onclick={race_handler} shadow>
|
||||
<Button width="w-full" color="tertiary" onclick={race_handler} shadow {disabled}>
|
||||
<span class="font-bold">Create New Race</span>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@ -4,9 +4,12 @@
|
||||
import type { PageData } from "./$types";
|
||||
import type { Race, Substitution } from "$lib/schema";
|
||||
import { Button, Table, type TableColumn } from "$lib/components";
|
||||
import { pbUser } from "$lib/pocketbase";
|
||||
|
||||
let { data }: { data: PageData } = $props();
|
||||
|
||||
let disabled: boolean = $derived(!$pbUser?.admin);
|
||||
|
||||
const modalStore: ModalStore = getModalStore();
|
||||
const substitution_handler = async (event: Event, id?: string) => {
|
||||
const substitution: Substitution | undefined = get_by_value(
|
||||
@ -64,7 +67,7 @@
|
||||
</svelte:head>
|
||||
|
||||
<div class="pb-2">
|
||||
<Button width="w-full" color="tertiary" onclick={substitution_handler} shadow>
|
||||
<Button width="w-full" color="tertiary" onclick={substitution_handler} shadow {disabled}>
|
||||
<span class="font-bold">Create New Substitution</span>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@ -4,9 +4,12 @@
|
||||
import { getModalStore, type ModalSettings, type ModalStore } from "@skeletonlabs/skeleton";
|
||||
import type { PageData } from "./$types";
|
||||
import { get_by_value } from "$lib/database";
|
||||
import { pbUser } from "$lib/pocketbase";
|
||||
|
||||
let { data }: { data: PageData } = $props();
|
||||
|
||||
let disabled: boolean = $derived(!$pbUser?.admin);
|
||||
|
||||
const modalStore: ModalStore = getModalStore();
|
||||
const team_handler = async (event: Event, id?: string) => {
|
||||
const team: Team | undefined = get_by_value(await data.teams, "id", id ?? "Invalid");
|
||||
@ -47,7 +50,7 @@
|
||||
</svelte:head>
|
||||
|
||||
<div class="pb-2">
|
||||
<Button width="w-full" color="tertiary" onclick={team_handler} shadow>
|
||||
<Button width="w-full" color="tertiary" onclick={team_handler} shadow {disabled}>
|
||||
<span class="font-bold">Create New Team</span>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user