diff --git a/supabase/functions/seed-test-data/index.ts b/supabase/functions/seed-test-data/index.ts index 147db1e2..53413da8 100644 --- a/supabase/functions/seed-test-data/index.ts +++ b/supabase/functions/seed-test-data/index.ts @@ -334,10 +334,21 @@ Deno.serve(async (req) => { return { submissionId, itemId, typeId: null }; } + // Helper function to properly pluralize company types + const pluralizeCompanyType = (singular: string): string => { + const pluralMap: Record = { + 'manufacturer': 'manufacturers', + 'operator': 'operators', + 'designer': 'designers', + 'property_owner': 'property_owners' + }; + return pluralMap[singular] || singular + 's'; + }; + // Create companies FIRST so parks can reference operators/owners const companyTypes = ['manufacturer', 'operator', 'designer', 'property_owner']; 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); for (let i = 0; i < count; i++) { const level = getPopulationLevel(fieldDensity, i);