diff --git a/source/frontend/src/components/common/form/PrimaryContactSelector/PrimaryContactSelectorView.tsx b/source/frontend/src/components/common/form/PrimaryContactSelector/PrimaryContactSelectorView.tsx new file mode 100644 index 0000000000..6a3884afe9 --- /dev/null +++ b/source/frontend/src/components/common/form/PrimaryContactSelector/PrimaryContactSelectorView.tsx @@ -0,0 +1,56 @@ +import { FaExternalLinkAlt } from 'react-icons/fa'; + +import { SectionField } from '../../Section/SectionField'; +import { StyledLink } from '../../styles'; + +interface PrimaryContactSelectorViewProps { + label: string; + teamMemberName: string; + teamMemberUrl: string; + primaryContactName: string; + primaryContactUrl: string; + showPrimaryContact: boolean; + index?: number; + tooltip?: string; +} + +export const PrimaryContactSelectorView = ({ + label, + teamMemberName, + teamMemberUrl, + primaryContactName, + primaryContactUrl, + showPrimaryContact = false, + index = 0, + tooltip, +}: PrimaryContactSelectorViewProps) => ( + <> + + {teamMemberName && teamMemberUrl ? ( + + {teamMemberName} + + + ) : ( + '' + )} + + + {showPrimaryContact && ( + + {primaryContactName && primaryContactUrl ? ( + + {primaryContactName} + + + ) : ( + 'No contacts available' + )} + + )} + +); diff --git a/source/frontend/src/features/leases/detail/LeasePages/details/LeaseTeamView.tsx b/source/frontend/src/features/leases/detail/LeasePages/details/LeaseTeamView.tsx index 50bfe92506..40844d77b9 100644 --- a/source/frontend/src/features/leases/detail/LeasePages/details/LeaseTeamView.tsx +++ b/source/frontend/src/features/leases/detail/LeasePages/details/LeaseTeamView.tsx @@ -1,11 +1,8 @@ import React from 'react'; -import { FaExternalLinkAlt } from 'react-icons/fa'; +import { PrimaryContactSelectorView } from '@/components/common/form/PrimaryContactSelector/PrimaryContactSelectorView'; import { Section } from '@/components/common/Section/Section'; -import { SectionField } from '@/components/common/Section/SectionField'; -import { StyledLink } from '@/components/common/styles'; import { ApiGen_Concepts_Lease } from '@/models/api/generated/ApiGen_Concepts_Lease'; -import { exists } from '@/utils'; import { formatApiPersonNames } from '@/utils/personUtils'; export interface ILeaseTeamProps { @@ -18,47 +15,26 @@ export const LeaseTeamView: React.FunctionComponent {lease.leaseTeam.map((teamMember, index) => ( - - - - {teamMember?.person - ? formatApiPersonNames(teamMember?.person) - : teamMember?.organization?.name ?? ''} - - - - - {exists(teamMember?.organizationId) && ( - - {teamMember?.primaryContactId ? ( - - - {teamMember?.primaryContact - ? formatApiPersonNames(teamMember.primaryContact) - : ''} - - - - ) : ( - 'No contacts available' - )} - - )} + teamMemberName={ + teamMember?.person + ? formatApiPersonNames(teamMember.person) + : teamMember?.organization?.name ?? '' + } + teamMemberUrl={ + teamMember?.personId + ? `/contact/P${teamMember?.personId}` + : `/contact/O${teamMember?.organizationId}` + } + primaryContactName={ + teamMember?.primaryContact ? formatApiPersonNames(teamMember.primaryContact) : '' + } + primaryContactUrl={ + teamMember?.primaryContactId ? `/contact/P${teamMember?.primaryContactId}` : undefined + } + showPrimaryContact={!!teamMember?.organizationId} + /> ))} diff --git a/source/frontend/src/features/mapSideBar/acquisition/__snapshots__/AcquisitionView.test.tsx.snap b/source/frontend/src/features/mapSideBar/acquisition/__snapshots__/AcquisitionView.test.tsx.snap index f849b98154..8b2be1acab 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/__snapshots__/AcquisitionView.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/acquisition/__snapshots__/AcquisitionView.test.tsx.snap @@ -338,6 +338,11 @@ exports[`AcquisitionView component > renders as expected 1`] = ` cursor: pointer; } +.c42 { + padding: 0 0.4rem; + display: block; +} + .c5.btn.btn-light.Button { padding: 0; border: 0.1rem solid #9F9D9C; @@ -672,7 +677,7 @@ exports[`AcquisitionView component > renders as expected 1`] = ` white-space: pre-line; } -.c42 { +.c45 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -1879,6 +1884,7 @@ exports[`AcquisitionView component > renders as expected 1`] = `
renders as expected 1`] = `
matches snapshot 1`] = ` class="c7 text-left col" > = ({
{detail.acquisitionTeam.map((teamMember, index) => ( - - - {teamMember?.teamName} - - - - {teamMember?.organizationId && ( - - {teamMember?.primaryContactId ? ( - - {teamMember?.primaryContactName} - - - ) : ( - 'No contacts available' - )} - - )} + ))}
@@ -264,41 +247,22 @@ const AcquisitionSummaryView: React.FC = ({ {!!ownerSolicitors?.length && ownerSolicitors.map(ownerSolicitor => ( - - - - {ownerSolicitor?.personId - ? formatApiPersonNames(ownerSolicitor?.person) - : ownerSolicitor?.organization?.name ?? ''} - - - - - - {ownerSolicitor?.organization && ( - - {ownerSolicitor?.primaryContactId ? ( - - {formatApiPersonNames(ownerSolicitor.primaryContact)} - - - ) : ( - 'No contacts available' - )} - - )} + ))} {!!ownerRepresentatives?.length && diff --git a/source/frontend/src/features/mapSideBar/acquisition/tabs/fileDetails/detail/__snapshots__/AcquisitionSummaryView.test.tsx.snap b/source/frontend/src/features/mapSideBar/acquisition/tabs/fileDetails/detail/__snapshots__/AcquisitionSummaryView.test.tsx.snap index 77c1157a9a..74985f84bd 100644 --- a/source/frontend/src/features/mapSideBar/acquisition/tabs/fileDetails/detail/__snapshots__/AcquisitionSummaryView.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/acquisition/tabs/fileDetails/detail/__snapshots__/AcquisitionSummaryView.test.tsx.snap @@ -13,6 +13,22 @@ exports[`AcquisitionSummaryView component > matches snapshot 1`] = ` text-decoration: none; } +.c6 { + padding: 0 0.4rem; + display: block; +} + +.c5.required::before { + content: '*'; + position: absolute; + top: 0.75rem; + left: 0rem; +} + +.c4 { + font-weight: bold; +} + .c0 { background-color: #f2f2f2; padding-top: 1rem; @@ -38,22 +54,11 @@ exports[`AcquisitionSummaryView component > matches snapshot 1`] = ` margin-bottom: 2.4rem; } -.c5.required::before { - content: '*'; - position: absolute; - top: 0.75rem; - left: 0rem; -} - -.c4 { - font-weight: bold; -} - .c8 { white-space: pre-line; } -.c6 { +.c9 { display: -webkit-box; display: -webkit-flex; display: -ms-flexbox; @@ -665,6 +670,7 @@ exports[`AcquisitionSummaryView component > matches snapshot 1`] = `
renders as expected 1`] = ` class="pb-2 row" >
renders as expected 1`] = ` class="pb-2 row" >
matches snapshot 1`] = ` class="pb-2 row" >
matches snapshot 1`] = ` class="pb-2 row" >
{dispositionFile?.dispositionTeam?.map((teamMember, index) => ( - - - - {teamMember?.personId - ? formatApiPersonNames(teamMember?.person) - : teamMember?.organization?.name ?? ''} - - - - - {teamMember?.organizationId && ( - - {teamMember?.primaryContactId ? ( - - {formatApiPersonNames(teamMember?.primaryContact)} - - - ) : ( - 'No contacts available' - )} - - )} + teamMemberName={ + teamMember?.personId + ? formatApiPersonNames(teamMember?.person) + : teamMember?.organization?.name ?? '' + } + teamMemberUrl={ + teamMember?.personId + ? `/contact/P${teamMember?.personId}` + : `/contact/O${teamMember?.organizationId}` + } + primaryContactName={formatApiPersonNames(teamMember?.primaryContact)} + primaryContactUrl={`/contact/P${teamMember?.primaryContactId}`} + showPrimaryContact={!!teamMember?.organizationId} + > ))} diff --git a/source/frontend/src/features/mapSideBar/disposition/tabs/fileDetails/detail/__snapshots__/DispositionSummaryView.test.tsx.snap b/source/frontend/src/features/mapSideBar/disposition/tabs/fileDetails/detail/__snapshots__/DispositionSummaryView.test.tsx.snap index 98aeaab2b7..09b27c5921 100644 --- a/source/frontend/src/features/mapSideBar/disposition/tabs/fileDetails/detail/__snapshots__/DispositionSummaryView.test.tsx.snap +++ b/source/frontend/src/features/mapSideBar/disposition/tabs/fileDetails/detail/__snapshots__/DispositionSummaryView.test.tsx.snap @@ -6,7 +6,23 @@ exports[`DispositionSummaryView component > matches snapshot 1`] = ` class="Toastify" />
- .c0 { + .c4.required::before { + content: '*'; + position: absolute; + top: 0.75rem; + left: 0rem; +} + +.c3 { + font-weight: bold; +} + +.c6 { + padding: 0 0.4rem; + display: block; +} + +.c0 { background-color: #f2f2f2; padding-top: 1rem; } @@ -31,22 +47,6 @@ exports[`DispositionSummaryView component > matches snapshot 1`] = ` margin-bottom: 2.4rem; } -.c4.required::before { - content: '*'; - position: absolute; - top: 0.75rem; - left: 0rem; -} - -.c3 { - font-weight: bold; -} - -.c6 { - padding: 0 0.4rem; - display: block; -} -
@@ -481,7 +481,7 @@ exports[`DispositionSummaryView component > matches snapshot 1`] = ` class="pb-2 row" >
matches snapshot 1`] = ` class="pb-2 row" >
x.managementActivitySubtypeCode).filter(exists) ?? []; + const getRequestorName = () => { + if (props.activity?.requestorPerson) { + return formatApiPersonNames(props.activity.requestorPerson); + } else if (props.activity?.requestorOrganization) { + return props.activity.requestorOrganization?.name; + } + return null; + }; + + const getRequestorContactLink = () => { + if (props.activity?.requestorPerson) { + return `/contact/P${props.activity.requestorPerson?.id}`; + } else if (props.activity?.requestorOrganization) { + return `/contact/O${props.activity.requestorOrganization?.id}`; + } + return null; + }; + return (
@@ -58,52 +75,64 @@ const PropertyActivityDetailsSubView: React.FunctionComponent< <>{contact.person !== null && } ))} - - <> - {exists(props.activity.requestorPerson) && ( - - )} - {exists(props.activity.requestorOrganization) && ( - - )} - - - {exists(props.activity.requestorPrimaryContactId) && ( - */} + {/* <> + {exists(props.activity.requestorPerson) && ( + + )} + {exists(props.activity.requestorOrganization) && ( + + )} + + + {exists(props.activity.requestorPrimaryContactId) && ( + + {props.activity?.requestorPrimaryContactId ? ( + - {props.activity?.requestorPrimaryContactId ? ( - - - {props.activity?.requestorPrimaryContactId - ? formatApiPersonNames(props.activity?.requestorPrimaryContact) - : ''} - - - - ) : ( - 'No contacts available' - )} - + + {props.activity?.requestorPrimaryContactId + ? formatApiPersonNames(props.activity?.requestorPrimaryContact) + : ''} + + + + ) : ( + 'No contacts available' )} - - {props.activity.involvedParties?.map(contact => ( - <> - {contact.person !== null && } - {contact.organization !== null && } - - ))} - + + )} + + {props.activity.involvedParties?.map(contact => ( + <> + {contact.person !== null && } + {contact.organization !== null && } + + ))} */} + <> {props.activity.serviceProviderPerson !== null && (