Skip to content

Link opportunity contact person to agent_person on legacy form submit#665

Open
nadavosa wants to merge 5 commits into
developfrom
664-link-contact-person-to-agent
Open

Link opportunity contact person to agent_person on legacy form submit#665
nadavosa wants to merge 5 commits into
developfrom
664-link-contact-person-to-agent

Conversation

@nadavosa

Copy link
Copy Markdown
Collaborator

Summary

  • After saving the contact person from a legacy form submission, inserts an agent_person row (role VOLUNTEER_COORDINATOR) linking them to the matched/created agent
  • Never touches existing agent_person rows — only adds a new link if needed
  • The submitter was already linked via getOrCreateSubmitterPerson; this covers the contact person which was previously only attached to the opportunity

Why

agent_person should accumulate all persons known to be associated with a center. The FE currently shows one contact, but the backend should already build the full list for future use.

Resolves #664

Test plan

  • Submit a legacy form for an existing agent → contact person appears in agent_person for that agent with VOLUNTEER_COORDINATOR role
  • Submit a legacy form that creates a new agent → contact person is linked to the new agent
  • Existing agent_person rows (representative etc.) are not changed

🤖 Generated with Claude Code

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 #664

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>

if (opportunity.agent?.id) {
const agentPersonRepository = getRepository(dataSource, AgentPerson);
await agentPersonRepository.save(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it might throw violation of constraint:
"IDX_f15c4b743ddfba08409b99f797" UNIQUE, btree (agent_id, person_id, role)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Link opportunity contact persons to agent_person without overriding representative

2 participants