linting with biome...
This commit is contained in:
parent
da2e7da762
commit
f19b9f3b36
263 changed files with 3013 additions and 2754 deletions
|
@ -1,66 +1,78 @@
|
|||
<script lang="ts">
|
||||
import Button from '$ui/button/button.svelte';
|
||||
import CardContent from '$ui/card/card-content.svelte';
|
||||
import CardHeader from '$ui/card/card-header.svelte';
|
||||
import Card from '$ui/card/card.svelte';
|
||||
import Input from '$ui/input/input.svelte';
|
||||
import Label from '$ui/label/label.svelte';
|
||||
import RadioGroupItem from '$ui/radio-group/radio-group-item.svelte';
|
||||
import RadioGroup from '$ui/radio-group/radio-group.svelte';
|
||||
import type { Bracket } from '@/lib/server/db/schema/brackets';
|
||||
import type { Round } from '@/lib/server/db/schema/rounds';
|
||||
import { cn, instanceOf } from '@/lib/utils';
|
||||
import { SchedulingMode } from '@/types';
|
||||
import { ArrowRightIcon, CircleQuestionMarkIcon } from 'lucide-svelte';
|
||||
import { _ } from 'svelte-i18n';
|
||||
import { toast } from 'svelte-sonner';
|
||||
import { Tooltip, TooltipProvider } from '../ui/tooltip';
|
||||
import TooltipContent from '../ui/tooltip/tooltip-content.svelte';
|
||||
import TooltipTrigger from '../ui/tooltip/tooltip-trigger.svelte';
|
||||
import { ArrowRightIcon, CircleQuestionMarkIcon } from 'lucide-svelte';
|
||||
import { _ } from 'svelte-i18n';
|
||||
import { toast } from 'svelte-sonner';
|
||||
import type { Bracket } from '@/lib/server/db/schema/brackets';
|
||||
import type { Round } from '@/lib/server/db/schema/rounds';
|
||||
import { cn, instanceOf } from '@/lib/utils';
|
||||
import { SchedulingMode } from '@/types';
|
||||
import Button from '$ui/button/button.svelte';
|
||||
import Card from '$ui/card/card.svelte';
|
||||
import CardContent from '$ui/card/card-content.svelte';
|
||||
import CardHeader from '$ui/card/card-header.svelte';
|
||||
import Input from '$ui/input/input.svelte';
|
||||
import Label from '$ui/label/label.svelte';
|
||||
import RadioGroup from '$ui/radio-group/radio-group.svelte';
|
||||
import RadioGroupItem from '$ui/radio-group/radio-group-item.svelte';
|
||||
import { Tooltip, TooltipProvider } from '../ui/tooltip';
|
||||
import TooltipContent from '../ui/tooltip/tooltip-content.svelte';
|
||||
import TooltipTrigger from '../ui/tooltip/tooltip-trigger.svelte';
|
||||
|
||||
let {
|
||||
competitionId,
|
||||
brackets = $bindable(),
|
||||
showAddBracket = $bindable(true)
|
||||
}: { competitionId: string; brackets: Bracket[]; showAddBracket: boolean } = $props();
|
||||
let {
|
||||
competitionId,
|
||||
brackets = $bindable(),
|
||||
showAddBracket = $bindable(true)
|
||||
}: {
|
||||
competitionId: string;
|
||||
brackets: Bracket[];
|
||||
showAddBracket: boolean;
|
||||
} = $props();
|
||||
|
||||
let schedulingMode: SchedulingMode = $state(SchedulingMode.single);
|
||||
let name = $state('');
|
||||
let nameInvalid = $state(false);
|
||||
let size: number | undefined = $state();
|
||||
let sizeInvalid = $state(false);
|
||||
let schedulingMode: SchedulingMode = $state(SchedulingMode.single);
|
||||
let name = $state('');
|
||||
let nameInvalid = $state(false);
|
||||
let size: number | undefined = $state();
|
||||
let sizeInvalid = $state(false);
|
||||
|
||||
let buttonDisabled = $state(false);
|
||||
let buttonDisabled = $state(false);
|
||||
|
||||
async function submit() {
|
||||
if (name.length === 0) {
|
||||
nameInvalid = true;
|
||||
toast.error('Name is required');
|
||||
return;
|
||||
}
|
||||
if (!size || size < 0) {
|
||||
sizeInvalid = true;
|
||||
toast.error('Number of matches must be greater than 0');
|
||||
return;
|
||||
}
|
||||
nameInvalid = false;
|
||||
// loading/disable button
|
||||
buttonDisabled = true;
|
||||
const response = await fetch(`/api/competitions/${competitionId}`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
body: JSON.stringify({ scheduling_mode: schedulingMode, name: name, size: size })
|
||||
});
|
||||
// update rounds
|
||||
const data = await response.json();
|
||||
buttonDisabled = false;
|
||||
if (Array.isArray(data) && data.length > 0 && instanceOf<Bracket>(data[0], 'id')) {
|
||||
brackets = [...brackets, data[0]];
|
||||
showAddBracket = false;
|
||||
} else {
|
||||
throw new Error('Invalid bracket');
|
||||
}
|
||||
async function submit() {
|
||||
if (name.length === 0) {
|
||||
nameInvalid = true;
|
||||
toast.error('Name is required');
|
||||
return;
|
||||
}
|
||||
if (!size || size < 0) {
|
||||
sizeInvalid = true;
|
||||
toast.error('Number of matches must be greater than 0');
|
||||
return;
|
||||
}
|
||||
nameInvalid = false;
|
||||
// loading/disable button
|
||||
buttonDisabled = true;
|
||||
const response = await fetch(`/api/competitions/${competitionId}`, {
|
||||
method: 'POST',
|
||||
credentials: 'include',
|
||||
body: JSON.stringify({
|
||||
scheduling_mode: schedulingMode,
|
||||
name: name,
|
||||
size: size
|
||||
})
|
||||
});
|
||||
// update rounds
|
||||
const data = await response.json();
|
||||
buttonDisabled = false;
|
||||
if (
|
||||
Array.isArray(data) &&
|
||||
data.length > 0 &&
|
||||
instanceOf<Bracket>(data[0], 'id')
|
||||
) {
|
||||
brackets = [...brackets, data[0]];
|
||||
showAddBracket = false;
|
||||
} else {
|
||||
throw new Error('Invalid bracket');
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="flex flex-col gap-4">
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue