Website/src/components/dashboard/SchematicInfo.svelte

35 Zeilen
1.1 KiB
Svelte

2023-11-12 22:43:42 +01:00
<script lang="ts">
import {t} from "astro-i18n"
import {createEventDispatcher} from "svelte";
import {schemRepo} from "../repo/repo.ts";
import {Modal, Spinner} from "flowbite-svelte";
import {astroI18n} from "astro-i18n";
import moment from "moment/moment";
import {CheckSolid, XCircleOutline} from "flowbite-svelte-icons";
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}