Website/src/components/dashboard/SchematicInfo.svelte

51 Zeilen
1.8 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";
2024-01-06 15:08:54 +01:00
import {Spinner} from "flowbite-svelte";
2023-11-12 22:43:42 +01:00
import SchematicInfoModal from "./SchematicInfoModal.svelte";
2023-12-25 21:54:40 +01:00
import type {Player} from "@type/data.ts";
2023-12-27 19:16:54 +01:00
import {schemRepo} from "@repo/schem.ts";
2024-01-06 15:08:54 +01:00
import SWModal from "@components/styled/SWModal.svelte";
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}
2024-01-06 15:08:54 +01:00
<SWModal title="Loading" open on:close={() => dispatch("reset")}>
2023-11-12 22:43:42 +01:00
<Spinner />
2024-01-06 15:08:54 +01:00
</SWModal>
2023-11-12 22:43:42 +01:00
{: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}
2024-01-06 15:08:54 +01:00
<SWModal title="Error" open on:close={() => dispatch("reset")}>
2023-11-12 22:43:42 +01:00
<p>{e.message}</p>
<button class="btn !ml-auto" slot="footer" on:click={() => dispatch("reset")}>Close</button>
2024-01-06 15:08:54 +01:00
</SWModal>
2023-11-12 22:43:42 +01:00
{/await}