diff --git a/src/components/Dashboard/DashboardAusweis.svelte b/src/components/Dashboard/DashboardAusweis.svelte index 6aabea27..70372d10 100644 --- a/src/components/Dashboard/DashboardAusweis.svelte +++ b/src/components/Dashboard/DashboardAusweis.svelte @@ -16,6 +16,7 @@ import { Enums, Objekt } from "#lib/client/prisma.js"; import { endEnergieVerbrauchVerbrauchsausweisGewerbe_2016 } from "#lib/Berechnungen/VerbrauchsausweisGewerbe/VerbrauchsausweisGewerbe_2016.js"; import { shortenUID } from "#server/lib/hash.js"; + import { addNotification } from "#components/Notifications/shared.js"; export let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | BedarfsausweisWohnenClient; export let aufnahme: AufnahmeKomplettClient; @@ -91,6 +92,75 @@ calculations = endEnergieVerbrauchVerbrauchsausweisGewerbe_2016(ausweis as VerbrauchsausweisGewerbeClient, aufnahme, objekt); } + async function registriernummerAnfordern() { + try { + const result = await api.admin.registriernummer.GET.fetch({ + uid: ausweis.uid + }, { + headers: { + "Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}` + } + }) + } catch(e) { + addNotification({ + message: "Registriernummer anfordern fehlgeschlagen.", + subtext: e as string, + type: "error", + dismissable: true, + timeout: 3000, + }) + } + } + + async function stornieren() { + try { + const response = await api.admin.stornieren.PUT.fetch({ + uid_ausweis: ausweis.uid + }, { + headers: { + "Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}` + } + }) + + addNotification({ + message: "Ausweis wurde storniert", + type: "success", + dismissable: true, + timeout: 3000, + }) + + ausweis.storniert = true; + ausweis = ausweis; + } catch(e) { + addNotification({ + message: "Ausweis konnte nicht storniert werden.", + subtext: e as string, + type: "error", + dismissable: true, + timeout: 3000, + }) + } + } + + async function ausweisAusstellen() { + try { + await api.admin.ausstellen.GET.fetch({ + uid_ausweis: ausweis.uid + }, { + headers: { + "Authorization": `Bearer ${Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)}` + } + }) + } catch(e) { + addNotification({ + message: "Das hat nicht geklappt.", + subtext: e as string, + timeout: 3000, + type: "error", + }) + } + } +
@@ -222,7 +292,7 @@
{/await} -
+
{#if !ausweis.storniert && !ausweis.ausgestellt}