53 lines
1.4 KiB
Plaintext
53 lines
1.4 KiB
Plaintext
---
|
|
import { getAusweisartFromId } from "#components/Ausweis/types";
|
|
import AusweisLayoutPruefung from "#layouts/AusweisLayoutPruefung.astro";
|
|
import { getPrismaAusweisAdapter } from "#lib/server/ausweis";
|
|
import { Enums } from "#lib/server/prisma";
|
|
import { getCurrentUser } from "#lib/server/user";
|
|
import KundendatenModule from "#modules/KundendatenModule.svelte";
|
|
import { PaymentStatus } from "@mollie/api-client";
|
|
import { AusweisTyp } from "src/generated/enums";
|
|
|
|
const uid = Astro.url.searchParams.get("uid")
|
|
|
|
if (!uid) {
|
|
return Astro.redirect("/404")
|
|
}
|
|
|
|
const user = await getCurrentUser(Astro)
|
|
const adapter = getPrismaAusweisAdapter(uid)
|
|
const ausweisart = getAusweisartFromId(uid)
|
|
|
|
if (!user || !adapter || !ausweisart) {
|
|
return Astro.redirect("/404")
|
|
}
|
|
|
|
const ausweis = await adapter.findUnique({
|
|
where: {
|
|
uid,
|
|
benutzer_id: user.id
|
|
},
|
|
include: {
|
|
aufnahme: {
|
|
include: {
|
|
objekt: true,
|
|
bilder: true
|
|
}
|
|
},
|
|
rechnung: true
|
|
}
|
|
})
|
|
|
|
if (!ausweis) {
|
|
return Astro.redirect("/404")
|
|
}
|
|
|
|
if (ausweis.rechnung.status === PaymentStatus.paid) {
|
|
return Astro.redirect("/dashboard")
|
|
}
|
|
---
|
|
|
|
<AusweisLayoutPruefung title="Energieausweis Bezahlung">
|
|
<KundendatenModule {user} {ausweis} objekt={ausweis.aufnahme.objekt} rechnung={ausweis.rechnung} aufnahme={ausweis.aufnahme} bilder={ausweis.aufnahme.bilder} {ausweisart} ausweistyp={AusweisTyp.Standard} aktiveBezahlmethode={Enums.Bezahlmethoden.paypal} client:only></KundendatenModule>
|
|
</AusweisLayoutPruefung>
|