Skip to content

Commit

Permalink
psp-8708 fix tenant primary contacts. (bcgov#4176)
Browse files Browse the repository at this point in the history
Co-authored-by: Alejandro Sanchez <[email protected]>
  • Loading branch information
devinleighsmith and asanchezr authored Jul 12, 2024
1 parent fa59c26 commit f4753b6
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ public class ContactSummaryModel
/// </summary>
public long? PersonId { get; set; }

public PersonModel Person { get; set; }
public Pims.Api.Models.Concepts.Person.PersonModel Person { get; set; }

/// <summary>
/// get/set - The primary key to identify the organization.
/// </summary>
public long? OrganizationId { get; set; }

public OrganizationModel Organization { get; set; }
public Pims.Api.Models.Concepts.Organization.OrganizationModel Organization { get; set; }

/// <summary>
/// get/set - The concurrency row version.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ exports[`Contact Search Results Table > matches snapshot 1`] = `
<div
class="sortable-column"
>
Update/View
Edit/View
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ const columns: ColumnWithProps<IContactSearchResult>[] = [
maxWidth: 50,
},
{
Header: 'Update/View',
Header: 'Edit/View',
accessor: 'controls' as any, // this column is not part of the data model
width: 50,
maxWidth: 50,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -974,7 +974,7 @@ exports[`ContactManagerView > matches snapshot 1`] = `
<div
class="sortable-column"
>
Update/View
Edit/View
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1050,7 +1050,7 @@ exports[`Contact List View > matches snapshot 1`] = `
<div
class="sortable-column"
>
Update/View
Edit/View
</div>
</div>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ export const AddLeaseTenantForm: React.FunctionComponent<
Note: If the tenants you are trying to find were never added to the &quot;contact
list&quot; it will not show up. Please add them to the contact list{' '}
{<Link to="/contact/list">here</Link>}, then you will be able to see them on the &quot;Add
&quot;Add a Tenant&quot; list.
a Tenant&quot; list.
</span>

<Formik
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ exports[`AddLeaseTenantForm component > renders as expected 1`] = `
>
here
</a>
, then you will be able to see them on the "Add "Add a Tenant" list.
, then you will be able to see them on the "Add a Tenant" list.
</span>
<div
class="c6"
Expand All @@ -301,13 +301,13 @@ exports[`AddLeaseTenantForm component > renders as expected 1`] = `
<div
class="tr"
role="row"
style="display: flex; flex: 1 0 auto; min-width: 410px;"
style="display: flex; flex: 1 0 auto; min-width: 416px;"
>
<div
class="th"
colspan="1"
role="columnheader"
style="box-sizing: border-box; flex: 10 0 auto; min-width: 10px; width: 10px; justify-content: right; text-align: right; flex-wrap: wrap; align-items: center; display: flex;"
style="box-sizing: border-box; flex: 16 0 auto; min-width: 16px; width: 16px; justify-content: right; text-align: right; flex-wrap: wrap; align-items: center; display: flex;"
>
<div
class="sortable-column"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { FaRegBuilding, FaRegUser } from 'react-icons/fa';
import { FaCircle } from 'react-icons/fa';
import { Link } from 'react-router-dom';
import { CellProps } from 'react-table';
import styled from 'styled-components';

import Active from '@/assets/images/active.svg?react';
import Inactive from '@/assets/images/inactive.svg?react';
import { Select, SelectOption } from '@/components/common/form';
import { ColumnWithProps } from '@/components/Table';
import { getPrimaryContact } from '@/features/contacts/contactUtils';
Expand All @@ -18,11 +18,23 @@ const getColumns = (tenantTypes: SelectOption[]): ColumnWithProps<FormTenant>[]
Header: '',
accessor: 'isDisabled',
align: 'right',
width: 10,
maxWidth: 10,
minWidth: 10,
Cell: (props: CellProps<FormTenant>) =>
props.row.original.isDisabled ? <Inactive /> : <Active />,
width: 16,
maxWidth: 16,
minWidth: 16,
Cell: (props: CellProps<FormTenant>) => {
const original = props.row.original;
const status =
original.original !== undefined
? original.original.id.startsWith('O') === true
? original.original.organization.isDisabled
: original.isDisabled
: original.isDisabled;
return (
<StatusIndicators className={status ? 'inactive' : 'active'}>
<FaCircle size={10} className="mr-2" />
</StatusIndicators>
);
},
},
{
Header: '',
Expand Down Expand Up @@ -58,7 +70,10 @@ const getColumns = (tenantTypes: SelectOption[]): ColumnWithProps<FormTenant>[]
width: 120,
Cell: (props: CellProps<FormTenant>) => {
const original = props.row.original;
const persons = original?.organizationPersons?.map(op => op.person);
const persons =
original.original !== undefined && isValidId(props?.row?.original?.organizationId)
? original?.original.organization.organizationPersons?.map(op => op.person)
: original?.organizationPersons?.map(op => op.person);
let primaryContact = original.initialPrimaryContact;
if (original.primaryContactId !== original.initialPrimaryContact?.id) {
primaryContact = original.primaryContactId
Expand Down Expand Up @@ -129,4 +144,12 @@ const getColumns = (tenantTypes: SelectOption[]): ColumnWithProps<FormTenant>[]
},
];
};

export const StatusIndicators = styled.div`
color: ${props => props.theme.css.borderOutlineColor};
&.active {
color: ${props => props.theme.bcTokens.iconsColorSuccess};
}
`;

export default getColumns;

0 comments on commit f4753b6

Please sign in to comment.