<script lang="ts">
    import { schemRepo } from "@repo/schem.ts";

    let code = $derived(new URLSearchParams(window.location.search).get("code") || "");

    let downloadUrl = $derived($schemRepo.getSchematicDownloadUrl(code));
    let schematic = $derived($schemRepo.getSchematicCodeInfo(code));
</script>

{#await schematic then schem}
    <h1 class="text-2xl font-bold">{schem.name}</h1>
    <div class="flex justify-center">
        <a href={downloadUrl} class="btn" target="_blank">Download</a>
    </div>
{:catch error}
    <p>{error.message}</p>
{/await}
