\ No newline at end of file
diff --git a/src/components/Overlay.svelte b/src/components/Overlay.svelte
new file mode 100644
index 00000000..7d02411d
--- /dev/null
+++ b/src/components/Overlay.svelte
@@ -0,0 +1,16 @@
+
+
+
+
+
\ No newline at end of file
diff --git a/src/layouts/BlankLayout.astro b/src/layouts/BlankLayout.astro
new file mode 100644
index 00000000..17518447
--- /dev/null
+++ b/src/layouts/BlankLayout.astro
@@ -0,0 +1,125 @@
+---
+import i18next from "i18next";
+
+import "../style/global.scss";
+import { NotificationWrapper } from "@ibcornelsen/ui";
+
+export interface Props {
+ title: string;
+}
+
+const { title } = Astro.props;
+
+const schema = JSON.stringify({
+ "@context": "http://schema.org",
+ "@type": "Corporation",
+ name: "IB Cornelsen",
+ alternateName: "online-energieausweis.org",
+ url: "https://online-energieausweis.org",
+ logo: "https://online-energieausweis.org/ib-cornelsen.png",
+ address: {
+ "@type": "PostalAddress",
+ streetAddress: "Katendeich 5A",
+ addressLocality: "Hamburg",
+ postalCode: "21035",
+ addressCountry: "Deutschland",
+ email: "info@online-energieausweis.org",
+ },
+ contactPoint: {
+ "@type": "ContactPoint",
+ telephone: "+49-040-209339850",
+ faxNumber: "+49-040-209339859",
+ contactType: "customer service",
+ areaServed: "DE",
+ availableLanguage: "German",
+ },
+});
+---
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {title || "Energieausweis online erstellen - Online Energieausweis"}
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/lib/Berechnungen/VerbrauchsausweisWohnen/VerbrauchsausweisWohnen_2016.ts b/src/lib/Berechnungen/VerbrauchsausweisWohnen/VerbrauchsausweisWohnen_2016.ts
index 818f0e43..de24c38c 100644
--- a/src/lib/Berechnungen/VerbrauchsausweisWohnen/VerbrauchsausweisWohnen_2016.ts
+++ b/src/lib/Berechnungen/VerbrauchsausweisWohnen/VerbrauchsausweisWohnen_2016.ts
@@ -28,12 +28,18 @@ export async function endEnergieVerbrauchVerbrauchsausweis_2016(
return null
}
- const klimafaktoren = await client.v1.klimafaktoren.query({
- plz: ausweis.gebaeude_stammdaten.plz,
- genauigkeit: "years",
- startdatum: ausweis.startdatum,
- enddatum: moment(ausweis.startdatum).add(2, "years").toDate()
- })
+ try {
+ const klimafaktoren = await client.v1.klimafaktoren.query({
+ plz: ausweis.gebaeude_stammdaten.plz,
+ genauigkeit: "years",
+ startdatum: ausweis.startdatum,
+ enddatum: moment(ausweis.startdatum).add(2, "years").toDate()
+ })
+ } catch (e) {
+ return null
+ }
+
+
// Endenergieverbrauch
// Um den EEV auszurechnen, müssen die Verbräuche zu kWh konvertiert werden.
diff --git a/src/lib/Berechnungen/VerbrauchsausweisWohnen/VerbrauchsausweisWohnen_2023.ts b/src/lib/Berechnungen/VerbrauchsausweisWohnen/VerbrauchsausweisWohnen_2023.ts
index 88648bc4..f46d5a26 100644
--- a/src/lib/Berechnungen/VerbrauchsausweisWohnen/VerbrauchsausweisWohnen_2023.ts
+++ b/src/lib/Berechnungen/VerbrauchsausweisWohnen/VerbrauchsausweisWohnen_2023.ts
@@ -11,6 +11,7 @@ export function energetischeNutzflaecheVerbrauchsausweisWohnen_2023(ausweis: Ver
export async function endEnergieVerbrauchVerbrauchsausweis_2023(ausweis: VerbrauchsausweisWohnen & { gebaeude_stammdaten: GebaeudeStammdaten }): Promise {
const date = ausweis.startdatum;
+
const klimafaktoren = await getKlimafaktoren(
date,
ausweis.gebaeude_stammdaten.plz
diff --git a/src/lib/Klimafaktoren.ts b/src/lib/Klimafaktoren.ts
index ebf05065..ec7b9821 100644
--- a/src/lib/Klimafaktoren.ts
+++ b/src/lib/Klimafaktoren.ts
@@ -7,16 +7,15 @@ export const getKlimafaktoren = memoize(async (date: Date, plz: string) => {
return null;
}
- const response = await client.v1.klimafaktoren.query({
- plz,
- genauigkeit: "years",
- startdatum: date,
- enddatum: moment(date).add(2, "years").toDate()
- })
-
- if (!response) {
+ try {
+ const response = await client.v1.klimafaktoren.query({
+ plz,
+ genauigkeit: "years",
+ startdatum: date,
+ enddatum: moment(date).add(2, "years").toDate(),
+ });
+ return response;
+ } catch (e) {
return null;
}
-
- return response;
-});
\ No newline at end of file
+});
diff --git a/src/lib/caller.ts b/src/lib/caller.ts
new file mode 100644
index 00000000..bea3a05b
--- /dev/null
+++ b/src/lib/caller.ts
@@ -0,0 +1,14 @@
+import { appRouter, t } from "@ibcornelsen/api";
+import { API_ACCESS_TOKEN_COOKIE_NAME } from "./constants";
+
+export const createCaller = function (opts: any) {
+ // 1. create a caller-function for your router
+ const createCaller = t.createCallerFactory(appRouter);
+
+ // 2. create a caller using your `Context`
+ return createCaller({
+ authorization: opts.cookies.get(API_ACCESS_TOKEN_COOKIE_NAME).value ?? "",
+ ip: opts.clientAddress,
+ req: opts.request
+ });
+}
\ No newline at end of file
diff --git a/src/lib/constants.ts b/src/lib/constants.ts
new file mode 100644
index 00000000..149a176e
--- /dev/null
+++ b/src/lib/constants.ts
@@ -0,0 +1,7 @@
+import { createMollieClient } from "@mollie/api-client";
+
+export const API_ACCESS_TOKEN_COOKIE_NAME = "accessToken";
+// Mollie Payments
+export const TEST_MOLLIE_API_TOKEN = "test_jenmp2Pq3j3N6HeQxwx7qbHasWMdnx";
+
+export const mollieClient = createMollieClient({ apiKey: TEST_MOLLIE_API_TOKEN })
\ No newline at end of file
diff --git a/src/lib/login.ts b/src/lib/login.ts
new file mode 100644
index 00000000..5f5947fa
--- /dev/null
+++ b/src/lib/login.ts
@@ -0,0 +1,27 @@
+import { AppRoute } from "@ibcornelsen/api";
+import { inferProcedureOutput } from "@trpc/server";
+import Cookies from "js-cookie";
+import { client } from "src/trpc"
+
+export async function loginClient(email: string, passwort: string): Promise | null> {
+ try {
+ const response = await client.v1.benutzer.getRefreshToken.query({
+ email,
+ passwort
+ })
+
+ const options = {
+ domain: `.${window.location.hostname}`,
+ path: "/",
+ expires: response.exp
+ }
+ Cookies.set("accessToken", response.accessToken, options);
+ Cookies.set("refreshToken", response.refreshToken, options);
+ Cookies.set("uid", response.uid, options);
+
+ return response;
+ } catch (e) {
+ return null;
+
+ }
+}
\ No newline at end of file
diff --git a/src/modules/Ausweise/VerbrauchsausweisWohnenModule.svelte b/src/modules/Ausweise/VerbrauchsausweisWohnenModule.svelte
index 8612bc9a..27c6600e 100644
--- a/src/modules/Ausweise/VerbrauchsausweisWohnenModule.svelte
+++ b/src/modules/Ausweise/VerbrauchsausweisWohnenModule.svelte
@@ -9,18 +9,79 @@
import ZipSearch from "#components/ZIPSearch.svelte";
import moment from "moment";
import BilderZusatzsysteme from "#components/Ausweis/BilderZusatzsysteme.svelte";
- import { RawNotificationWrapper, RawNotification, notifications } from "@ibcornelsen/ui";
+ import { RawNotificationWrapper, RawNotification, notifications, addNotification } from "@ibcornelsen/ui";
import { auditHeizungGebaeudeBaujahr } from "#components/Verbrauchsausweis/audits/HeizungGebaeudeBaujahr";
import { AuditType, hidden } from "#components/Verbrauchsausweis/audits/hidden";
import { auditBedarfsausweisBenoetigt } from "#components/Verbrauchsausweis/audits/BedarfsausweisBenoetigt";
import { auditVerbrauchAbweichung } from "#components/Verbrauchsausweis/audits/VerbrauchAbweichung";
import { GebaeudeStammdaten, VerbrauchsausweisWohnen } from "@ibcornelsen/database";
import { client } from "src/trpc";
+ import Cookies from "js-cookie";
+ import { API_ACCESS_TOKEN_COOKIE_NAME } from "#lib/constants";
+ import Overlay from "#components/Overlay.svelte";
- export let uid: string = "";
+ export let uid: string | null = null;
- let gebaeude: GebaeudeStammdaten = {} as GebaeudeStammdaten;
- let ausweis: VerbrauchsausweisWohnen = {} as VerbrauchsausweisWohnen;
+ async function spaeterWeitermachen() {
+
+ // Um einen Ausweis zu speichern müssen wir eingeloggt sein, andernfalls wird die API den call ablehnen.
+ // Wir prüfen also ob wir eingeloggt sind und leiten den Nutzer ggf. auf die Login Seite weiter.
+ if (!Cookies.get(API_ACCESS_TOKEN_COOKIE_NAME)) {
+ loginOverlayHidden = false;
+
+ const getEvent = (event: MessageEvent) => {
+ if (event.data == "AUTHORIZED") {
+ spaeterWeitermachen();
+ window.removeEventListener("message", getEvent)
+ loginOverlayHidden = true;
+ }
+ }
+ window.addEventListener("message", getEvent)
+ return
+ }
+
+ if (uid) {
+ // Anscheinend wurde der Ausweis bereits erstellt und hat eine UID.
+ // Jetzt müssen wir ihn nun nur noch abspeichern.
+ try {
+ await client.v1.verbrauchsausweisWohnen[2016].speichern.mutate({
+ ...ausweis,
+ gebaeude_stammdaten: gebaeude,
+ uid
+ })
+
+ window.location.href = `/ausweis-gespeichert?uid=${uid}`;
+ } catch (e) {
+ addNotification({
+ dismissable: false,
+ message: "Ausweis konnte nicht gespeichert werden, bitte versuchen sie es erneut.",
+ subtext: "Sollte das Problem weiterhin bestehen, kontaktieren sie bitte den Support.",
+ timeout: 6000,
+ type: "error"
+ })
+ }
+ } else {
+ // Wir speichern den Ausweis ab und leiten auf die "ausweis-gespeichert" Seite weiter.
+ try {
+ const { uid } = await client.v1.verbrauchsausweisWohnen[2016].erstellen.mutate({
+ ...ausweis,
+ gebaeude_stammdaten: gebaeude
+ })
+ window.location.href = `/ausweis-gespeichert?uid=${uid}`;
+ } catch (e) {
+ addNotification({
+ dismissable: false,
+ message: "Ausweis konnte nicht gespeichert werden, bitte versuchen sie es erneut.",
+ subtext: "Sollte das Problem weiterhin bestehen, kontaktieren sie bitte den Support.",
+ timeout: 6000,
+ type: "error"
+ })
+ }
+ }
+ }
+
+ export let gebaeude: GebaeudeStammdaten = {} as GebaeudeStammdaten;
+ export let ausweis: VerbrauchsausweisWohnen = {} as VerbrauchsausweisWohnen;
if (uid) {
// NOTE: Funktioniert nicht mehr
async () => {
@@ -63,7 +124,7 @@
async function ausweisAbschicken() {
- overlay.ariaHidden = "false";
+ waitOverlayHidden = false;
const response = await client.v1.verbrauchsausweisWohnen[2016].erstellen.mutate({
...ausweis,
gebaeude_stammdaten: gebaeude
@@ -72,13 +133,17 @@
window.location.href = `/kundendaten?uid=${response.uid}`;
}
- let overlay: HTMLDivElement;
-
+ let waitOverlayHidden = true;
+ let loginOverlayHidden = true;
-