From 9c2e2b35e9be6c83bdabfc1727cb7eb6b4c72d41 Mon Sep 17 00:00:00 2001 From: nadavosa Date: Wed, 10 Jun 2026 12:45:52 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20link=20opportunity=20contact=20pers?= =?UTF-8?q?on=20to=20agent=5Fperson=20on=20legacy=20form=20submit?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When a legacy form submission creates an opportunity, the contact person is now also inserted into agent_person (VOLUNTEER_COORDINATOR) for the matched/created agent. This builds up the full list of known persons per agent over time without touching the existing representative. The submitter was already linked via getOrCreateSubmitterPerson; this covers the contact person which was previously only linked to the opportunity. Resolves https://github.com/need4deed-org/be/issues/664 Co-Authored-By: Claude Sonnet 4.6 --- src/server/routes/opportunity/legacy.routes.ts | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/server/routes/opportunity/legacy.routes.ts b/src/server/routes/opportunity/legacy.routes.ts index 14df7fcf..4626340a 100644 --- a/src/server/routes/opportunity/legacy.routes.ts +++ b/src/server/routes/opportunity/legacy.routes.ts @@ -116,6 +116,15 @@ export default async function opportunityLegacyRoutes( Object.assign(opportunity, await addDistrictToOpportunity(opportunity)); if (opportunity.agent?.id) { + const agentPersonRepository = getRepository(dataSource, AgentPerson); + await agentPersonRepository.save( + new AgentPerson({ + agentId: opportunity.agent.id, + personId: contactPerson.id, + role: AgentRoleType.VOLUNTEER_COORDINATOR, + }), + ); + const submitter = await getOrCreateSubmitterPerson( request.body, opportunity.agent.id,