<script lang="ts">
    import type {Player} from "../types/data.ts";
    import {statsRepo} from "../repo/repo.ts";
    import {t} from "astro-i18n"

    export let user: Player;

    let request = getRequest();

    function getRequest() {
        return $statsRepo.getUserStats(user.id)
    }
</script>

{#await request}
    <p>{t("status.loading")}</p>
{:then data}
    <p>Playtime: {data.playtime}h</p>
    <p>Fights: {data.fights}</p>
    {#if user.perms.includes("CHECK")}
        <p>Schematics Checked: {data.acceptedSchematics}</p>
    {/if}
{:catch error}
    <p>error: {error}</p>
{/await}