Datenblatt und Verbrauchsausweis verbessert
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Aufnahme, BedarfsausweisGewerbe, Bild, Objekt, prisma, Unterlage, VerbrauchsausweisWohnen } from "./prisma.js";
|
||||
import { Aufnahme, BedarfsausweisGewerbe, BedarfsausweisWohnen, Bild, Objekt, prisma, Unterlage, VerbrauchsausweisGewerbe, VerbrauchsausweisWohnen } from "./prisma.js";
|
||||
|
||||
export async function getVerbrauchsausweisWohnen(id: string): Promise<VerbrauchsausweisWohnen | null> {
|
||||
return await prisma.verbrauchsausweisWohnen.findUnique({
|
||||
@@ -8,6 +8,22 @@ export async function getVerbrauchsausweisWohnen(id: string): Promise<Verbrauchs
|
||||
})
|
||||
}
|
||||
|
||||
export async function getVerbrauchsausweisGewerbe(id: string): Promise<VerbrauchsausweisGewerbe | null> {
|
||||
return await prisma.verbrauchsausweisGewerbe.findUnique({
|
||||
where: {
|
||||
id
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export async function getBedarfsausweisWohnen(id: string): Promise<BedarfsausweisWohnen | null> {
|
||||
return await prisma.bedarfsausweisWohnen.findUnique({
|
||||
where: {
|
||||
id
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export async function getBedarfsausweisGewerbe(id: string): Promise<BedarfsausweisGewerbe | null> {
|
||||
return await prisma.bedarfsausweisGewerbe.findUnique({
|
||||
where: {
|
||||
|
||||
@@ -6,9 +6,11 @@ import { Enums } from "#lib/client/prisma.js";
|
||||
import { APIRoute } from "astro";
|
||||
import { createCaller } from "src/astro-typesafe-api-caller.js";
|
||||
import { getS3File } from "#lib/s3.js";
|
||||
import { getVerbrauchsausweisWohnen, getVerbrauchsausweisGewerbe, getAufnahme, getObjekt, getBilder } from "#lib/server/db.js";
|
||||
import { getCurrentUser } from "#lib/server/user.js";
|
||||
|
||||
export const GET: APIRoute = async (Astro) => {
|
||||
const ausweis_id = Astro.url.searchParams.get("uid");
|
||||
const ausweis_id = Astro.url.searchParams.get("id");
|
||||
|
||||
if (!ausweis_id) {
|
||||
return new Response(null, { status: 404 });
|
||||
@@ -16,8 +18,6 @@ export const GET: APIRoute = async (Astro) => {
|
||||
|
||||
const ausweisart = getAusweisartFromId(ausweis_id)
|
||||
|
||||
const caller = createCaller(Astro);
|
||||
|
||||
let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | null = null;
|
||||
let aufnahme: AufnahmeClient = {} as AufnahmeClient;
|
||||
let objekt: ObjektClient = {} as ObjektClient;
|
||||
@@ -25,23 +25,9 @@ export const GET: APIRoute = async (Astro) => {
|
||||
let bilder: UploadedGebaeudeBild[] = []
|
||||
|
||||
if (ausweisart === Enums.Ausweisart.VerbrauchsausweisWohnen) {
|
||||
ausweis = await caller["verbrauchsausweis-wohnen"]._id.GET.fetch(undefined, {
|
||||
params: {
|
||||
id: ausweis_id
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
}
|
||||
});
|
||||
ausweis = await getVerbrauchsausweisWohnen(ausweis_id)
|
||||
} else if (ausweisart === Enums.Ausweisart.VerbrauchsausweisGewerbe) {
|
||||
ausweis = await caller["verbrauchsausweis-gewerbe"]._id.GET.fetch(undefined, {
|
||||
params: {
|
||||
id: ausweis_id
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
}
|
||||
});
|
||||
ausweis = await getVerbrauchsausweisGewerbe(ausweis_id)
|
||||
}
|
||||
|
||||
|
||||
@@ -49,29 +35,13 @@ export const GET: APIRoute = async (Astro) => {
|
||||
return new Response(null, { status: 404 });
|
||||
}
|
||||
|
||||
aufnahme = await caller.aufnahme._id.GET.fetch(undefined, {
|
||||
params: {
|
||||
id: ausweis.aufnahme_id
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
}
|
||||
});
|
||||
aufnahme = await getAufnahme(ausweis.aufnahme_id)
|
||||
|
||||
objekt = await caller.objekt._id.GET.fetch(undefined, {
|
||||
params: {
|
||||
id: ausweis.objekt_id
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
}
|
||||
});
|
||||
objekt = await getObjekt(aufnahme.objekt_id)
|
||||
|
||||
user = await caller.user.self.GET.fetch(undefined, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
}
|
||||
});
|
||||
bilder = await getBilder(ausweis.aufnahme_id)
|
||||
|
||||
user = await getCurrentUser(Astro)
|
||||
|
||||
let pdf: Uint8Array<ArrayBufferLike> | null = null;
|
||||
if (ausweis.alte_ausweis_id) {
|
||||
|
||||
@@ -8,17 +8,17 @@ import { Enums } from "#lib/client/prisma.js";
|
||||
import { APIRoute } from "astro";
|
||||
import { createCaller } from "src/astro-typesafe-api-caller.js";
|
||||
import { getS3File } from "#lib/s3.js";
|
||||
import { getAufnahme, getBilder, getObjekt, getVerbrauchsausweisGewerbe, getVerbrauchsausweisWohnen } from "#lib/server/db.js";
|
||||
import { getCurrentUser } from "#lib/server/user.js";
|
||||
|
||||
export const GET: APIRoute = async (Astro) => {
|
||||
const uidAusweis = Astro.url.searchParams.get("uid");
|
||||
const ausweis_id = Astro.url.searchParams.get("id");
|
||||
|
||||
if (!uidAusweis) {
|
||||
if (!ausweis_id) {
|
||||
return new Response(null, { status: 404 });
|
||||
}
|
||||
|
||||
const ausweisart = getAusweisartFromId(uidAusweis)
|
||||
|
||||
const caller = createCaller(Astro);
|
||||
const ausweisart = getAusweisartFromId(ausweis_id)
|
||||
|
||||
let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | null = null;
|
||||
let aufnahme: AufnahmeClient = {} as AufnahmeClient;
|
||||
@@ -27,23 +27,9 @@ export const GET: APIRoute = async (Astro) => {
|
||||
let bilder: UploadedGebaeudeBild[] = []
|
||||
|
||||
if (ausweisart === Enums.Ausweisart.VerbrauchsausweisWohnen) {
|
||||
ausweis = await caller["verbrauchsausweis-wohnen"]._id.GET.fetch(undefined, {
|
||||
params: {
|
||||
id: uidAusweis
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
}
|
||||
});
|
||||
ausweis = await getVerbrauchsausweisWohnen(ausweis_id)
|
||||
} else if (ausweisart === Enums.Ausweisart.VerbrauchsausweisGewerbe) {
|
||||
ausweis = await caller["verbrauchsausweis-gewerbe"]._id.GET.fetch(undefined, {
|
||||
params: {
|
||||
id: uidAusweis
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
}
|
||||
});
|
||||
ausweis = await getVerbrauchsausweisGewerbe(ausweis_id)
|
||||
}
|
||||
|
||||
|
||||
@@ -51,29 +37,13 @@ export const GET: APIRoute = async (Astro) => {
|
||||
return new Response(null, { status: 404 });
|
||||
}
|
||||
|
||||
aufnahme = await caller.aufnahme._id.GET.fetch(undefined, {
|
||||
params: {
|
||||
id: ausweis.aufnahme_id
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
}
|
||||
});
|
||||
aufnahme = await getAufnahme(ausweis.aufnahme_id)
|
||||
|
||||
objekt = await caller.objekt._id.GET.fetch(undefined, {
|
||||
params: {
|
||||
id: ausweis.objekt_id
|
||||
},
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
}
|
||||
});
|
||||
objekt = await getObjekt(aufnahme.objekt_id)
|
||||
|
||||
user = await caller.user.self.GET.fetch(undefined, {
|
||||
headers: {
|
||||
Authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
}
|
||||
});
|
||||
bilder = await getBilder(ausweis.aufnahme_id)
|
||||
|
||||
user = await getCurrentUser(Astro)
|
||||
|
||||
let pdf: Uint8Array<ArrayBufferLike> | null = null;
|
||||
if (ausweis.alte_ausweis_id) {
|
||||
|
||||
Reference in New Issue
Block a user