Kaufabschluss funktioniert.
Kaufabschluss funktioniert einzeln, gesamter Durchgang geht auch. Input Validation ist der nächste große Schritt. Im Formular kommen immer noch viele Werte raus die wir nicht in der Datenbank haban wollen...
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -11,6 +11,7 @@ export function energetischeNutzflaecheVerbrauchsausweisWohnen_2023(ausweis: Ver
|
||||
|
||||
export async function endEnergieVerbrauchVerbrauchsausweis_2023(ausweis: VerbrauchsausweisWohnen & { gebaeude_stammdaten: GebaeudeStammdaten }): Promise<number> {
|
||||
const date = ausweis.startdatum;
|
||||
|
||||
const klimafaktoren = await getKlimafaktoren(
|
||||
date,
|
||||
ausweis.gebaeude_stammdaten.plz
|
||||
|
||||
@@ -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;
|
||||
});
|
||||
});
|
||||
|
||||
14
src/lib/caller.ts
Normal file
14
src/lib/caller.ts
Normal file
@@ -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
|
||||
});
|
||||
}
|
||||
7
src/lib/constants.ts
Normal file
7
src/lib/constants.ts
Normal file
@@ -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 })
|
||||
27
src/lib/login.ts
Normal file
27
src/lib/login.ts
Normal file
@@ -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<inferProcedureOutput<AppRouter["v1"]["benutzer"]["getRefreshToken"]> | 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;
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user