Files
online-energieausweis/src/components/Verbrauchsausweis/audits/PlzNichtErkannt.ts
Moritz Utcke da9ffec877 Makefile
2024-11-04 15:15:10 +11:00

24 lines
772 B
TypeScript

import { GebaeudeAufnahmeClient } from "#components/Ausweis/types";
import { client } from "src/trpc";
import { memoize } from "src/lib/Memoization";
import { AuditType, hidden } from "../audits/hidden";
export const auditPlzNichtErkannt = memoize(async (gebaeude: GebaeudeAufnahmeClient) => {
if (gebaeude.plz) {
if (gebaeude.plz.length == 5) {
try {
const result = await client.v1.postleitzahlen.query({ plz: gebaeude.plz, limit: 1 });
if (result.length > 0) {
return false;
}
} catch (e) {
if (!hidden.has(AuditType.PLZ_NICHT_ERKANNT)){
return true;
}
}
}
}
return false
});