2023-11-12 22:43:42 +01:00
|
|
|
<script lang="ts">
|
|
|
|
import {createEventDispatcher} from "svelte";
|
2023-12-07 00:17:32 +01:00
|
|
|
import {schemRepo} from "../repo/repo";
|
2023-11-12 22:43:42 +01:00
|
|
|
import {Modal, Spinner} from "flowbite-svelte";
|
|
|
|
import SchematicInfoModal from "./SchematicInfoModal.svelte";
|
2023-12-05 17:55:48 +01:00
|
|
|
import type {Player} from "../types/data.ts";
|
2023-11-12 22:43:42 +01:00
|
|
|
|
|
|
|
const dispatch = createEventDispatcher();
|
|
|
|
|
|
|
|
export let schematicId: number;
|
2023-12-05 17:55:48 +01:00
|
|
|
export let user: Player;
|
2023-11-12 22:43:42 +01:00
|
|
|
|
|
|
|
let schemInfo = getSchematicInfo(schematicId);
|
|
|
|
|
|
|
|
function getSchematicInfo(id: number) {
|
|
|
|
return $schemRepo.getSchematicInfo(id);
|
|
|
|
}
|
|
|
|
</script>
|
|
|
|
|
|
|
|
{#await schemInfo}
|
|
|
|
<Modal title="Loading" open on:close={() => dispatch("reset")}>
|
|
|
|
<Spinner />
|
|
|
|
</Modal>
|
|
|
|
{:then info}
|
2023-12-05 17:55:48 +01:00
|
|
|
<SchematicInfoModal {user} {info} on:reset />
|
2023-11-12 22:43:42 +01:00
|
|
|
{:catch e}
|
|
|
|
<Modal title="Error" open on:close={() => dispatch("reset")}>
|
|
|
|
<p>{e.message}</p>
|
|
|
|
<button class="btn !ml-auto" slot="footer" on:click={() => dispatch("reset")}>Close</button>
|
|
|
|
</Modal>
|
|
|
|
{/await}
|