Admin Tools
This commit is contained in:
@@ -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",
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
</script>
|
||||
|
||||
<div class="relative bg-base-200 border border-base-300 rounded-lg p-4 mr-4">
|
||||
@@ -222,7 +292,7 @@
|
||||
</div>
|
||||
{/await}
|
||||
|
||||
<div class="flex flex-row justify-end gap-4 mt-4">
|
||||
<div class="flex flex-row justify-end items-center gap-4 mt-4">
|
||||
{#if !ausweis.storniert && !ausweis.ausgestellt}
|
||||
<!--
|
||||
<a
|
||||
@@ -266,6 +336,12 @@
|
||||
>Formular</a>
|
||||
{/if}
|
||||
{/if}
|
||||
|
||||
{#if benutzer.rolle === Enums.BenutzerRolle.ADMIN}
|
||||
<button class="button text-sm" on:click={ausweisAusstellen}>A</button>
|
||||
<button class="button text-sm" on:click={stornieren}>S</button>
|
||||
<button class="button text-sm" on:click={registriernummerAnfordern}>R</button>
|
||||
{/if}
|
||||
|
||||
<a
|
||||
class="p-2 rounded-lg hover:bg-gray-200"
|
||||
@@ -273,7 +349,15 @@
|
||||
target="_blank"
|
||||
href="/pdf/ansichtsausweis?uid={ausweis.uid}"
|
||||
>
|
||||
<Download size={22} />
|
||||
<img src="/images/ausweis.webp" width="32" alt="Energieausweis">
|
||||
</a>
|
||||
<a
|
||||
class="p-2 rounded-lg hover:bg-gray-200"
|
||||
title="PDF Herunterladen"
|
||||
target="_blank"
|
||||
href="/pdf/datenblatt?uid={ausweis.uid}"
|
||||
>
|
||||
<img src="/images/datenblatt.webp" width="32" alt="Datenblatt">
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
class="flex p-2 hover:bg-gray-200 rounded-lg">
|
||||
<ChevronLeft></ChevronLeft>
|
||||
</a>
|
||||
<p>{current} of {pages}</p>
|
||||
<p>{current} von {pages}</p>
|
||||
<a href={next}
|
||||
class:disabled={current === pages ? true : false}
|
||||
aria-label="right arrow icon"
|
||||
|
||||
Reference in New Issue
Block a user