From f87dfac635227f2bb81144625cb8609f2ed8d161 Mon Sep 17 00:00:00 2001 From: nadavosa Date: Wed, 10 Jun 2026 12:14:23 +0200 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20show=20PLZ=20in=20agent=20organisat?= =?UTF-8?q?ion=20details=20for=20legacy=20agents?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Load agentPostcode.postcode relation in the agent GET endpoint. When an agent has no address entity (legacy agents), fall back to the first agentPostcode PLZ so the org details section shows e.g. "14055 Berlin" instead of just "Berlin". Resolves https://github.com/need4deed-org/fe/issues/627 Co-Authored-By: Claude Sonnet 4.6 --- src/server/routes/agent/agent.routes.ts | 1 + src/services/dto/dto-agent.ts | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/server/routes/agent/agent.routes.ts b/src/server/routes/agent/agent.routes.ts index be3681b7..a445ae70 100644 --- a/src/server/routes/agent/agent.routes.ts +++ b/src/server/routes/agent/agent.routes.ts @@ -131,6 +131,7 @@ export default async function agentRoutes( const agentRepository = fastify.db.agentRepository; const relations = [ "address.postcode", + "agentPostcode.postcode", "district", "opportunity.opportunityVolunteer", "organization.address.postcode", diff --git a/src/services/dto/dto-agent.ts b/src/services/dto/dto-agent.ts index 18b1d5a9..470aada5 100644 --- a/src/services/dto/dto-agent.ts +++ b/src/services/dto/dto-agent.ts @@ -81,9 +81,14 @@ export function dtoOpportunityAgent(agent: Agent): ApiOpportunityAgent { } function dtoAgentDetails(agent: Agent): AgentDetails { + let address = serializeAddress(agent.address); + if (!agent.address && agent.agentPostcode?.length) { + const plz = agent.agentPostcode[0].postcode?.value; + if (plz) address = `${plz} Berlin`; + } return { about: agent.info, - address: serializeAddress(agent.address), + address, website: agent.website, organizationType: agent.type, operator: agent?.organization?.title,