From 5e0674e2fbd53051d96e0fc1493cb235f37e3417 Mon Sep 17 00:00:00 2001 From: Nathnael Date: Sun, 9 Aug 2026 13:28:45 +0000 Subject: [PATCH] fix: poa email --- .../companyProfileForm/steps/PoaStep.tsx | 67 ++++++++++++------- 1 file changed, 41 insertions(+), 26 deletions(-) diff --git a/apps/edr-freight-web/portal/src/pages/accounts/companyProfileForm/steps/PoaStep.tsx b/apps/edr-freight-web/portal/src/pages/accounts/companyProfileForm/steps/PoaStep.tsx index 2c98ea473..bed6a6068 100644 --- a/apps/edr-freight-web/portal/src/pages/accounts/companyProfileForm/steps/PoaStep.tsx +++ b/apps/edr-freight-web/portal/src/pages/accounts/companyProfileForm/steps/PoaStep.tsx @@ -41,6 +41,22 @@ export default function PoaStep({ formState: { errors }, } = form; + // Fayda's email/phone/address claims are optional and routinely come back + // empty, so a *verified* representative can still be missing the email and + // phone the API demands from a freight forwarder (`REQUIRED_POA_FIELDS`) — + // and the panel above renders no input for them, which dead-ends the step on + // "Add the poa email first". Offer an input for whatever the verification + // did not supply: the API keeps exactly those keys typeable, since a claim + // that returned nothing owns no value to protect (`faydaOwnedKeys`). + const poa = identity?.poa; + // Where Fayda is mandatory an unverified representative must verify rather + // than be typed, so nothing is offered until the verification lands. + const typedAllowed = !identity || poa!.verified || !identity.faydaRequired; + const missing = (value: string | null | undefined) => + typedAllowed && !value?.trim(); + const needsEmail = missing(poa?.email); + const needsPhone = missing(poa?.phone); + return ( <> @@ -60,24 +76,19 @@ export default function PoaStep({ required={requirePoa} /> )} - {/* A verified representative's details come from the Fayda claim - and are shown on the panel above. Where Fayda cannot be - required — a foreign company whose representative may hold no - Fayda ID — they are typed here instead. They have to be: the - API refuses to save a freight forwarder's PoA without a name, - email and phone (`REQUIRED_POA_FIELDS`), and before this the - step rendered no input for any of them, so the customer was - told to "add the poa name, poa email, poa phone" with nowhere - to add them. */} - {!identity?.poa.verified && !identity?.faydaRequired && ( - <> - - + {/* Whatever the Fayda claim did carry is shown on the panel above and + is never typed here — the verification owns it. */} + {missing(poa?.name) && ( + + )} + {(needsEmail || needsPhone) && ( + + {needsEmail && ( + )} + {needsPhone && ( - - - + )} + + )} + {missing(poa?.address) && ( + )} {/* The paper authorises the representative, so it shows once one