Website/src/components/dashboard/SchematicInfo.svelte

50 Zeilen
1.7 KiB
Svelte

<!--
- This file is a part of the SteamWar software.
-
- Copyright (C) 2023 SteamWar.de-Serverteam
-
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU Affero General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
-
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- GNU Affero General Public License for more details.
-
- You should have received a copy of the GNU Affero General Public License
- along with this program. If not, see <https://www.gnu.org/licenses/>.
-->
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}