72 lines
2.1 KiB
Plaintext
72 lines
2.1 KiB
Plaintext
---
|
|
import AusweisLayout from "#layouts/AusweisLayoutDaten.astro";
|
|
import VerbrauchsausweisWohnenModule from "#modules/VerbrauchsausweisWohnen/VerbrauchsausweisWohnenModule.svelte";
|
|
import { AufnahmeClient, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types";
|
|
import { createCaller } from "../../../astro-typesafe-api-caller.js";
|
|
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants";
|
|
|
|
const uid = Astro.url.searchParams.get("uid");
|
|
let ausweis: VerbrauchsausweisWohnenClient = {} as VerbrauchsausweisWohnenClient;
|
|
let aufnahme: AufnahmeClient = {} as AufnahmeClient;
|
|
let objekt: ObjektClient = {} as ObjektClient;
|
|
let bilder: UploadedGebaeudeBild[] = []
|
|
|
|
const caller = createCaller(Astro);
|
|
|
|
if (uid) {
|
|
try {
|
|
ausweis = await caller["verbrauchsausweis-wohnen"]._uid.GET.fetch(null, {
|
|
headers: {
|
|
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
|
},
|
|
params: {
|
|
uid
|
|
}
|
|
});
|
|
|
|
aufnahme = await caller.aufnahme._uid.GET.fetch(null, {
|
|
headers: {
|
|
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
|
},
|
|
params: {
|
|
uid: ausweis.uid_aufnahme
|
|
}
|
|
})
|
|
|
|
objekt = await caller.objekt._uid.GET.fetch(null, {
|
|
headers: {
|
|
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
|
},
|
|
params: {
|
|
uid: ausweis.uid_objekt
|
|
}
|
|
})
|
|
|
|
bilder = await caller.objekt._uid.bilder.GET.fetch(null, {
|
|
headers: {
|
|
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
|
},
|
|
params: {
|
|
uid: ausweis.uid_objekt
|
|
}
|
|
})
|
|
|
|
if (!ausweis) {
|
|
// Der Ausweis scheint nicht zu existieren.
|
|
// Wir leiten auf die generische Ausweisseite ohne UID weiter.
|
|
return Astro.redirect(
|
|
"/energieausweis-erstellen/verbrauchsausweis-wohnen"
|
|
);
|
|
}
|
|
} catch(e) {
|
|
return Astro.redirect(
|
|
"/energieausweis-erstellen/verbrauchsausweis-wohnen"
|
|
);
|
|
}
|
|
}
|
|
---
|
|
|
|
<AusweisLayout title="Verbrauchsausweis erstellen">
|
|
<VerbrauchsausweisWohnenModule client:load {ausweis} {objekt} {aufnahme} {bilder} />
|
|
</AusweisLayout>
|