Verbesserungen im Prozess
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
---
|
||||
import AusweisLayout from "#layouts/AusweisLayoutDaten.astro";
|
||||
import { AufnahmeClient, GEGNachweisWohnenClient, ObjektClient, UnterlageClient, UploadedGebaeudeBild } from "#components/Ausweis/types";
|
||||
import { AufnahmeClient, GEGNachweisWohnenClient, ObjektClient, UnterlageClient, BildClient } from "#components/Ausweis/types";
|
||||
import { createCaller } from "src/astro-typesafe-api-caller";
|
||||
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants.js";
|
||||
import { validateAccessTokenServer } from "#server/lib/validateAccessToken.js";
|
||||
@@ -10,7 +10,7 @@ const uid = Astro.url.searchParams.get("uid");
|
||||
let nachweis: GEGNachweisWohnenClient = {} as GEGNachweisWohnenClient;
|
||||
let aufnahme: AufnahmeClient = {} as AufnahmeClient;
|
||||
let objekt: ObjektClient = {} as ObjektClient;
|
||||
let bilder: UploadedGebaeudeBild[] = []
|
||||
let bilder: BildClient[] = []
|
||||
let unterlagen: UnterlageClient[] = []
|
||||
|
||||
const valid = validateAccessTokenServer(Astro);
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AufnahmeClient, ObjektClient, UploadedGebaeudeBild, UUidWithPrefix, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
|
||||
import { AufnahmeClient, ObjektClient, BildClient, UUidWithPrefix, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
|
||||
import { filterAusweise } from "#lib/filters.js";
|
||||
import { omit } from "#lib/helpers.js";
|
||||
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
|
||||
@@ -18,7 +18,7 @@ export const GET = defineApiRoute({
|
||||
if (user.rolle !== Enums.BenutzerRolle.ADMIN) {
|
||||
input.filters = input.filters || {}
|
||||
input.filters["benutzer"] = {
|
||||
uid: user.uid
|
||||
id: user.id
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,7 +43,7 @@ export const GET = defineApiRoute({
|
||||
ausweis: omit(ausweis, ["aufnahme"]) as VerbrauchsausweisWohnenClient,
|
||||
aufnahme: omit(omit(ausweis.aufnahme, ["events"]), ["objekt"]) as AufnahmeClient,
|
||||
objekt: omit(ausweis.aufnahme.objekt, ["bilder"]) as ObjektClient,
|
||||
bilder: ausweis.aufnahme.bilder as unknown as UploadedGebaeudeBild[],
|
||||
bilder: ausweis.aufnahme.bilder as unknown as BildClient[],
|
||||
events: ausweis.aufnahme.events
|
||||
}))
|
||||
},
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
import { AufnahmeClient, BenutzerClient, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types";
|
||||
import { AufnahmeClient, BenutzerClient, ObjektClient, BildClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types";
|
||||
import UserLayout from "#layouts/DashboardLayout.astro";
|
||||
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants";
|
||||
import { omit } from "#lib/helpers";
|
||||
@@ -31,7 +31,7 @@ if (user.rolle !== Enums.BenutzerRolle.ADMIN) {
|
||||
const ausweise = await prisma.verbrauchsausweisWohnen.findMany({
|
||||
where: {
|
||||
benutzer: {
|
||||
uid: user.uid
|
||||
id: user.id
|
||||
}
|
||||
},
|
||||
include: {
|
||||
@@ -50,7 +50,7 @@ const ausweise = await prisma.verbrauchsausweisWohnen.findMany({
|
||||
const totalPages = await prisma.verbrauchsausweisWohnen.count({
|
||||
where: {
|
||||
benutzer: {
|
||||
uid: user.uid
|
||||
id: user.id
|
||||
}
|
||||
}
|
||||
})
|
||||
@@ -59,7 +59,7 @@ const reformedAusweise = ausweise.map(ausweis => ({
|
||||
ausweis: omit(ausweis, ["aufnahme"]) as VerbrauchsausweisWohnenClient,
|
||||
aufnahme: omit(omit(ausweis.aufnahme, ["events"]), ["objekt"]) as AufnahmeClient,
|
||||
objekt: omit(ausweis.aufnahme.objekt, ["bilder"]) as ObjektClient,
|
||||
bilder: ausweis.aufnahme.bilder as unknown as UploadedGebaeudeBild[],
|
||||
bilder: ausweis.aufnahme.bilder as unknown as BildClient[],
|
||||
events: ausweis.aufnahme.events
|
||||
}))
|
||||
---
|
||||
|
||||
@@ -6,7 +6,7 @@ import { Enums, prisma } from "#lib/server/prisma";
|
||||
import UserLayout from "#layouts/DashboardLayout.astro";
|
||||
import DashboardAufnahmeModule from "#modules/Dashboard/DashboardAufnahmeModule.svelte";
|
||||
|
||||
const { uid } = Astro.params;
|
||||
const { id } = Astro.params;
|
||||
|
||||
const accessTokenValid = await validateAccessTokenServer(Astro);
|
||||
|
||||
@@ -30,10 +30,10 @@ if (!user) {
|
||||
const aufnahme = await prisma.aufnahme.findUnique({
|
||||
where: user.rolle === Enums.BenutzerRolle.USER ? {
|
||||
benutzer: {
|
||||
uid: user.uid
|
||||
id: user.id
|
||||
},
|
||||
uid
|
||||
} : { uid },
|
||||
id
|
||||
} : { id },
|
||||
include: {
|
||||
objekt: true,
|
||||
bilder: true,
|
||||
@@ -26,7 +26,7 @@ if (!user) {
|
||||
const totalPages = await prisma.objekt.count({
|
||||
where: user.rolle === Enums.BenutzerRolle.USER ? {
|
||||
benutzer: {
|
||||
uid: user.uid
|
||||
id: user.id
|
||||
}
|
||||
} : {}
|
||||
})
|
||||
@@ -34,7 +34,7 @@ const totalPages = await prisma.objekt.count({
|
||||
const objekte = await prisma.objekt.findMany({
|
||||
where: user.rolle === Enums.BenutzerRolle.USER ? {
|
||||
benutzer: {
|
||||
uid: user.uid
|
||||
id: user.id
|
||||
},
|
||||
} : {
|
||||
...(id ? {OR: [
|
||||
|
||||
@@ -2,25 +2,25 @@
|
||||
|
||||
import AusweisLayout from "#layouts/AusweisLayoutDaten.astro";
|
||||
import BedarfsausweisWohnenModule from "#modules/BedarfsausweisWohnen/BedarfsausweisWohnenModule.svelte";
|
||||
import { AufnahmeClient, BedarfsausweisWohnenClient, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types";
|
||||
import { AufnahmeClient, ObjektClient, BildClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types";
|
||||
import { createCaller } from "src/astro-typesafe-api-caller";
|
||||
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants";
|
||||
import { validateAccessTokenServer } from "#server/lib/validateAccessToken";
|
||||
import { Enums } from "#lib/server/prisma";
|
||||
|
||||
const uid = Astro.url.searchParams.get("uid") || "";
|
||||
const uid_aufnahme = Astro.url.searchParams.get("aufnahme")
|
||||
const id = Astro.url.searchParams.get("uid") || "";
|
||||
const aufnahme_id = Astro.url.searchParams.get("aufnahme")
|
||||
const ausweistyp = Astro.url.searchParams.get("ausweistyp") || Enums.AusweisTyp.Standard;
|
||||
let ausweis: VerbrauchsausweisWohnenClient = {} as VerbrauchsausweisWohnenClient;
|
||||
let aufnahme: AufnahmeClient = {} as AufnahmeClient;
|
||||
let objekt: ObjektClient = {} as ObjektClient;
|
||||
let bilder: UploadedGebaeudeBild[] = []
|
||||
let bilder: BildClient[] = []
|
||||
|
||||
const valid = validateAccessTokenServer(Astro);
|
||||
|
||||
const caller = createCaller(Astro);
|
||||
|
||||
if (uid) {
|
||||
if (id) {
|
||||
if (!valid) {
|
||||
return Astro.redirect(
|
||||
`/auth/login?redirect=${Astro.url.toString()}`
|
||||
@@ -28,39 +28,39 @@ if (uid) {
|
||||
}
|
||||
|
||||
try {
|
||||
ausweis = await caller["bedarfsausweis-wohnen"]._uid.GET.fetch(null, {
|
||||
ausweis = await caller["bedarfsausweis-wohnen"]._id.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid
|
||||
id
|
||||
}
|
||||
});
|
||||
|
||||
aufnahme = await caller.aufnahme._uid.GET.fetch(null, {
|
||||
aufnahme = await caller.aufnahme._id.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid: ausweis.uid_aufnahme
|
||||
id: ausweis.aufnahme_id
|
||||
}
|
||||
})
|
||||
|
||||
objekt = await caller.objekt._uid.GET.fetch(null, {
|
||||
objekt = await caller.objekt._id.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid: ausweis.uid_objekt
|
||||
id: ausweis.objekt_id
|
||||
}
|
||||
})
|
||||
|
||||
bilder = await caller.aufnahme._uid.bilder.GET.fetch(null, {
|
||||
bilder = await caller.aufnahme._id.bilder.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid: ausweis.uid_aufnahme
|
||||
id: ausweis.aufnahme_id
|
||||
}
|
||||
})
|
||||
|
||||
@@ -81,5 +81,5 @@ if (uid) {
|
||||
|
||||
---
|
||||
<AusweisLayout title="Bedarfsausweis erstellen | IBCornelsen">
|
||||
<BedarfsausweisWohnenModule client:only {ausweis} {objekt} {aufnahme} {bilder} {ausweistyp} {uid}></BedarfsausweisWohnenModule>
|
||||
<BedarfsausweisWohnenModule client:only {ausweis} {objekt} {aufnahme} {bilder} {ausweistyp} {id}></BedarfsausweisWohnenModule>
|
||||
</AusweisLayout>
|
||||
@@ -1,26 +1,26 @@
|
||||
---
|
||||
import AusweisLayout from "#layouts/AusweisLayoutDaten.astro";
|
||||
import { AufnahmeClient, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisGewerbeClient } from "#components/Ausweis/types";
|
||||
import { AufnahmeClient, ObjektClient, BildClient, VerbrauchsausweisGewerbeClient } from "#components/Ausweis/types";
|
||||
import { createCaller } from "src/astro-typesafe-api-caller";
|
||||
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants";
|
||||
import { validateAccessTokenServer } from "#server/lib/validateAccessToken";
|
||||
import VerbrauchsausweisGewerbeModule from "#modules/VerbrauchsausweisGewerbe/VerbrauchsausweisGewerbeModule.svelte";
|
||||
import { Enums } from "#lib/server/prisma";
|
||||
|
||||
const uid = Astro.url.searchParams.get("uid");
|
||||
const uid_aufnahme = Astro.url.searchParams.get("aufnahme")
|
||||
const id = Astro.url.searchParams.get("uid");
|
||||
const aufnahme_id = Astro.url.searchParams.get("aufnahme")
|
||||
const ausweistyp = Astro.url.searchParams.get("ausweistyp") || Enums.AusweisTyp.Standard;
|
||||
|
||||
let ausweis: VerbrauchsausweisGewerbeClient = {} as VerbrauchsausweisGewerbeClient;
|
||||
let aufnahme: AufnahmeClient = {} as AufnahmeClient;
|
||||
let objekt: ObjektClient = {} as ObjektClient;
|
||||
let bilder: UploadedGebaeudeBild[] = []
|
||||
let bilder: BildClient[] = []
|
||||
|
||||
const valid = validateAccessTokenServer(Astro);
|
||||
|
||||
const caller = createCaller(Astro);
|
||||
|
||||
if (uid) {
|
||||
if (id) {
|
||||
if (!valid) {
|
||||
return Astro.redirect(
|
||||
`/auth/login?redirect=${Astro.url.toString()}`
|
||||
@@ -28,41 +28,41 @@ if (uid) {
|
||||
}
|
||||
|
||||
try {
|
||||
let { uid_aufnahme, uid_objekt, uid_benutzer, ...result } = await caller["verbrauchsausweis-gewerbe"]._uid.GET.fetch(null, {
|
||||
let { aufnahme_id, objekt_id, benutzer_id, ...result } = await caller["verbrauchsausweis-gewerbe"]._id.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid
|
||||
id
|
||||
}
|
||||
});
|
||||
|
||||
ausweis = result
|
||||
|
||||
aufnahme = await caller.aufnahme._uid.GET.fetch(null, {
|
||||
aufnahme = await caller.aufnahme._id.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid: uid_aufnahme
|
||||
id: aufnahme_id
|
||||
}
|
||||
})
|
||||
|
||||
objekt = await caller.objekt._uid.GET.fetch(null, {
|
||||
objekt = await caller.objekt._id.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid: uid_objekt
|
||||
id: objekt_id
|
||||
}
|
||||
})
|
||||
|
||||
bilder = await caller.aufnahme._uid.bilder.GET.fetch(null, {
|
||||
bilder = await caller.aufnahme._id.bilder.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid: uid_aufnahme
|
||||
id: aufnahme_id
|
||||
}
|
||||
})
|
||||
|
||||
@@ -78,30 +78,30 @@ if (uid) {
|
||||
"/energieausweis-erstellen/verbrauchsausweis-gewerbe"
|
||||
);
|
||||
}
|
||||
} else if (uid_aufnahme) {
|
||||
} else if (aufnahme_id) {
|
||||
if (!valid) {
|
||||
return Astro.redirect(
|
||||
`/auth/login?redirect=${Astro.url.toString()}`
|
||||
);
|
||||
}
|
||||
|
||||
let { uid_objekt, ...result} = await caller.aufnahme._uid.GET.fetch(null, {
|
||||
let { objekt_id, ...result} = await caller.aufnahme._id.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid: uid_aufnahme
|
||||
id: aufnahme_id
|
||||
}
|
||||
})
|
||||
|
||||
aufnahme = result;
|
||||
|
||||
objekt = await caller.objekt._uid.GET.fetch(null, {
|
||||
objekt = await caller.objekt._id.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid: uid_objekt
|
||||
id: objekt_id
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -1,112 +1,85 @@
|
||||
---
|
||||
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 "src/astro-typesafe-api-caller";
|
||||
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants";
|
||||
import { validateAccessTokenServer } from "#server/lib/validateAccessToken";
|
||||
import { Enums } from "#lib/server/prisma";
|
||||
import { AufnahmeClient, BildClient, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types";
|
||||
import { Aufnahme, Bild, Enums, Objekt, VerbrauchsausweisWohnen } from "#lib/server/prisma";
|
||||
import { getAufnahme, getBilder, getObjekt, getVerbrauchsausweisWohnen } from "#lib/server/db";
|
||||
import { getCurrentUser } from "#lib/server/user";
|
||||
|
||||
const id = Astro.url.searchParams.get("id");
|
||||
const aufnahme_id = Astro.url.searchParams.get("aufnahme")
|
||||
let ausweistyp = Astro.url.searchParams.get("ausweistyp") || Enums.AusweisTyp.Standard;
|
||||
let ausweistyp = Astro.url.searchParams.get("ausweistyp") as Enums.AusweisTyp || Enums.AusweisTyp.Standard;
|
||||
|
||||
let ausweis: VerbrauchsausweisWohnenClient = {} as VerbrauchsausweisWohnenClient;
|
||||
let aufnahme: AufnahmeClient = {} as AufnahmeClient;
|
||||
let objekt: ObjektClient = {} as ObjektClient;
|
||||
let bilder: UploadedGebaeudeBild[] = []
|
||||
let ausweis: VerbrauchsausweisWohnen = {} as VerbrauchsausweisWohnen;
|
||||
let aufnahme: Aufnahme = {} as Aufnahme;
|
||||
let objekt: Objekt = {} as Objekt;
|
||||
let bilder: Bild[] = []
|
||||
|
||||
const valid = validateAccessTokenServer(Astro);
|
||||
|
||||
const caller = createCaller(Astro);
|
||||
const user = await getCurrentUser(Astro)
|
||||
|
||||
if (id) {
|
||||
if (!valid) {
|
||||
if (!user) {
|
||||
return Astro.redirect(
|
||||
`/auth/login?redirect=${Astro.url.toString()}`
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
ausweis = await caller["verbrauchsausweis-wohnen"]._id.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
id
|
||||
}
|
||||
});
|
||||
ausweis = await getVerbrauchsausweisWohnen(id) as VerbrauchsausweisWohnen
|
||||
|
||||
ausweistyp = ausweis.ausweistyp
|
||||
|
||||
aufnahme = await caller.aufnahme._id.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
id: ausweis.aufnahme_id
|
||||
}
|
||||
})
|
||||
|
||||
objekt = await caller.objekt._id.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
id: ausweis.objekt_id
|
||||
}
|
||||
})
|
||||
|
||||
bilder = await caller.aufnahme._id.bilder.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
id: ausweis.aufnahme_id
|
||||
}
|
||||
})
|
||||
|
||||
if (!ausweis) {
|
||||
// Der Ausweis scheint nicht zu existieren.
|
||||
// Wir leiten auf die generische Ausweisseite ohne UID weiter.
|
||||
return Astro.redirect(
|
||||
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
|
||||
);
|
||||
}
|
||||
} catch(e) {
|
||||
if (!ausweis || ausweis.benutzer_id !== user.id) {
|
||||
// Der Ausweis scheint nicht zu existieren.
|
||||
// Wir leiten auf die generische Ausweisseite ohne ID weiter.
|
||||
return Astro.redirect(
|
||||
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
|
||||
);
|
||||
}
|
||||
|
||||
aufnahme = await getAufnahme(ausweis.aufnahme_id) as Aufnahme
|
||||
|
||||
if (!aufnahme) {
|
||||
// Die Aufnahme existiert nicht, das sollte eigentlich nicht passieren aber so können wir nicht fortfahren.
|
||||
return Astro.redirect(
|
||||
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
|
||||
);
|
||||
}
|
||||
|
||||
objekt = await getObjekt(aufnahme.objekt_id) as Objekt
|
||||
|
||||
if (!objekt) {
|
||||
// Das Objekt existiert nicht, das sollte eigentlich nicht passieren aber so können wir nicht fortfahren.
|
||||
return Astro.redirect(
|
||||
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
|
||||
);
|
||||
}
|
||||
|
||||
bilder = await getBilder(aufnahme.id);
|
||||
} else if (aufnahme_id) {
|
||||
if (!valid) {
|
||||
if (!user) {
|
||||
return Astro.redirect(
|
||||
`/auth/login?redirect=${Astro.url.toString()}`
|
||||
);
|
||||
}
|
||||
|
||||
let { objekt_id, ...result} = await caller.aufnahme._id.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
id: aufnahme_id
|
||||
}
|
||||
})
|
||||
aufnahme = await getAufnahme(ausweis.aufnahme_id) as Aufnahme
|
||||
|
||||
aufnahme = result;
|
||||
if (!aufnahme) {
|
||||
// Die Aufnahme existiert wohl nicht.
|
||||
return Astro.redirect(
|
||||
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
|
||||
);
|
||||
}
|
||||
|
||||
objekt = await caller.objekt._id.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
id: objekt_id
|
||||
}
|
||||
})
|
||||
objekt = await getObjekt(aufnahme.objekt_id) as Objekt
|
||||
|
||||
if (!objekt) {
|
||||
// Das Objekt existiert nicht.
|
||||
return Astro.redirect(
|
||||
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
|
||||
);
|
||||
}
|
||||
}
|
||||
---
|
||||
|
||||
<AusweisLayout title="Verbrauchsausweis erstellen">
|
||||
<VerbrauchsausweisWohnenModule client:only {ausweis} {objekt} {aufnahme} {bilder} {id} {ausweistyp} />
|
||||
<VerbrauchsausweisWohnenModule client:only {ausweis} {objekt} {aufnahme} {bilder} {id} {ausweistyp} {user} />
|
||||
</AusweisLayout>
|
||||
|
||||
@@ -8,13 +8,13 @@ import { createCaller } from "src/astro-typesafe-api-caller.js";
|
||||
import { getS3File } from "#lib/s3.js";
|
||||
|
||||
export const GET: APIRoute = async (Astro) => {
|
||||
const uidAusweis = Astro.url.searchParams.get("uid");
|
||||
const ausweis_id = Astro.url.searchParams.get("uid");
|
||||
|
||||
if (!uidAusweis) {
|
||||
if (!ausweis_id) {
|
||||
return new Response(null, { status: 404 });
|
||||
}
|
||||
|
||||
const ausweisart = getAusweisartFromUUID(uidAusweis)
|
||||
const ausweisart = getAusweisartFromUUID(ausweis_id)
|
||||
|
||||
const caller = createCaller(Astro);
|
||||
|
||||
@@ -25,18 +25,18 @@ export const GET: APIRoute = async (Astro) => {
|
||||
let bilder: UploadedGebaeudeBild[] = []
|
||||
|
||||
if (ausweisart === Enums.Ausweisart.VerbrauchsausweisWohnen) {
|
||||
ausweis = await caller["verbrauchsausweis-wohnen"]._uid.GET.fetch(undefined, {
|
||||
ausweis = await caller["verbrauchsausweis-wohnen"]._id.GET.fetch(undefined, {
|
||||
params: {
|
||||
uid: uidAusweis
|
||||
id: ausweis_id
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
}
|
||||
});
|
||||
} else if (ausweisart === Enums.Ausweisart.VerbrauchsausweisGewerbe) {
|
||||
ausweis = await caller["verbrauchsausweis-gewerbe"]._uid.GET.fetch(undefined, {
|
||||
ausweis = await caller["verbrauchsausweis-gewerbe"]._id.GET.fetch(undefined, {
|
||||
params: {
|
||||
uid: uidAusweis
|
||||
id: ausweis_id
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
@@ -49,18 +49,18 @@ export const GET: APIRoute = async (Astro) => {
|
||||
return new Response(null, { status: 404 });
|
||||
}
|
||||
|
||||
aufnahme = await caller.aufnahme._uid.GET.fetch(undefined, {
|
||||
aufnahme = await caller.aufnahme._id.GET.fetch(undefined, {
|
||||
params: {
|
||||
uid: ausweis.uid_aufnahme
|
||||
id: ausweis.aufnahme_id
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
}
|
||||
});
|
||||
|
||||
objekt = await caller.objekt._uid.GET.fetch(undefined, {
|
||||
objekt = await caller.objekt._id.GET.fetch(undefined, {
|
||||
params: {
|
||||
uid: ausweis.uid_objekt
|
||||
id: ausweis.objekt_id
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
|
||||
@@ -27,18 +27,18 @@ export const GET: APIRoute = async (Astro) => {
|
||||
let bilder: UploadedGebaeudeBild[] = []
|
||||
|
||||
if (ausweisart === Enums.Ausweisart.VerbrauchsausweisWohnen) {
|
||||
ausweis = await caller["verbrauchsausweis-wohnen"]._uid.GET.fetch(undefined, {
|
||||
ausweis = await caller["verbrauchsausweis-wohnen"]._id.GET.fetch(undefined, {
|
||||
params: {
|
||||
uid: uidAusweis
|
||||
id: uidAusweis
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
}
|
||||
});
|
||||
} else if (ausweisart === Enums.Ausweisart.VerbrauchsausweisGewerbe) {
|
||||
ausweis = await caller["verbrauchsausweis-gewerbe"]._uid.GET.fetch(undefined, {
|
||||
ausweis = await caller["verbrauchsausweis-gewerbe"]._id.GET.fetch(undefined, {
|
||||
params: {
|
||||
uid: uidAusweis
|
||||
id: uidAusweis
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
@@ -51,18 +51,18 @@ export const GET: APIRoute = async (Astro) => {
|
||||
return new Response(null, { status: 404 });
|
||||
}
|
||||
|
||||
aufnahme = await caller.aufnahme._uid.GET.fetch(undefined, {
|
||||
aufnahme = await caller.aufnahme._id.GET.fetch(undefined, {
|
||||
params: {
|
||||
uid: ausweis.uid_aufnahme
|
||||
id: ausweis.aufnahme_id
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
}
|
||||
});
|
||||
|
||||
objekt = await caller.objekt._uid.GET.fetch(undefined, {
|
||||
objekt = await caller.objekt._id.GET.fetch(undefined, {
|
||||
params: {
|
||||
uid: ausweis.uid_objekt
|
||||
id: ausweis.objekt_id
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
@@ -80,9 +80,9 @@ export const GET: APIRoute = async (Astro) => {
|
||||
// Dieser Ausweis wurde mit der alten Version erstellt, das PDF sollte bereits existieren.
|
||||
pdf = await getS3File("ibc-pdfs", `ID_${ausweis.alte_ausweis_id}_Datenblatt.pdf`)
|
||||
} else if (ausweisart === Enums.Ausweisart.VerbrauchsausweisWohnen) {
|
||||
pdf = await pdfVerbrauchsausweisWohnen(ausweis as VerbrauchsausweisWohnenClient, aufnahme, objekt, bilder, user);
|
||||
pdf = await pdfDatenblattVerbrauchsausweisWohnen(ausweis as VerbrauchsausweisWohnenClient, aufnahme, objekt, user, bilder);
|
||||
} else if (ausweisart === Enums.Ausweisart.VerbrauchsausweisGewerbe) {
|
||||
pdf = await pdfVerbrauchsausweisGewerbe(ausweis as VerbrauchsausweisGewerbeClient, aufnahme, objekt, bilder, user);
|
||||
pdf = await pdfDatenblattVerbrauchsausweisGewerbe(ausweis as VerbrauchsausweisGewerbeClient, aufnahme, objekt, user, bilder);
|
||||
}
|
||||
|
||||
return new Response(pdf, {
|
||||
|
||||
@@ -6,24 +6,19 @@ import { getPrismaAusweisAdapter } from "#lib/server/ausweis";
|
||||
import { getCurrentUser } from "#lib/server/user";
|
||||
|
||||
const user = await getCurrentUser(Astro)
|
||||
const uid = Astro.url.searchParams.get("uid");
|
||||
const adapter = getPrismaAusweisAdapter(uid || "")
|
||||
const id = Astro.url.searchParams.get("id");
|
||||
const adapter = getPrismaAusweisAdapter(id || "")
|
||||
|
||||
console.log(user, uid);
|
||||
|
||||
|
||||
if (!user || !uid || !adapter) {
|
||||
if (!user || !id || !adapter) {
|
||||
return Astro.redirect("/")
|
||||
}
|
||||
|
||||
const ausweis = await adapter.findUnique({
|
||||
where: {
|
||||
uid
|
||||
id
|
||||
}
|
||||
})
|
||||
|
||||
const id = ausweis.id;
|
||||
|
||||
if (!ausweis) {
|
||||
return Astro.redirect("/")
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user