Tests
This commit is contained in:
@@ -1,90 +1,87 @@
|
||||
---
|
||||
import AusweisLayout from "#layouts/AusweisLayoutDaten.astro";
|
||||
import { AufnahmeClient, BildClient, GEGNachweisWohnenClient, ObjektClient, UnterlageClient } 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";
|
||||
import GEGNachweisWohnenModule from "#modules/angebot-anfragen/GEGNachweisWohnenModule.svelte";
|
||||
import { getGEGNachweisWohnen, getAufnahme, getObjekt, getBilder } from "#lib/server/db";
|
||||
import { Enums, Aufnahme, Objekt, Bild, GEGNachweisWohnen, Unterlage } from "#lib/server/prisma";
|
||||
import { getCurrentUser } from "#lib/server/user";
|
||||
import { getUnterlagen } from "#lib/server/db";
|
||||
|
||||
const uid = Astro.url.searchParams.get("uid");
|
||||
let nachweis: GEGNachweisWohnenClient = {} as GEGNachweisWohnenClient;
|
||||
let aufnahme: AufnahmeClient = {} as AufnahmeClient;
|
||||
let objekt: ObjektClient = {} as ObjektClient;
|
||||
let bilder: BildClient[] = []
|
||||
let unterlagen: UnterlageClient[] = []
|
||||
const id = Astro.url.searchParams.get("id");
|
||||
const aufnahme_id = Astro.url.searchParams.get("aufnahme")
|
||||
let ausweistyp = Astro.url.searchParams.get("ausweistyp") as Enums.AusweisTyp || Enums.AusweisTyp.Standard;
|
||||
|
||||
const valid = validateAccessTokenServer(Astro);
|
||||
let nachweis: GEGNachweisWohnen = {} as GEGNachweisWohnen;
|
||||
let aufnahme: Aufnahme = {} as Aufnahme;
|
||||
let objekt: Objekt = {} as Objekt;
|
||||
let bilder: Bild[] = []
|
||||
let unterlagen: Unterlage[] = []
|
||||
|
||||
const caller = createCaller(Astro);
|
||||
const user = await getCurrentUser(Astro)
|
||||
|
||||
if (uid) {
|
||||
if (!valid) {
|
||||
if (id) {
|
||||
if (!user) {
|
||||
return Astro.redirect(
|
||||
`/auth/login?redirect=${Astro.url.toString()}`
|
||||
);
|
||||
}
|
||||
|
||||
try {
|
||||
nachweis = await caller["geg-nachweis-wohnen"]._uid.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid
|
||||
}
|
||||
});
|
||||
nachweis = await getGEGNachweisWohnen(id) as GEGNachweisWohnen
|
||||
|
||||
aufnahme = await caller.aufnahme._uid.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid: nachweis.uid_aufnahme
|
||||
}
|
||||
})
|
||||
|
||||
objekt = await caller.objekt._uid.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid: nachweis.uid_objekt
|
||||
}
|
||||
})
|
||||
|
||||
bilder = await caller.aufnahme._uid.bilder.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid: nachweis.uid_aufnahme
|
||||
}
|
||||
})
|
||||
|
||||
unterlagen = await caller.aufnahme._uid.unterlagen.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid: nachweis.uid_aufnahme
|
||||
}
|
||||
})
|
||||
|
||||
if (!nachweis) {
|
||||
// Der Ausweis scheint nicht zu existieren.
|
||||
// Wir leiten auf die generische Ausweisseite ohne UID weiter.
|
||||
return Astro.redirect(
|
||||
"/angebot-anfragen/geg-nachweis-wohnen-anfragen"
|
||||
);
|
||||
}
|
||||
} catch(e) {
|
||||
if (!nachweis || nachweis.benutzer_id !== user.id) {
|
||||
// Der Ausweis scheint nicht zu existieren.
|
||||
// Wir leiten auf die generische Ausweisseite ohne ID weiter.
|
||||
return Astro.redirect(
|
||||
"/angebot-anfragen/geg-nachweis-wohnen-anfragen"
|
||||
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
|
||||
);
|
||||
}
|
||||
|
||||
aufnahme = await getAufnahme(nachweis.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);
|
||||
unterlagen = await getUnterlagen(aufnahme.id);
|
||||
} else if (aufnahme_id) {
|
||||
if (!user) {
|
||||
return Astro.redirect(
|
||||
`/auth/login?redirect=${Astro.url.toString()}`
|
||||
);
|
||||
}
|
||||
|
||||
aufnahme = await getAufnahme(nachweis.aufnahme_id) as Aufnahme
|
||||
|
||||
if (!aufnahme) {
|
||||
// Die Aufnahme existiert wohl nicht.
|
||||
return Astro.redirect(
|
||||
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
|
||||
);
|
||||
}
|
||||
|
||||
objekt = await getObjekt(aufnahme.objekt_id) as Objekt
|
||||
|
||||
if (!objekt) {
|
||||
// Das Objekt existiert nicht.
|
||||
return Astro.redirect(
|
||||
"/energieausweis-erstellen/verbrauchsausweis-wohngebaeude"
|
||||
);
|
||||
}
|
||||
}
|
||||
---
|
||||
|
||||
<AusweisLayout title="GEG Nachweis Wohnen anfragen">
|
||||
<GEGNachweisWohnenModule client:only {nachweis} {objekt} {aufnahme} {bilder} {unterlagen} />
|
||||
<GEGNachweisWohnenModule client:only {nachweis} {objekt} {aufnahme} {bilder} {unterlagen} {id} />
|
||||
</AusweisLayout>
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
import { UUidWithPrefix } from "#components/Ausweis/types.js";
|
||||
import { VALID_UUID_PREFIXES } from "#lib/constants.js";
|
||||
import { generatePrefixedId } from "#lib/db.js";
|
||||
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
|
||||
import { prisma } from "#lib/server/prisma.js";
|
||||
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
||||
@@ -16,24 +18,25 @@ export const PUT = defineApiRoute({
|
||||
nachweis: GEGNachweisGewerbeSchema.omit({
|
||||
id: true,
|
||||
benutzer_id: true,
|
||||
uid: true,
|
||||
aufnahme_id: true,
|
||||
created_at: true,
|
||||
updated_at: true,
|
||||
geg_einpreisung_id: true,
|
||||
rechnung_id: true
|
||||
}),
|
||||
uid_aufnahme: UUidWithPrefix
|
||||
aufnahme_id: UUidWithPrefix
|
||||
}),
|
||||
output: z.object({
|
||||
uid: UUidWithPrefix,
|
||||
objekt_uid: UUidWithPrefix,
|
||||
aufnahme_uid: UUidWithPrefix,
|
||||
id: UUidWithPrefix,
|
||||
objekt_id: UUidWithPrefix,
|
||||
aufnahme_id: UUidWithPrefix,
|
||||
}),
|
||||
headers: authorizationHeaders,
|
||||
middleware: authorizationMiddleware,
|
||||
async fetch(input, ctx, user) {
|
||||
const aufnahme = await prisma.aufnahme.findUnique({
|
||||
where: {
|
||||
uid: input.uid_aufnahme
|
||||
id: input.aufnahme_id
|
||||
}
|
||||
})
|
||||
|
||||
@@ -44,8 +47,11 @@ export const PUT = defineApiRoute({
|
||||
})
|
||||
}
|
||||
|
||||
const id = generatePrefixedId(6, VALID_UUID_PREFIXES.GEGNachweisGewerbe)
|
||||
|
||||
const nachweis = await prisma.gEGNachweisGewerbe.create({
|
||||
data: {
|
||||
id,
|
||||
...input.nachweis,
|
||||
benutzer: {
|
||||
connect: {
|
||||
@@ -59,13 +65,13 @@ export const PUT = defineApiRoute({
|
||||
}
|
||||
},
|
||||
select: {
|
||||
uid: true,
|
||||
id: true,
|
||||
aufnahme: {
|
||||
select: {
|
||||
uid: true,
|
||||
id: true,
|
||||
objekt: {
|
||||
select: {
|
||||
uid: true,
|
||||
id: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -74,9 +80,9 @@ export const PUT = defineApiRoute({
|
||||
});
|
||||
|
||||
return {
|
||||
uid: nachweis.uid,
|
||||
objekt_uid: nachweis.aufnahme.objekt.uid,
|
||||
aufnahme_uid: nachweis.aufnahme.uid,
|
||||
id: nachweis.id,
|
||||
objekt_id: nachweis.aufnahme.objekt.id,
|
||||
aufnahme_id: nachweis.aufnahme.id,
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -101,11 +107,11 @@ export const GET = defineApiRoute({
|
||||
headers: authorizationHeaders,
|
||||
middleware: authorizationMiddleware,
|
||||
async fetch(input, context, user) {
|
||||
const { uid } = context.params;
|
||||
const { id } = context.params;
|
||||
|
||||
const nachweis = await prisma.gEGNachweisGewerbe.findUnique({
|
||||
where: {
|
||||
uid,
|
||||
id,
|
||||
},
|
||||
include: {
|
||||
benutzer: true,
|
||||
@@ -115,7 +121,7 @@ export const GET = defineApiRoute({
|
||||
include: {
|
||||
benutzer: {
|
||||
select: {
|
||||
uid: true,
|
||||
id: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
import { GEGNachweisWohnenClient, OptionalNullable, UUidWithPrefix, ZodOverlap } from "#components/Ausweis/types.js";
|
||||
import { UUidWithPrefix } from "#components/Ausweis/types.js";
|
||||
import { VALID_UUID_PREFIXES } from "#lib/constants.js";
|
||||
import { generatePrefixedId } from "#lib/db.js";
|
||||
import { exclude } from "#lib/exclude.js";
|
||||
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
|
||||
import { GEGNachweisWohnenSchema, prisma } from "#lib/server/prisma";
|
||||
import { prisma } from "#lib/server/prisma.js";
|
||||
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
||||
import { GEGNachweisWohnenSchema } from "src/generated/zod/gegnachweiswohnen.js";
|
||||
import { z } from "zod";
|
||||
|
||||
export const PATCH = defineApiRoute({
|
||||
input: GEGNachweisWohnenSchema.omit({
|
||||
uid: true,
|
||||
id: true,
|
||||
benutzer_id: true,
|
||||
geg_einpreisung_id: true,
|
||||
@@ -21,7 +23,7 @@ export const PATCH = defineApiRoute({
|
||||
async fetch(input, ctx, user) {
|
||||
const objekt = await prisma.gEGNachweisWohnen.findUnique({
|
||||
where: {
|
||||
uid: ctx.params.uid,
|
||||
id: ctx.params.id,
|
||||
benutzer: {
|
||||
id: user.id
|
||||
}
|
||||
@@ -37,7 +39,7 @@ export const PATCH = defineApiRoute({
|
||||
|
||||
await prisma.gEGNachweisWohnen.update({
|
||||
where: {
|
||||
uid: ctx.params.uid
|
||||
id: ctx.params.id
|
||||
},
|
||||
data: input
|
||||
})
|
||||
@@ -51,9 +53,9 @@ export const DELETE = defineApiRoute({
|
||||
headers: authorizationHeaders,
|
||||
middleware: authorizationMiddleware,
|
||||
async fetch(input, ctx, user) {
|
||||
const { uid } = ctx.params;
|
||||
const { id } = ctx.params;
|
||||
|
||||
if (!UUidWithPrefix.safeParse(uid).success) {
|
||||
if (!UUidWithPrefix.safeParse(id).success) {
|
||||
throw new APIError({
|
||||
code: "BAD_REQUEST",
|
||||
message: "UID konnte nicht verifiziert werden."
|
||||
@@ -64,7 +66,7 @@ export const DELETE = defineApiRoute({
|
||||
// Dieser MUSS mit dem Nutzer verknüpft sein.
|
||||
const nachweis = await prisma.gEGNachweisWohnen.findUnique({
|
||||
where: {
|
||||
uid,
|
||||
id,
|
||||
}
|
||||
});
|
||||
|
||||
@@ -111,10 +113,13 @@ export const DELETE = defineApiRoute({
|
||||
}
|
||||
})
|
||||
|
||||
const event_id =
|
||||
|
||||
// Wir erstellen ein Event, dass der Nachweis storniert wurde
|
||||
// Dann können wir das in der Historie anzeigen
|
||||
await prisma.event.create({
|
||||
data: {
|
||||
id: generatePrefixedId(6, VALID_UUID_PREFIXES.Event),
|
||||
title: "Nachweis storniert",
|
||||
description: ((user.rolle === "ADMIN") && (nachweis.benutzer_id !== user.id)) ? "Nachweis wurde von einem Administrator storniert." : "Nachweis wurde vom Besitzer storniert.",
|
||||
benutzer: {
|
||||
@@ -150,9 +155,9 @@ export const GET = defineApiRoute({
|
||||
}
|
||||
},
|
||||
output: GEGNachweisWohnenSchema.merge(z.object({
|
||||
uid_aufnahme: UUidWithPrefix,
|
||||
uid_objekt: UUidWithPrefix,
|
||||
uid_benutzer: UUidWithPrefix.optional()
|
||||
aufnahme_id: UUidWithPrefix,
|
||||
objekt_id: UUidWithPrefix,
|
||||
benutzer_id: UUidWithPrefix.optional()
|
||||
})).omit({
|
||||
id: true,
|
||||
aufnahme_id: true,
|
||||
@@ -160,32 +165,32 @@ export const GET = defineApiRoute({
|
||||
}),
|
||||
middleware: authorizationMiddleware,
|
||||
async fetch(input, context, user) {
|
||||
const { uid } = context.params;
|
||||
const { id } = context.params;
|
||||
|
||||
if (!uid) {
|
||||
if (!id) {
|
||||
throw new APIError({
|
||||
code: "BAD_REQUEST",
|
||||
message: "Missing uid in request params"
|
||||
})
|
||||
}
|
||||
|
||||
const Nachweis = await prisma.gEGNachweisWohnen.findUnique({
|
||||
const nachweis = await prisma.gEGNachweisWohnen.findUnique({
|
||||
where: {
|
||||
uid,
|
||||
id,
|
||||
benutzer_id: user.id
|
||||
},
|
||||
include: {
|
||||
benutzer: {
|
||||
select: {
|
||||
uid: true
|
||||
id: true
|
||||
}
|
||||
},
|
||||
aufnahme: {
|
||||
select: {
|
||||
uid: true,
|
||||
id: true,
|
||||
objekt: {
|
||||
select: {
|
||||
uid: true
|
||||
id: true
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -193,7 +198,7 @@ export const GET = defineApiRoute({
|
||||
}
|
||||
});
|
||||
|
||||
if (!Nachweis) {
|
||||
if (!nachweis) {
|
||||
// Falls wir den Nachweis nicht finden können, werfen wir einen Fehler
|
||||
throw new APIError({
|
||||
code: "NOT_FOUND",
|
||||
@@ -202,10 +207,10 @@ export const GET = defineApiRoute({
|
||||
}
|
||||
|
||||
return {
|
||||
uid_aufnahme: Nachweis.aufnahme.uid,
|
||||
uid_objekt: Nachweis.aufnahme.objekt.uid,
|
||||
uid_benutzer: Nachweis.benutzer?.uid,
|
||||
...exclude(Nachweis, ["id", "aufnahme_id", "benutzer_id", "aufnahme"])
|
||||
aufnahme_id: nachweis.aufnahme.id,
|
||||
objekt_id: nachweis.aufnahme.objekt.id,
|
||||
benutzer_id: nachweis.benutzer?.id,
|
||||
...exclude(nachweis, ["id", "aufnahme_id", "benutzer_id", "aufnahme"])
|
||||
}
|
||||
},
|
||||
});
|
||||
@@ -1,4 +1,6 @@
|
||||
import { UUidWithPrefix } from "#components/Ausweis/types.js";
|
||||
import { VALID_UUID_PREFIXES } from "#lib/constants.js";
|
||||
import { generatePrefixedId } from "#lib/db.js";
|
||||
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
|
||||
import { prisma } from "#lib/server/prisma.js";
|
||||
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
||||
@@ -16,24 +18,25 @@ export const PUT = defineApiRoute({
|
||||
nachweis: GEGNachweisWohnenSchema.omit({
|
||||
id: true,
|
||||
benutzer_id: true,
|
||||
uid: true,
|
||||
aufnahme_id: true,
|
||||
updated_at: true,
|
||||
created_at: true,
|
||||
geg_einpreisung_id: true,
|
||||
rechnung_id: true
|
||||
}),
|
||||
uid_aufnahme: UUidWithPrefix
|
||||
aufnahme_id: UUidWithPrefix
|
||||
}),
|
||||
output: z.object({
|
||||
uid: UUidWithPrefix,
|
||||
objekt_uid: UUidWithPrefix,
|
||||
aufnahme_uid: UUidWithPrefix,
|
||||
id: UUidWithPrefix,
|
||||
objekt_id: UUidWithPrefix,
|
||||
aufnahme_id: UUidWithPrefix,
|
||||
}),
|
||||
headers: authorizationHeaders,
|
||||
middleware: authorizationMiddleware,
|
||||
async fetch(input, ctx, user) {
|
||||
const aufnahme = await prisma.aufnahme.findUnique({
|
||||
where: {
|
||||
uid: input.uid_aufnahme
|
||||
id: input.aufnahme_id
|
||||
}
|
||||
})
|
||||
|
||||
@@ -44,8 +47,11 @@ export const PUT = defineApiRoute({
|
||||
})
|
||||
}
|
||||
|
||||
const id = generatePrefixedId(6, VALID_UUID_PREFIXES.GEGNachweisWohnen)
|
||||
|
||||
const nachweis = await prisma.gEGNachweisWohnen.create({
|
||||
data: {
|
||||
id,
|
||||
...input.nachweis,
|
||||
benutzer: {
|
||||
connect: {
|
||||
@@ -59,13 +65,13 @@ export const PUT = defineApiRoute({
|
||||
}
|
||||
},
|
||||
select: {
|
||||
uid: true,
|
||||
id: true,
|
||||
aufnahme: {
|
||||
select: {
|
||||
uid: true,
|
||||
id: true,
|
||||
objekt: {
|
||||
select: {
|
||||
uid: true,
|
||||
id: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -74,9 +80,9 @@ export const PUT = defineApiRoute({
|
||||
});
|
||||
|
||||
return {
|
||||
uid: nachweis.uid,
|
||||
objekt_uid: nachweis.aufnahme.objekt.uid,
|
||||
aufnahme_uid: nachweis.aufnahme.uid,
|
||||
id: nachweis.id,
|
||||
objekt_id: nachweis.aufnahme.objekt.id,
|
||||
aufnahme_id: nachweis.aufnahme.id,
|
||||
};
|
||||
},
|
||||
});
|
||||
@@ -101,11 +107,11 @@ export const GET = defineApiRoute({
|
||||
headers: authorizationHeaders,
|
||||
middleware: authorizationMiddleware,
|
||||
async fetch(input, context, user) {
|
||||
const { uid } = context.params;
|
||||
const { id } = context.params;
|
||||
|
||||
const nachweis = await prisma.gEGNachweisGewerbe.findUnique({
|
||||
where: {
|
||||
uid,
|
||||
id,
|
||||
},
|
||||
include: {
|
||||
benutzer: true,
|
||||
@@ -115,7 +121,7 @@ export const GET = defineApiRoute({
|
||||
include: {
|
||||
benutzer: {
|
||||
select: {
|
||||
uid: true,
|
||||
id: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
import { getAusweisartFromId, UUidWithPrefix } from "#components/Ausweis/types.js";
|
||||
import { VALID_UUID_PREFIXES } from "#lib/constants.js";
|
||||
import { generatePrefixedId } from "#lib/db.js";
|
||||
import { omit } from "#lib/helpers.js";
|
||||
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
|
||||
import { sendGEGAnforderungsMail } from "#lib/server/mail/geg-anfordern.js";
|
||||
import { Enums, GEGNachweisGewerbe, GEGNachweisWohnen, prisma } from "#lib/server/prisma.js";
|
||||
import { BedarfsausweisGewerbe, Enums, GEGNachweisGewerbe, GEGNachweisWohnen, prisma } from "#lib/server/prisma.js";
|
||||
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
||||
import { GEGEinpreisungSchema } from "src/generated/zod/gegeinpreisung.js";
|
||||
import { z } from "zod";
|
||||
@@ -21,7 +23,7 @@ export const PUT = defineApiRoute({
|
||||
const ausweisart = getAusweisartFromId(input.nachweis_id);
|
||||
|
||||
let einpreisung;
|
||||
let nachweis: GEGNachweisWohnen | GEGNachweisGewerbe;
|
||||
let nachweis: GEGNachweisWohnen | GEGNachweisGewerbe | BedarfsausweisGewerbe;
|
||||
if (ausweisart === Enums.Ausweisart.GEGNachweisWohnen) {
|
||||
nachweis = await prisma.gEGNachweisWohnen.findUnique({
|
||||
where: {
|
||||
@@ -55,9 +57,12 @@ export const PUT = defineApiRoute({
|
||||
})
|
||||
}
|
||||
|
||||
const id = generatePrefixedId(6, VALID_UUID_PREFIXES.GEGEinpreisung)
|
||||
|
||||
if (ausweisart === Enums.Ausweisart.GEGNachweisWohnen) {
|
||||
einpreisung = await prisma.gEGEinpreisung.create({
|
||||
data: {
|
||||
id,
|
||||
...omit(input, ["nachweis_id"]),
|
||||
status: Enums.Einpreisungsstatus.open,
|
||||
benutzer: {
|
||||
@@ -75,6 +80,7 @@ export const PUT = defineApiRoute({
|
||||
} else if (ausweisart === Enums.Ausweisart.GEGNachweisGewerbe) {
|
||||
einpreisung = await prisma.gEGEinpreisung.create({
|
||||
data: {
|
||||
id,
|
||||
...omit(input, ["nachweis_id"]),
|
||||
status: Enums.Einpreisungsstatus.open,
|
||||
benutzer: {
|
||||
@@ -92,6 +98,7 @@ export const PUT = defineApiRoute({
|
||||
} else if (ausweisart === Enums.Ausweisart.BedarfsausweisGewerbe) {
|
||||
einpreisung = await prisma.gEGEinpreisung.create({
|
||||
data: {
|
||||
id,
|
||||
...omit(input, ["nachweis_id"]),
|
||||
status: Enums.Einpreisungsstatus.open,
|
||||
benutzer: {
|
||||
@@ -111,7 +118,7 @@ export const PUT = defineApiRoute({
|
||||
await sendGEGAnforderungsMail(nachweis, user)
|
||||
|
||||
return {
|
||||
id: einpreisung.id
|
||||
id
|
||||
}
|
||||
},
|
||||
})
|
||||
@@ -1,10 +1,8 @@
|
||||
import { AufnahmeClient, BenutzerClient, getAusweisartFromId, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
|
||||
import { BenutzerClient, getAusweisartFromId, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
|
||||
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants.js";
|
||||
import { pdfDatenblattVerbrauchsausweisGewerbe } from "#lib/pdf/pdfDatenblattVerbrauchsausweisGewerbe.js";
|
||||
import { pdfDatenblattVerbrauchsausweisWohnen } from "#lib/pdf/pdfDatenblattVerbrauchsausweisWohnen.js";
|
||||
import { pdfVerbrauchsausweisGewerbe } from "#lib/pdf/pdfVerbrauchsausweisGewerbe.js";
|
||||
import { pdfVerbrauchsausweisWohnen } from "#lib/pdf/pdfVerbrauchsausweisWohnen.js";
|
||||
import { Enums } from "#lib/client/prisma.js";
|
||||
import { Aufnahme, Benutzer, Bild, Enums, Objekt, VerbrauchsausweisGewerbe, VerbrauchsausweisWohnen } from "#lib/client/prisma.js";
|
||||
import { APIRoute } from "astro";
|
||||
import { createCaller } from "src/astro-typesafe-api-caller.js";
|
||||
import { getS3File } from "#lib/s3.js";
|
||||
@@ -20,11 +18,11 @@ export const GET: APIRoute = async (Astro) => {
|
||||
|
||||
const ausweisart = getAusweisartFromId(ausweis_id)
|
||||
|
||||
let ausweis: VerbrauchsausweisWohnenClient | VerbrauchsausweisGewerbeClient | null = null;
|
||||
let aufnahme: AufnahmeClient = {} as AufnahmeClient;
|
||||
let objekt: ObjektClient = {} as ObjektClient;
|
||||
let user: BenutzerClient = {} as BenutzerClient;
|
||||
let bilder: UploadedGebaeudeBild[] = []
|
||||
let ausweis: VerbrauchsausweisWohnen | VerbrauchsausweisGewerbe | null = null;
|
||||
let aufnahme: Aufnahme = {} as Aufnahme;
|
||||
let objekt: Objekt = {} as Objekt;
|
||||
let user: Benutzer = {} as Benutzer;
|
||||
let bilder: Bild[] = []
|
||||
|
||||
if (ausweisart === Enums.Ausweisart.VerbrauchsausweisWohnen) {
|
||||
ausweis = await getVerbrauchsausweisWohnen(ausweis_id)
|
||||
|
||||
Reference in New Issue
Block a user