Klimafaktoren gefixt

This commit is contained in:
Moritz Utcke
2025-03-19 12:59:46 -03:00
parent 6c0ab35f91
commit cb7b1f0c41
4 changed files with 14 additions and 5 deletions

View File

@@ -5,6 +5,7 @@ export const createCaller = createCallerFactory({
"klimafaktoren": await import("../src/pages/api/klimafaktoren.ts"),
"postleitzahlen": await import("../src/pages/api/postleitzahlen.ts"),
"unterlage": await import("../src/pages/api/unterlage.ts"),
"ausweise": await import("../src/pages/api/ausweise/index.ts"),
"admin/ausstellen": await import("../src/pages/api/admin/ausstellen.ts"),
"admin/bestellbestaetigung": await import("../src/pages/api/admin/bestellbestaetigung.ts"),
"admin/erinnern": await import("../src/pages/api/admin/erinnern.ts"),
@@ -12,11 +13,10 @@ export const createCaller = createCallerFactory({
"admin/post-ausstellen": await import("../src/pages/api/admin/post-ausstellen.ts"),
"admin/registriernummer": await import("../src/pages/api/admin/registriernummer.ts"),
"admin/stornieren": await import("../src/pages/api/admin/stornieren.ts"),
"aufnahme": await import("../src/pages/api/aufnahme/index.ts"),
"ausweise": await import("../src/pages/api/ausweise/index.ts"),
"auth/access-token": await import("../src/pages/api/auth/access-token.ts"),
"auth/passwort-vergessen": await import("../src/pages/api/auth/passwort-vergessen.ts"),
"auth/refresh-token": await import("../src/pages/api/auth/refresh-token.ts"),
"aufnahme": await import("../src/pages/api/aufnahme/index.ts"),
"bedarfsausweis-gewerbe/[uid]": await import("../src/pages/api/bedarfsausweis-gewerbe/[uid].ts"),
"bedarfsausweis-gewerbe": await import("../src/pages/api/bedarfsausweis-gewerbe/index.ts"),
"bedarfsausweis-wohnen/[uid]": await import("../src/pages/api/bedarfsausweis-wohnen/[uid].ts"),

View File

@@ -20,6 +20,11 @@ export async function auditKlimaFaktoren(
ausweis.startdatum,
gebaeude.plz
);
if (response && response.length === 3) {
return false
}
return true; // Alle Klimfaktoren konnten abgefragt werden.
} catch (e) {
return true;

View File

@@ -11,11 +11,15 @@ export const getKlimafaktoren = memoize(async (date: Date, plz: string) => {
const response = await api.klimafaktoren.GET.fetch({
plz,
genauigkeit: "years",
startdatum: moment(date).utc(true).toDate(),
enddatum: moment(date).add(2, "years").utc(true).toDate(),
// @ts-ignore Der Adapter nimmt z.coerce.date()
startdatum: moment(date).utc(true).toString(),
// @ts-ignore Der Adapter nimmt z.coerce.date()
enddatum: moment(date).add(2, "years").utc(true).toString(),
});
return response;
} catch (e) {
console.log(e);
return null;
}
});

View File

@@ -1,6 +1,6 @@
import { z } from "zod";
import moment from "moment";
import { prisma } from "#lib/server/prisma";
import { prisma } from "#lib/server/prisma.js";
import { APIError, defineApiRoute } from "astro-typesafe-api/server";
export const GET = defineApiRoute({