Skip to content

Commit

Permalink
fix : updated confirmation form adress format
Browse files Browse the repository at this point in the history
  • Loading branch information
prwozny committed Oct 16, 2024
1 parent b2ffef3 commit fadbf2c
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions src/ui/SurveyUnit/Communication/CommunicationConfirmation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,11 @@ const CommunicationConfirmation = ({
bypassReasonLabel,
}: CommunicationConfirmationProps) => {
const address = getAddressData(surveyUnit.address);
const addressLines = Object.values(address).filter(v => !!v);
const recipient = getprivilegedPerson(surveyUnit);
const { user } = useUser();

const userError = userSchema.safeParse(user);
const recipientError = recipientSchema.safeParse({ ...address, ...recipient });
const communicationError = communicationSchema.safeParse(communication);

const isValid = userError.success && recipientError.success && communicationError.success;

return (
Expand Down Expand Up @@ -89,12 +86,22 @@ const CommunicationConfirmation = ({
>
{getTitle(recipient.title)} {recipient.firstName} {recipient.lastName}
<br />
{addressLines.map(line => (
<Fragment key={line.toString()}>
{line}
<br />
<Fragment>
{address.streetName} <br />
</Fragment>
{address.additionalAddress.length > 0 && (
<Fragment>
{address.additionalAddress} <br />
</Fragment>
))}
)}
{address.locality.length > 0 && (
<Fragment>
{address.locality} <br />
</Fragment>
)}
<Fragment>
{address.postCode}, {address.cityName}
</Fragment>
</Typography>
{!recipientError.success && <ValidationError error={recipientError.error} mt={1} />}
</div>
Expand Down

0 comments on commit fadbf2c

Please sign in to comment.