<script lang="ts">
    import {Avatar, Navbar, NavBrand, Spinner, TabItem, Tabs} from "flowbite-svelte";
    import EventEdit from "./event/EventEdit.svelte";
    import {ArrowLeftSolid} from "flowbite-svelte-icons";
    import FightList from "./event/FightList.svelte";
    import {eventRepo} from "../../repo/repo.js";
    import TeamList from "./event/TeamList.svelte";
    import GroupGenerator from "./generate/GroupGenerator.svelte";

    export let params: { id: number } = {};

    let id = params.id;
    let event = $eventRepo.getEvent(id.toString());
</script>

{#await event}
    <div class="h-screen w-screen grid place-items-center">
        <Spinner size={16}/>
    </div>
{:then data}
    <Navbar let:hidden let:toggle>
        <NavBrand href="#/event/{id}">
            <ArrowLeftSolid></ArrowLeftSolid>
            <span class="ml-4 self-center whitespace-nowrap text-xl font-semibold dark:text-white">
                {data.event.name} - Generate
            </span>
        </NavBrand>
    </Navbar>

    <Tabs style="pill" class="mx-4 flex shadow-lg border-b-2 border-gray-700 pb-2" contentClass="">
        <TabItem title="Group" open>
            <GroupGenerator {data}/>
        </TabItem>
        <TabItem title="KO">
            <h1>WIP</h1>
        </TabItem>
    </Tabs>
{:catch error}
    <p>
        {error.message}
    </p>
{/await}
