KI-AGENT: Erweitert Länderauswahl für Lieferanten (#157)

Die Länderauswahl wird beim Laden der Spezialressource um eine vollständige deutschsprachige Standardliste ergänzt. Bestehende Datenbankeinträge bleiben erhalten und überschreiben die Standardwerte.
This commit is contained in:
2026-05-11 17:52:59 +02:00
parent c42e57494a
commit aa162dcad3
2 changed files with 277 additions and 0 deletions

View File

@@ -4,6 +4,7 @@ import { sortData } from "../utils/sort"
// Schema imports
import { accounts, units, countrys, tenants } from "../../db/schema"
import { defaultCountries } from "../utils/countries"
const TABLE_MAP: Record<string, any> = {
accounts,
@@ -96,6 +97,24 @@ export default async function resourceRoutesSpecial(server: FastifyInstance) {
const data = await query
if (resource === "countrys") {
const countryMap = new Map<string, any>()
for (const country of defaultCountries) {
countryMap.set(country.toLocaleLowerCase("de"), { id: country, name: country })
}
for (const country of data) {
countryMap.set(country.name.toLocaleLowerCase("de"), country)
}
return sortData(
Array.from(countryMap.values()),
sort || "name",
sort ? ascQuery === "true" : true
)
}
// Falls sort clientseitig wie früher notwendig ist:
const sorted = sortData(
data,