API größtenteils umgezogen und Funktionen angepasst
This commit is contained in:
@@ -1,27 +1,56 @@
|
||||
---
|
||||
import AusweisLayout from "#layouts/AusweisLayoutDaten.astro";
|
||||
import VerbrauchsausweisWohnenModule from "#modules/VerbrauchsausweisWohnen/VerbrauchsausweisWohnenModule.svelte";
|
||||
import { VerbrauchsausweisWohnenClient } from "#components/Ausweis/types";
|
||||
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 = {
|
||||
aufnahme: { objekt: {} },
|
||||
} as VerbrauchsausweisWohnenClient;
|
||||
let ausweis: VerbrauchsausweisWohnenClient = {} as VerbrauchsausweisWohnenClient;
|
||||
let aufnahme: AufnahmeClient = {} as AufnahmeClient;
|
||||
let objekt: ObjektClient = {} as ObjektClient;
|
||||
let bilder: UploadedGebaeudeBild[] = []
|
||||
|
||||
const caller = await createCaller(Astro);
|
||||
const caller = createCaller(Astro);
|
||||
|
||||
if (uid) {
|
||||
try {
|
||||
ausweis = await caller["verbrauchsausweis-wohnen"]._id.GET.fetch(null, {
|
||||
ausweis = await caller["verbrauchsausweis-wohnen"]._uid.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: "Basic "
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
id: "123"
|
||||
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.
|
||||
@@ -38,5 +67,5 @@ if (uid) {
|
||||
---
|
||||
|
||||
<AusweisLayout title="Verbrauchsausweis erstellen">
|
||||
<VerbrauchsausweisWohnenModule client:load ausweis={ausweis} />
|
||||
<VerbrauchsausweisWohnenModule client:load {ausweis} {objekt} {aufnahme} {bilder} />
|
||||
</AusweisLayout>
|
||||
|
||||
Reference in New Issue
Block a user