Fix company generation pluralization

This commit is contained in:
gpt-engineer-app[bot]
2025-10-10 17:35:55 +00:00
parent b155d8c327
commit 0c3d3ac0a9

View File

@@ -334,10 +334,21 @@ Deno.serve(async (req) => {
return { submissionId, itemId, typeId: null }; return { submissionId, itemId, typeId: null };
} }
// Helper function to properly pluralize company types
const pluralizeCompanyType = (singular: string): string => {
const pluralMap: Record<string, string> = {
'manufacturer': 'manufacturers',
'operator': 'operators',
'designer': 'designers',
'property_owner': 'property_owners'
};
return pluralMap[singular] || singular + 's';
};
// Create companies FIRST so parks can reference operators/owners // Create companies FIRST so parks can reference operators/owners
const companyTypes = ['manufacturer', 'operator', 'designer', 'property_owner']; const companyTypes = ['manufacturer', 'operator', 'designer', 'property_owner'];
for (const compType of companyTypes) { for (const compType of companyTypes) {
if (entityTypes.includes(compType + 's') || entityTypes.includes(compType === 'manufacturer' ? 'manufacturers' : compType === 'property_owner' ? 'property_owners' : compType + 's')) { if (entityTypes.includes(pluralizeCompanyType(compType))) {
const count = Math.floor(plan.companies / 4); const count = Math.floor(plan.companies / 4);
for (let i = 0; i < count; i++) { for (let i = 0; i < count; i++) {
const level = getPopulationLevel(fieldDensity, i); const level = getPopulationLevel(fieldDensity, i);