Bilder fix Datenblatt
This commit is contained in:
@@ -1,90 +1,88 @@
|
||||
---
|
||||
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 VerbrauchsausweisWohnenModule from "#modules/VerbrauchsausweisWohnen/VerbrauchsausweisWohnenModule.svelte";
|
||||
import { AufnahmeClient, BildClient, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types";
|
||||
import { Aufnahme, BedarfsausweisGewerbe, Bild, Enums, Objekt, Unterlage, VerbrauchsausweisWohnen } from "#lib/server/prisma";
|
||||
import { getAufnahme, getBedarfsausweisGewerbe, getBilder, getObjekt, getUnterlagen, getVerbrauchsausweisWohnen } from "#lib/server/db";
|
||||
import { getCurrentUser } from "#lib/server/user";
|
||||
import BedarfsausweisGewerbeModule from "#modules/angebot-anfragen/BedarfsausweisGewerbeModule.svelte";
|
||||
|
||||
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: BedarfsausweisGewerbe = {} as BedarfsausweisGewerbe;
|
||||
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["bedarfsausweis-gewerbe"]._uid.GET.fetch(null, {
|
||||
headers: {
|
||||
authorization: `Bearer ${Astro.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)?.value}`
|
||||
},
|
||||
params: {
|
||||
uid
|
||||
}
|
||||
});
|
||||
nachweis = await getBedarfsausweisGewerbe(id) as BedarfsausweisGewerbe
|
||||
|
||||
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/bedarfsausweis-gewerbe-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/bedarfsausweis-gewerbe-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="Bedarfsausweis Gewerbe anfragen">
|
||||
<BedarfsausweisGewerbeModule client:only {nachweis} {objekt} {aufnahme} {bilder} {unterlagen} />
|
||||
<BedarfsausweisGewerbeModule client:only {nachweis} {objekt} {aufnahme} {bilder} {unterlagen} {id} {ausweistyp} />
|
||||
</AusweisLayout>
|
||||
|
||||
@@ -1,8 +1,6 @@
|
||||
import { getAusweisartFromUUID } from "#components/Ausweis/types.js";
|
||||
import { getAusweisartFromId } from "#components/Ausweis/types.js";
|
||||
import { adminMiddleware } from "#lib/middleware/authorization.js";
|
||||
import { pdfDatenblattVerbrauchsausweisWohnen } from "#lib/pdf/pdfDatenblattVerbrauchsausweisWohnen.js";
|
||||
import { pdfVerbrauchsausweisWohnen } from "#lib/pdf/pdfVerbrauchsausweisWohnen.js";
|
||||
import { Enums, prisma } from "#lib/server/prisma";
|
||||
import { Enums, prisma } from "#lib/server/prisma.js";
|
||||
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
|
||||
import { z } from "astro:content";
|
||||
import { fileURLToPath } from "url";
|
||||
@@ -14,17 +12,17 @@ import { PERSISTENT_DIR } from "#lib/server/constants.js";
|
||||
|
||||
export const GET = defineApiRoute({
|
||||
input: z.object({
|
||||
uid_ausweis: z.string(),
|
||||
id_ausweis: z.string(),
|
||||
}),
|
||||
output: z.void(),
|
||||
middleware: adminMiddleware,
|
||||
async fetch({ uid_ausweis }, context, user) {
|
||||
const ausweisart = getAusweisartFromUUID(uid);
|
||||
async fetch({ id_ausweis }, context, user) {
|
||||
const ausweisart = getAusweisartFromId(id_ausweis);
|
||||
|
||||
if (ausweisart === "VerbrauchsausweisWohnen") {
|
||||
const ausweis = await prisma.verbrauchsausweisWohnen.findUnique({
|
||||
where: {
|
||||
uid: uid_ausweis,
|
||||
id: id_ausweis
|
||||
},
|
||||
include: {
|
||||
aufnahme: {
|
||||
@@ -50,7 +48,7 @@ export const GET = defineApiRoute({
|
||||
const rechnung = await prisma.rechnung.findFirst({
|
||||
where: {
|
||||
verbrauchsausweis_wohnen: {
|
||||
uid: uid_ausweis
|
||||
id: id_ausweis
|
||||
},
|
||||
},
|
||||
orderBy: {
|
||||
@@ -100,7 +98,7 @@ export const GET = defineApiRoute({
|
||||
if (pdfAusweis) {
|
||||
const pdfAusweisPath = fileURLToPath(
|
||||
new URL(
|
||||
`${PERSISTENT_DIR}/generated/Ausweis-${ausweis.uid}.pdf`,
|
||||
`${PERSISTENT_DIR}/generated/Ausweis-${ausweis.id}.pdf`,
|
||||
import.meta.url
|
||||
)
|
||||
);
|
||||
@@ -110,7 +108,7 @@ export const GET = defineApiRoute({
|
||||
if (pdfDatenblatt) {
|
||||
const pdfDatenblattPath = fileURLToPath(
|
||||
new URL(
|
||||
`${PERSISTENT_DIR}/generated/Datenblatt-${ausweis.uid}.pdf`,
|
||||
`${PERSISTENT_DIR}/generated/Datenblatt-${ausweis.id}.pdf`,
|
||||
import.meta.url
|
||||
)
|
||||
);
|
||||
@@ -160,7 +158,7 @@ fax 040 · 209339859
|
||||
<tr><td>IBAN</td><td>:<td>\t DE81 2004 0000 0348 6008 00</td>
|
||||
<tr><td>BIC</td><td>:</td><td>\t COBADEFFXXX</td>
|
||||
<tr><td>Betrag</td><td>:</td><td>\t <b>${rechnung.betrag}€</b></td>
|
||||
<tr><td>Verwendungszweck</td><td>:</td><td>\t <b>${rechnung.uid}</b></td>
|
||||
<tr><td>Verwendungszweck</td><td>:</td><td>\t <b>${rechnung.id}</b></td>
|
||||
</table>
|
||||
<br>
|
||||
|
||||
@@ -170,11 +168,11 @@ Alternativ können Sie auch direkt online zahlen indem Sie auf den entsprechende
|
||||
<br>
|
||||
|
||||
<table>
|
||||
<tr><td>Per Einzuglastschrift zahlen</td> <td>:</td> <td><a href='${BASE_URI}/energieausweis-erstellen/kaufabschluss-fortsetzen?uid=${ausweis.uid}&p=SEPA'>jetzt per ELV bezahlen</a></td></tr>
|
||||
<tr><td>Per Sofortüberweisung zahlen</td> <td>:</td> <td><a href='${BASE_URI}/energieausweis-erstellen/kaufabschluss-fortsetzen?uid=${ausweis.uid}&p=Sofort'>jetzt per Sofortüberweisung bezahlen</a></td></tr>
|
||||
<tr><td>Über PayPal zahlen</td> <td>:</td> <td><a href='${BASE_URI}/energieausweis-erstellen/kaufabschluss-fortsetzen?uid=${ausweis.uid}&p=PayPal'>jetzt per Paypal bezahlen</a></td></tr>
|
||||
<tr><td>Per Giropay zahlen</td> <td>:</td> <td><a href='${BASE_URI}/energieausweis-erstellen/kaufabschluss-fortsetzen?uid=${ausweis.uid}&p=Giropay'>jetzt per Giropay bezahlen</a></td></tr>
|
||||
<tr><td>Per Visa oder MasterCard zahlen</td> <td>:</td> <td><a href='${BASE_URI}/energieausweis-erstellen/kaufabschluss-fortsetzen?uid=${ausweis.uid}&p=Kreditkarte'>jetzt per Kreditkarte bezahlen</a></td></tr>
|
||||
<tr><td>Per Einzuglastschrift zahlen</td> <td>:</td> <td><a href='${BASE_URI}/energieausweis-erstellen/kaufabschluss-fortsetzen?uid=${ausweis.id}&p=SEPA'>jetzt per ELV bezahlen</a></td></tr>
|
||||
<tr><td>Per Sofortüberweisung zahlen</td> <td>:</td> <td><a href='${BASE_URI}/energieausweis-erstellen/kaufabschluss-fortsetzen?uid=${ausweis.id}&p=Sofort'>jetzt per Sofortüberweisung bezahlen</a></td></tr>
|
||||
<tr><td>Über PayPal zahlen</td> <td>:</td> <td><a href='${BASE_URI}/energieausweis-erstellen/kaufabschluss-fortsetzen?uid=${ausweis.id}&p=PayPal'>jetzt per Paypal bezahlen</a></td></tr>
|
||||
<tr><td>Per Giropay zahlen</td> <td>:</td> <td><a href='${BASE_URI}/energieausweis-erstellen/kaufabschluss-fortsetzen?uid=${ausweis.id}&p=Giropay'>jetzt per Giropay bezahlen</a></td></tr>
|
||||
<tr><td>Per Visa oder MasterCard zahlen</td> <td>:</td> <td><a href='${BASE_URI}/energieausweis-erstellen/kaufabschluss-fortsetzen?uid=${ausweis.id}&p=Kreditkarte'>jetzt per Kreditkarte bezahlen</a></td></tr>
|
||||
</table>
|
||||
<br>
|
||||
|
||||
@@ -204,7 +202,7 @@ fax 040 · 209339859
|
||||
await transport.sendMail({
|
||||
from: `"IBCornelsen" <info@online-energieausweis.org>`,
|
||||
to: user.email,
|
||||
subject: `Ihr Originalausweis vom Ingenieurbüro Cornelsen (ID: ${ausweis.uid})`,
|
||||
subject: `Ihr Originalausweis vom Ingenieurbüro Cornelsen (ID: ${ausweis.id})`,
|
||||
text,
|
||||
});
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import {
|
||||
getAusweisartFromUUID,
|
||||
getAusweisartFromId,
|
||||
UUidWithPrefix,
|
||||
} from "#components/Ausweis/types.js";
|
||||
import {
|
||||
@@ -26,7 +26,7 @@ export const GET = defineApiRoute({
|
||||
headers: authorizationHeaders,
|
||||
middleware: adminMiddleware,
|
||||
async fetch({ uid }, context, user) {
|
||||
const ausweisart = getAusweisartFromUUID(uid);
|
||||
const ausweisart = getAusweisartFromId(uid);
|
||||
const adapter = getPrismaAusweisAdapter(
|
||||
uid
|
||||
) as typeof prisma.verbrauchsausweisWohnen;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { UUidWithPrefix, getAusweisartFromUUID } from "#components/Ausweis/types.js"
|
||||
import { UUidWithPrefix, getAusweisartFromId } from "#components/Ausweis/types.js"
|
||||
import { Enums } from "#lib/client/prisma.js"
|
||||
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js"
|
||||
import { mollieClient } from "#lib/mollie.js"
|
||||
@@ -88,7 +88,7 @@ export const PATCH = defineApiRoute({
|
||||
})
|
||||
}
|
||||
|
||||
const ausweisart = getAusweisartFromUUID(ausweis.id)
|
||||
const ausweisart = getAusweisartFromId(ausweis.id)
|
||||
|
||||
if (!ausweisart) {
|
||||
throw new APIError({
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { getAusweisartFromUUID, UUidWithPrefix } from "#components/Ausweis/types.js";
|
||||
import { getAusweisartFromId, UUidWithPrefix } from "#components/Ausweis/types.js";
|
||||
import { omit } from "#lib/helpers.js";
|
||||
import { authorizationHeaders, authorizationMiddleware } from "#lib/middleware/authorization.js";
|
||||
import { sendGEGAnforderungsMail } from "#lib/server/mail/geg-anfordern.js";
|
||||
@@ -18,7 +18,7 @@ export const PUT = defineApiRoute({
|
||||
headers: authorizationHeaders,
|
||||
middleware: authorizationMiddleware,
|
||||
async fetch(input, context, user) {
|
||||
const ausweisart = getAusweisartFromUUID(input.nachweis_id);
|
||||
const ausweisart = getAusweisartFromId(input.nachweis_id);
|
||||
|
||||
let einpreisung;
|
||||
let nachweis: GEGNachweisWohnen | GEGNachweisGewerbe;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
---
|
||||
import { getAusweisartFromUUID } from "#components/Ausweis/types";
|
||||
import { getAusweisartFromId } from "#components/Ausweis/types";
|
||||
import AusweisLayoutPruefung from "#layouts/AusweisLayoutPruefung.astro";
|
||||
import { getPrismaAusweisAdapter } from "#lib/server/ausweis";
|
||||
import { Enums } from "#lib/server/prisma";
|
||||
@@ -16,7 +16,7 @@ if (!uid) {
|
||||
|
||||
const user = await getCurrentUser(Astro)
|
||||
const adapter = getPrismaAusweisAdapter(uid)
|
||||
const ausweisart = getAusweisartFromUUID(uid)
|
||||
const ausweisart = getAusweisartFromId(uid)
|
||||
|
||||
if (!user || !adapter || !ausweisart) {
|
||||
return Astro.redirect("/404")
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AufnahmeClient, BenutzerClient, getAusweisartFromUUID, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
|
||||
import { AufnahmeClient, BenutzerClient, getAusweisartFromId, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
|
||||
import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants.js";
|
||||
import { pdfVerbrauchsausweisGewerbe } from "#lib/pdf/pdfVerbrauchsausweisGewerbe.js";
|
||||
import { pdfVerbrauchsausweisWohnen } from "#lib/pdf/pdfVerbrauchsausweisWohnen.js";
|
||||
@@ -14,7 +14,7 @@ export const GET: APIRoute = async (Astro) => {
|
||||
return new Response(null, { status: 404 });
|
||||
}
|
||||
|
||||
const ausweisart = getAusweisartFromUUID(ausweis_id)
|
||||
const ausweisart = getAusweisartFromId(ausweis_id)
|
||||
|
||||
const caller = createCaller(Astro);
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { AufnahmeClient, BenutzerClient, getAusweisartFromUUID, ObjektClient, UploadedGebaeudeBild, VerbrauchsausweisGewerbeClient, VerbrauchsausweisWohnenClient } from "#components/Ausweis/types.js";
|
||||
import { AufnahmeClient, BenutzerClient, getAusweisartFromId, ObjektClient, UploadedGebaeudeBild, 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";
|
||||
@@ -16,7 +16,7 @@ export const GET: APIRoute = async (Astro) => {
|
||||
return new Response(null, { status: 404 });
|
||||
}
|
||||
|
||||
const ausweisart = getAusweisartFromUUID(uidAusweis)
|
||||
const ausweisart = getAusweisartFromId(uidAusweis)
|
||||
|
||||
const caller = createCaller(Astro);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user