24 lines
772 B
TypeScript
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
|
|
});
|