Skip to content

Commit

Permalink
Backmerge test to dev (#3347)
Browse files Browse the repository at this point in the history
* psp-6425 ensure that a new property added to a lease shows up on the map without requiring manual refresh. (#3296)

* psp-6442 filter expired codes, correct code value displays. (#3300)

* HOTFIX: Psp 6408 - separate unmounted vs. error map search behaviour. (#3297)

* separate unmounted vs error behaviour on usemapsearch.

* test corrections.

* correct try/catch location.

* psp-6499 ensure access request region is being populated when accepting an AR. (#3301)

* financial activity code instead of id, concurrency control and update corrections. (#3305)

* bump version number for 4.0 (#3306)

* Fix issue where bad tenant data can cause an NPE. (#3309)

* TEST Release - IS57 (#3312)

* Automation test - Stabilization of some automated features (#3285)

* Automation Projects

* Automation - Projects and Products automation

* Leases refactoring

* Leases refactoring

* Acquisition Files refactoring

* Automation fixes

* Automation - stabilization of some automation features

---------

Co-authored-by: devinleighsmith <41091511+devinleighsmith@users.noreply.github.com>

* PSP-5111

* CI: Bump version to v3.2.0-56.18

* CI: Bump version to v3.2.0-56.19

* PSP-6286 : Restrict changing final compensation requisition status back to draft (#3281)

---------

Co-authored-by: Eduardo Herrera <Eduardo.Herrera@quartech.com>

* CI: Bump version to v3.2.0-56.20

* PSP-5715 : Sec3/Sec6 add forms to acquisition file (#3292)


Co-authored-by: Eduardo Herrera <Eduardo.Herrera@quartech.com>

* CI: Bump version to v3.2.0-56.21

* Psp 6322 - lease and license refactor (#3253)

* psp-6322 lease refactor.

* merge corrections.

* lint corrections.

* code review updates.

* merge corrections.

* test corrections.

* CI: Bump version to v3.2.0-56.22

* psp-5361: fix link name for financial codes in admin tools (#3291)

* CI: Bump version to v3.2.0-56.23

* Bump DEV version - IS57 (#3295)

* CI: Bump version to v3.2.0-57.1

* PSP-5951 refactor left hand file navigation - Acquisition ONLY (#3288)

* Update useQuery global hook

* Update shared tabbed forms

* Refactor property tabs to work with state OR routing

* Refactor acquisition left hand navigation to use routing

* Remove setContainerState callback from acquisition forms

* Test corrections

* Improve tab names for properties

* Set header title based on current tab route

* Fix routing issue with requisition compensations

* Update snapshots

* Fix failing tests

* Fix bug when removing property from File

* Add tests for routing in Acquisition View

* Redirect to default tabs when editing and path doesn't match

* Test corrections

* Fix dereference error when accessing non-existing property index

* Remove unused code

* Move router components to router folder

* Test corrections

* CI: Bump version to v3.2.0-57.2

* psp-5791: add assignee to tenant types (#3290)

* CI: Bump version to v3.2.0-57.3

* psp-6246 increase keycloak sync resiliancy via polly, also update deprecated calls from keycloak api. (#3294)

* CI: Bump version to v3.2.0-57.4

* PSP-5716, PSP-5717, PSP-5719: Expropriation forms 1, 5 and 9 (#3303)

* WIP

* Code refactor to accommodate expropriation forms

* Fix styling for ContactPicker

* WIP - Expr Form1

* ContactInputView fixes

* Refactor interest holder property table into generic file property table

* Expropriation Form1 - WIP

* Create generic wrapper around form items to provide validation error feedback

* Add impacted properties table to Expropriation Form 1

* Update snapshots

* Add remaining expropriation forms

* Make forms more testable

* Unit tests

* CI: Bump version to v3.2.0-57.5

* psp-5860 limit lease and license access by region. (#3298)

* psp-5860 limit lease and license access by region.

* PR updates.

* lint fixes.

* fix null vs undefined on project display.

* correct null vs undefined at model level.

* removed dead code.

* CI: Bump version to v3.2.0-57.6

* psp-6428 fix layers colors (#3304)

Co-authored-by: devinleighsmith <41091511+devinleighsmith@users.noreply.github.com>
Co-authored-by: Alejandro Sanchez <emailforasr@gmail.com>

* CI: Bump version to v3.2.0-57.7

* Merge fixes

* CI: Bump version to v4.0.0-57.8

---------

Co-authored-by: Sue Tairaku <42981334+stairaku@users.noreply.github.com>
Co-authored-by: devinleighsmith <41091511+devinleighsmith@users.noreply.github.com>
Co-authored-by: PryancaJSharma <99448336+PryancaJSharma@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Eduardo <eddherrera@users.noreply.github.com>
Co-authored-by: Eduardo Herrera <Eduardo.Herrera@quartech.com>
Co-authored-by: Aman Monga <53246811+buddy326@users.noreply.github.com>

* CI: Bump version to v4.0.0-57.9

* psp-6495 Correct issue with object matching not working as expected. (#3310)

* HOTFIX: h0074 standardize agreement owner string other name. (#3315)

* h0074 standardize agreement owner string other name.

* unit test corrections.

* use financial code instead of id in generated h120. (#3316)

Co-authored-by: Alejandro Sanchez <emailforasr@gmail.com>

* Increment hotfix version in UAT (#3321)

* PSP-6522 : Display user friendly error when compensation req does not… (#3323)

Co-authored-by: Eduardo Herrera <Eduardo.Herrera@quartech.com>

* CI: Bump version to v4.0.0-57.10

* fix trufflehog install from failing (#3333) (#3335)

* correct credentials scan failure.

* force dependency versions.

---------

Co-authored-by: Smith <Devin.Smith@quartech.com>

* Fix for takes not showing properly on the update screen | psp-6572 (#3332)

* Fix for takes not showing properly on the update screen

* Removed debugger code

* PSP-6563 : HOTFIX: in trust is missing on H120 (#3325)

Co-authored-by: Eduardo Herrera <Eduardo.Herrera@quartech.com>

* PSP-6557 : HOTFIX - Missing values on Template H120 (#3326)

Co-authored-by: Eduardo Herrera <Eduardo.Herrera@quartech.com>

* Fixed business function not being displayed (#3330)

* Psp 6566 map search corrections (#3338)

* psp-6566

* correct order of operations for 0 pad.

* psp-6585 updates to allow etl to overwrite null expiry date on yearly financial codes. (#3340)

* bump release hotfix version. (#3341)

Co-authored-by: Smith <Devin.Smith@quartech.com>

* PSP-6527 : FT-REG: Lease & License - When a new license is created, the Created By and Last updated By dates are not displayed and the user is always USER (#3336)

Co-authored-by: Eduardo Herrera <Eduardo.Herrera@quartech.com>

* CI: Bump version to v4.0.0-57.11

* CI: Bump version to v4.0.3-57.51

* Update snapshots

---------

Co-authored-by: devinleighsmith <41091511+devinleighsmith@users.noreply.github.com>
Co-authored-by: Sue Tairaku <42981334+stairaku@users.noreply.github.com>
Co-authored-by: PryancaJSharma <99448336+PryancaJSharma@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Eduardo <eddherrera@users.noreply.github.com>
Co-authored-by: Eduardo Herrera <Eduardo.Herrera@quartech.com>
Co-authored-by: Aman Monga <53246811+buddy326@users.noreply.github.com>
Co-authored-by: Smith <Devin.Smith@quartech.com>
Co-authored-by: Manuel Rodriguez <marobej@gmail.com>
Co-authored-by: devinleighsmith <devinleighsmith@gmail.com>
  • Loading branch information
11 people authored Jul 20, 2023
1 parent d895b1d commit 7a98af8
Show file tree
Hide file tree
Showing 31 changed files with 790 additions and 859 deletions.
4 changes: 2 additions & 2 deletions etl/PAIMS_PIMS_CODES/PAIMS_PIMS_CODES/PAIMS_PIMS_CODES.dtproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
<SSIS:Property SSIS:Name="Name">PAIMS_PIMS_CODES</SSIS:Property>
<SSIS:Property SSIS:Name="VersionMajor">1</SSIS:Property>
<SSIS:Property SSIS:Name="VersionMinor">0</SSIS:Property>
<SSIS:Property SSIS:Name="VersionBuild">1406</SSIS:Property>
<SSIS:Property SSIS:Name="VersionBuild">1413</SSIS:Property>
<SSIS:Property SSIS:Name="VersionComments">
</SSIS:Property>
<SSIS:Property SSIS:Name="VersionGUID">{5BB42B30-09D9-4E62-9A8E-E77E1E840BDB}</SSIS:Property>
<SSIS:Property SSIS:Name="VersionGUID">{4AD6A5F9-CB28-45F8-8DBE-C1808D7673CA}</SSIS:Property>
<SSIS:Property SSIS:Name="PackageFormatVersion">8</SSIS:Property>
<SSIS:Property SSIS:Name="Description">
</SSIS:Property>
Expand Down
1,342 changes: 655 additions & 687 deletions etl/PAIMS_PIMS_CODES/PAIMS_PIMS_CODES/PAIMS_PIMS_CODES.dtsx

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ public IActionResult GetFileCompensations(long id)
/// <returns></returns>
[HttpGet("{id:long}/comp-req-h120s")]
[Produces("application/json")]
[ProducesResponseType(typeof(IEnumerable<H120CategoryModel>), 200)]
[ProducesResponseType(typeof(IEnumerable<CompensationFinancialModel>), 200)]
[SwaggerOperation(Tags = new[] { "comp-req-h120s" })]
public IActionResult GetFileCompReqH120(long id, bool? finalOnly)
{
Expand All @@ -251,9 +251,9 @@ public IActionResult GetFileCompReqH120(long id, bool? finalOnly)
DateTime.Now);
_logger.LogInformation("Dispatching to service: {Service}", _compReqH120Service.GetType());

var h120Categories = _compReqH120Service.GetAllByAcquisitionFileId(id, finalOnly);
var h120s = _compReqH120Service.GetAllByAcquisitionFileId(id, finalOnly);

return new JsonResult(_mapper.Map<IEnumerable<CompensationFinancialModel>>(h120Categories));
return new JsonResult(_mapper.Map<IEnumerable<CompensationFinancialModel>>(h120s));
}

/// <summary>
Expand Down
7 changes: 1 addition & 6 deletions source/backend/api/Models/Concepts/Lease/LeaseModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace Pims.Api.Models.Concepts
/// <summary>
/// Provides a lease-oriented model.
/// </summary>
public class LeaseModel
public class LeaseModel : BaseAppModel
{
#region Properties

Expand All @@ -16,11 +16,6 @@ public class LeaseModel
/// </summary>
public long Id { get; set; }

/// <summary>
/// get/set - The concurrency row version.
/// </summary>
public long RowVersion { get; set; }

/// <summary>
/// get/set - The lease amount.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void Register(TypeAdapterConfig config)
.Map(dest => dest.PsFileNumber, src => src.LeaseTerm.Lease.PsFileNo)
.Map(dest => dest.LeaseStatus, src => src.LeaseTerm.Lease.LeaseStatusTypeCodeNavigation.Description)
.Map(dest => dest.PropertyList, src => string.Join(",", src.LeaseTerm.Lease.PimsPropertyLeases.Select(x => GetFallbackPropertyIdentifier(x))))
.Map(dest => dest.TenantList, src => string.Join(",", src.LeaseTerm.Lease.PimsLeaseTenants.Where(t => t.TenantTypeCode == "TEN").Select(x => x.Person != null ? x.Person.GetFullName() : x.Organization.OrganizationName)))
.Map(dest => dest.TenantList, src => string.Join(",", src.LeaseTerm.Lease.PimsLeaseTenants.Where(t => t != null && t.TenantTypeCode == "TEN").Select(x => x != null && x.Person != null ? x.Person.GetFullName() : x != null && x.Organization != null ? x.Organization.OrganizationName : string.Empty)))
.Map(dest => dest.PayableOrReceivable, src => src.LeaseTerm.Lease.LeasePayRvblTypeCodeNavigation.Description)
.Map(dest => dest.Program, src => src.LeaseTerm.Lease.LeaseProgramTypeCode.ToUpper() == "OTHER" && !string.IsNullOrEmpty(src.LeaseTerm.Lease.OtherLeaseProgramType) ? $"{src.LeaseTerm.Lease.LeaseProgramTypeCodeNavigation.Description} - {src.LeaseTerm.Lease.OtherLeaseProgramType}" : src.LeaseTerm.Lease.LeaseProgramTypeCodeNavigation.Description)
.Map(dest => dest.Purpose, src => src.LeaseTerm.Lease.LeasePurposeTypeCode.ToUpper() == "OTHER" && !string.IsNullOrEmpty(src.LeaseTerm.Lease.OtherLeasePurposeType) ? $"{src.LeaseTerm.Lease.LeasePurposeTypeCodeNavigation.Description} - {src.LeaseTerm.Lease.OtherLeasePurposeType}" : src.LeaseTerm.Lease.LeasePurposeTypeCodeNavigation.Description)
Expand Down
2 changes: 1 addition & 1 deletion source/backend/api/Pims.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
</ItemGroup>
</Project>
</Project>
5 changes: 4 additions & 1 deletion source/backend/dal/Repositories/CompReqH120Repository.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ public IEnumerable<PimsCompReqH120> GetAllByAcquisitionFileId(long acquisitionFi
{
this._user.ThrowIfNotAllAuthorized(Security.Permissions.CompensationRequisitionView);

var query = Context.PimsCompReqH120s.Include(c => c.CompensationRequisition).Where(c => c.CompensationRequisition.AcquisitionFileId == acquisitionFileId);
var query = Context.PimsCompReqH120s
.Include(c => c.CompensationRequisition)
.Where(c => c.CompensationRequisition.AcquisitionFileId == acquisitionFileId);

if (finalOnly == true)
{
query = query.Where(c => c.CompensationRequisition.IsDraft == false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ export const TermsForm: React.FunctionComponent<React.PropsWithChildren<ITermsFo
const renderPayments = useDeepCompareMemo(
() => (row: FormLeaseTerm) => {
const matchingTerm = leaseForm.terms.find(t => t.id === row.id);
if (!matchingTerm) {
throw Error('Could not find matching term');
}
return (
<PaymentsForm
onSave={onSavePayment}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { useDocumentGenerationRepository } from '@/features/documents/hooks/useD
import { useAcquisitionProvider } from '@/hooks/repositories/useAcquisitionProvider';
import { useH120CategoryRepository } from '@/hooks/repositories/useH120CategoryRepository';
import { useInterestHolderRepository } from '@/hooks/repositories/useInterestHolderRepository';
import { useCompensationRequisitionRepository } from '@/hooks/repositories/useRequisitionCompensationRepository';
import { mockAcquisitionFileResponse } from '@/mocks/acquisitionFiles.mock';
import { getMockApiCompensationList } from '@/mocks/compensations.mock';
import { Api_AcquisitionFile } from '@/models/api/AcquisitionFile';
Expand All @@ -23,6 +24,7 @@ const getAcquisitionPropertiesFn = jest.fn();
const getAcquisitionCompReqH120s = jest.fn();
const getH120sCategoryFn = jest.fn();
const getInterestHolderFn = jest.fn();
const getCompensationRequisitionPayeeFn = jest.fn();

jest.mock('@/features/documents/hooks/useDocumentGenerationRepository');
(useDocumentGenerationRepository as jest.Mock).mockImplementation(() => ({
Expand All @@ -44,6 +46,10 @@ jest.mock('@/hooks/repositories/useInterestHolderRepository');
(useInterestHolderRepository as jest.Mock).mockImplementation(() => ({
getAcquisitionInterestHolders: { execute: getInterestHolderFn },
}));
jest.mock('@/hooks/repositories/useRequisitionCompensationRepository');
(useCompensationRequisitionRepository as jest.Mock).mockImplementation(() => ({
getCompensationRequisitionPayee: { execute: getCompensationRequisitionPayeeFn },
}));

let currentStore: MockStoreEnhanced<any, {}>;
const mockStore = configureMockStore([thunk]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
import axios, { AxiosError } from 'axios';
import { useCallback, useEffect, useState } from 'react';
import { toast } from 'react-toastify';

import { useGenerateH120 } from '@/features/properties/map/acquisition/common/GenerateForm/hooks/useGenerateH120';
import { useCompensationRequisitionRepository } from '@/hooks/repositories/useRequisitionCompensationRepository';
import { IApiError } from '@/interfaces/IApiError';
import { Api_AcquisitionFile } from '@/models/api/AcquisitionFile';
import { Api_CompensationPayee } from '@/models/api/CompensationPayee';
import { Api_CompensationRequisition } from '@/models/api/CompensationRequisition';
Expand Down Expand Up @@ -31,9 +34,18 @@ export const CompensationRequisitionDetailContainer: React.FunctionComponent<

const fetchCompensationPayee = useCallback(async () => {
if (!!compensation.id) {
const payee = await getCompensationRequisitionPayee(compensation.id);
if (payee) {
try {
const payee = await getCompensationRequisitionPayee(compensation.id);
setCompensationPayee(payee);
} catch (e) {
if (axios.isAxiosError(e)) {
const axiosError = e as AxiosError<IApiError>;
if (axiosError.response?.status === 404) {
setCompensationPayee(undefined);
} else {
toast.error(axiosError.response?.data.error);
}
}
}
}
}, [compensation, getCompensationRequisitionPayee]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,6 @@ interface PayeeViewDetails {
displayName: string;
isGstApplicable: boolean;
gstNumber: string;
preTaxAmount: number;
taxAmount: number;
totalAmount: number;
goodTrust: boolean;
contactEnabled: boolean;
personId: number | null;
Expand Down Expand Up @@ -83,22 +80,6 @@ export const CompensationRequisitionDetailView: React.FunctionComponent<
payeeDetail.personId = compensationPayee.motiSolicitor?.id!;
}

const payeePretaxAmount = compensation?.financials
.map(f => f.pretaxAmount ?? 0)
.reduce((prev, next) => prev + next, 0);

const payeeTaxAmount = compensation?.financials
.map(f => f.taxAmount ?? 0)
.reduce((prev, next) => prev + next, 0);

const payeeTotalAmount = compensation?.financials
.map(f => f.totalAmount ?? 0)
.reduce((prev, next) => prev + next, 0);

payeeDetail.preTaxAmount = payeePretaxAmount;
payeeDetail.taxAmount = payeeTaxAmount;
payeeDetail.totalAmount = payeeTotalAmount;

var results =
compensation.financials?.filter(el => {
return el.isGstRequired === true;
Expand All @@ -111,6 +92,18 @@ export const CompensationRequisitionDetailView: React.FunctionComponent<

const payeeDetails = getPayeeDetails(compensationPayee);

const compPretaxAmount = compensation?.financials
.map(f => f.pretaxAmount ?? 0)
.reduce((prev, next) => prev + next, 0);

const compTaxAmount = compensation?.financials
.map(f => f.taxAmount ?? 0)
.reduce((prev, next) => prev + next, 0);

const compTotalAmount = compensation?.financials
.map(f => f.totalAmount ?? 0)
.reduce((prev, next) => prev + next, 0);

const userCanEditCompensationReq = (): boolean => {
if (compensation.isDraft && hasClaim(Claims.COMPENSATION_REQUISITION_EDIT)) {
return true;
Expand All @@ -131,6 +124,7 @@ export const CompensationRequisitionDetailView: React.FunctionComponent<
}}
/>
);

return (
<StyledSummarySection>
<LoadingBackdrop show={loading} parentScreen={true} />
Expand All @@ -155,23 +149,23 @@ export const CompensationRequisitionDetailView: React.FunctionComponent<
contentWidth="4"
valueTestId="header-pretax-amount"
>
<p className="mb-0 text-right">{formatMoney(payeeDetails?.preTaxAmount ?? 0)}</p>
<p className="mb-0 text-right">{formatMoney(compPretaxAmount ?? 0)}</p>
</HeaderField>
<HeaderField
label="Applicable GST:"
labelWidth="8"
contentWidth="4"
valueTestId="header-tax-amount"
>
<p className="mb-0 text-right">{formatMoney(payeeDetails?.taxAmount ?? 0)}</p>
<p className="mb-0 text-right">{formatMoney(compTaxAmount ?? 0)}</p>
</HeaderField>
<HeaderField
label="Total cheque amount:"
labelWidth="8"
contentWidth="4"
valueTestId="header-total-amount"
>
<p className="mb-0 text-right">{formatMoney(payeeDetails?.totalAmount ?? 0)}</p>
<p className="mb-0 text-right">{formatMoney(compTotalAmount ?? 0)}</p>
</HeaderField>
</Col>
</StyledRow>
Expand Down Expand Up @@ -218,7 +212,7 @@ export const CompensationRequisitionDetailView: React.FunctionComponent<
{acqFileProduct?.code ?? ''}
</SectionField>
<SectionField label="Business function" labelWidth="4">
{acqFileProject?.code ?? ''}
{acqFileProject?.businessFunctionCode?.code ?? ''}
</SectionField>
<SectionField label="Work activity" labelWidth="4">
{acqFileProject?.workActivityCode?.code ?? ''}
Expand Down Expand Up @@ -266,19 +260,15 @@ export const CompensationRequisitionDetailView: React.FunctionComponent<
</StyledPayeeDisplayName>
</SectionField>
<SectionField label="Amount (before tax)">
{formatMoney(payeeDetails?.preTaxAmount ?? 0)}
{formatMoney(compPretaxAmount ?? 0)}
</SectionField>
<SectionField label="GST applicable?">
{payeeDetails?.isGstApplicable ? 'Yes' : 'No'}
</SectionField>
{payeeDetails?.isGstApplicable && (
<SectionField label="GST amount">
{formatMoney(payeeDetails?.taxAmount ?? 0)}
</SectionField>
<SectionField label="GST amount">{formatMoney(compTaxAmount ?? 0)}</SectionField>
)}
<SectionField label="Total amount">
{formatMoney(payeeDetails?.totalAmount ?? 0)}
</SectionField>
<SectionField label="Total amount">{formatMoney(compTotalAmount ?? 0)}</SectionField>
</Section>

<Section header="Financial Activities" isCollapsable initiallyExpanded>
Expand Down Expand Up @@ -319,23 +309,23 @@ export const CompensationRequisitionDetailView: React.FunctionComponent<
<label>Compensation amount:</label>
</Col>
<Col xs="3" className="pl-1 text-right">
<span>{formatMoney(payeeDetails?.preTaxAmount ?? 0)}</span>
<span>{formatMoney(compPretaxAmount ?? 0)}</span>
</Col>
</Row>
<Row>
<Col className="pr-0 text-right">
<label>Applicable GST:</label>
</Col>
<Col xs="3" className="pl-1 text-right">
<span>{formatMoney(payeeDetails?.taxAmount ?? 0)}</span>
<span>{formatMoney(compTaxAmount ?? 0)}</span>
</Col>
</Row>
<Row>
<Col className="pr-0 text-right">
<label>Total cheque amount:</label>
</Col>
<Col xs="3" className="pl-1 text-right">
<span>{formatMoney(payeeDetails?.totalAmount ?? 0)}</span>
<span>{formatMoney(compTotalAmount ?? 0)}</span>
</Col>
</Row>
</StyledCompensationFooter>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ describe('LeaseHeader component', () => {
const { getByText, getAllByText } = setup({ lease: testLease });

expect(getByText(testLease.lFileNo!)).toBeVisible();
expect(getByText(testLease.appCreateUserid!)).toBeVisible();
expect(getByText(testLease.appLastUpdateUserid!)).toBeVisible();
expect(getAllByText(prettyFormatDate(testLease.appCreateTimestamp))[0]).toBeVisible();
expect(getAllByText(prettyFormatDate(testLease.appLastUpdateTimestamp))[0]).toBeVisible();
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ exports[`LeaseHeader component renders as expected when no data is provided 1`]
id="userNameTooltip"
>
<strong>
USER
USER_B
</strong>
</span>
</span>
Expand All @@ -332,7 +332,7 @@ exports[`LeaseHeader component renders as expected when no data is provided 1`]
id="userNameTooltip"
>
<strong>
USER
USER_A
</strong>
</span>
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { FormikProps } from 'formik';
import * as React from 'react';

import { Api_PropertyFile } from '@/models/api/PropertyFile';
import { Api_Take } from '@/models/api/Take';

import { useTakesRepository } from '../repositories/useTakesRepository';
import { TakeModel } from './models';
Expand All @@ -17,16 +18,31 @@ export interface ITakesDetailContainerProps {

export const TakesUpdateContainer = React.forwardRef<FormikProps<any>, ITakesDetailContainerProps>(
({ fileProperty, View, onSuccess }, ref) => {
const [propertyTakes, setPropertyTakes] = React.useState<Api_Take[]>([]);

if (!fileProperty?.id) {
throw Error('File property must have id');
}
const {
getTakesByFileId: { loading: takesByFileLoading, response: takes, execute: getTakesByFile },
getTakesByFileId: { loading: takesByFileLoading, execute: getTakesByFile },
updateTakesByAcquisitionPropertyId: { execute: updateTakesByPropertyFile },
} = useTakesRepository();

React.useEffect(() => {
fileProperty.fileId && getTakesByFile(fileProperty.fileId);
const fetchTakes = async () => {
if (fileProperty.fileId) {
const fileTakes = await getTakesByFile(fileProperty.fileId);
if (fileTakes !== undefined) {
const propertyTakesRetrieved = fileTakes.filter(
x => x.propertyAcquisitionFileId === fileProperty.id,
);
setPropertyTakes(propertyTakesRetrieved);
} else {
setPropertyTakes([]);
}
}
};
fetchTakes();
}, [getTakesByFile, fileProperty]);

return (
Expand All @@ -46,7 +62,11 @@ export const TakesUpdateContainer = React.forwardRef<FormikProps<any>, ITakesDet
}
}}
loading={takesByFileLoading}
takes={takes?.length ? takes?.map(t => new TakeModel(t)) : [new TakeModel(emptyTake)]}
takes={
propertyTakes?.length
? propertyTakes?.map(t => new TakeModel(t))
: [new TakeModel(emptyTake)]
}
fileProperty={fileProperty}
ref={ref}
/>
Expand Down
Loading

0 comments on commit 7a98af8

Please sign in to comment.