From 7c494f51aacb1efd439703aa1a40df2b304bdb77 Mon Sep 17 00:00:00 2001 From: devinleighsmith Date: Tue, 19 Mar 2024 19:44:18 -0700 Subject: [PATCH 1/7] psp-7884 add take completion date. --- .../backend/api/Constants/TakeStatusTypes.cs | 18 ++ source/backend/api/Services/TakeService.cs | 4 + .../Models/Concepts/Take/TakeModel.cs | 2 + .../components/common/form/FastDatePicker.tsx | 4 + .../tabs/takes/update/TakeSubForm.tsx | 21 ++ .../tabs/takes/update/TakesUpdateForm.tsx | 1 + .../TakesUpdateForm.test.tsx.snap | 228 ++++++++++++------ .../property/tabs/takes/update/models.ts | 8 + source/frontend/src/mocks/takes.mock.ts | 1 + .../api/generated/ApiGen_Concepts_Take.ts | 1 + 10 files changed, 210 insertions(+), 78 deletions(-) create mode 100644 source/backend/api/Constants/TakeStatusTypes.cs diff --git a/source/backend/api/Constants/TakeStatusTypes.cs b/source/backend/api/Constants/TakeStatusTypes.cs new file mode 100644 index 0000000000..34c0126b33 --- /dev/null +++ b/source/backend/api/Constants/TakeStatusTypes.cs @@ -0,0 +1,18 @@ +using System.Runtime.Serialization; +using System.Text.Json.Serialization; + +namespace Pims.Api.Constants +{ + [JsonConverter(typeof(JsonStringEnumMemberConverter))] + public enum TakeStatusTypes + { + [EnumMember(Value = "INPROGRESS")] + INPROGRESS, + + [EnumMember(Value = "CANCELLED")] + CANCELLED, + + [EnumMember(Value = "COMPLETE")] + COMPLETE, + } +} diff --git a/source/backend/api/Services/TakeService.cs b/source/backend/api/Services/TakeService.cs index def6c80ef2..bbb176aa19 100644 --- a/source/backend/api/Services/TakeService.cs +++ b/source/backend/api/Services/TakeService.cs @@ -91,6 +91,10 @@ public IEnumerable UpdateAcquisitionPropertyTakes(long acquisitionFile } } } + else if (takes.Any(t => t.TakeStatusTypeCode == TakeStatusTypes.COMPLETE.ToString())) + { + throw new BusinessRuleViolationException("A completed take must have a completion date."); + } _takeRepository.UpdateAcquisitionPropertyTakes(acquisitionFilePropertyId, takes); _takeRepository.CommitTransaction(); diff --git a/source/backend/apimodels/Models/Concepts/Take/TakeModel.cs b/source/backend/apimodels/Models/Concepts/Take/TakeModel.cs index 5922f6ca62..b8acc48fae 100644 --- a/source/backend/apimodels/Models/Concepts/Take/TakeModel.cs +++ b/source/backend/apimodels/Models/Concepts/Take/TakeModel.cs @@ -39,6 +39,8 @@ public class TakeModel : BaseAuditModel public DateOnly? LandActEndDt { get; set; } + public DateOnly? CompletionDt { get; set; } + public AcquisitionFileModel PropertyAcquisitionFile { get; set; } public long PropertyAcquisitionFileId { get; set; } diff --git a/source/frontend/src/components/common/form/FastDatePicker.tsx b/source/frontend/src/components/common/form/FastDatePicker.tsx index a4d2774dac..78f0a87412 100644 --- a/source/frontend/src/components/common/form/FastDatePicker.tsx +++ b/source/frontend/src/components/common/form/FastDatePicker.tsx @@ -25,6 +25,8 @@ type OptionalAttributes = { innerClassName?: string; /** The minimum data allowable to be chosen in the datepicker */ minDate?: Date; + /** The maximum date allowable to be chosen in the datepicker */ + maxDate?: Date; /** form label */ label?: string; /** Whether the field is required. Makes the field border blue. */ @@ -48,6 +50,7 @@ const FormikDatePicker: FunctionComponent { diff --git a/source/frontend/src/features/mapSideBar/property/tabs/takes/update/TakeSubForm.tsx b/source/frontend/src/features/mapSideBar/property/tabs/takes/update/TakeSubForm.tsx index 1333696c52..35038d7a70 100644 --- a/source/frontend/src/features/mapSideBar/property/tabs/takes/update/TakeSubForm.tsx +++ b/source/frontend/src/features/mapSideBar/property/tabs/takes/update/TakeSubForm.tsx @@ -11,6 +11,7 @@ import AreaContainer from '@/components/measurements/AreaContainer'; import { Roles } from '@/constants'; import * as API from '@/constants/API'; import useKeycloakWrapper from '@/hooks/useKeycloakWrapper'; +import { TakesStatusTypes } from '@/constants/takesStatusTypes'; import useLookupCodeHelpers from '@/hooks/useLookupCodeHelpers'; import { getDeleteModalProps, useModalContext } from '@/hooks/useModalContext'; import { ApiGen_CodeTypes_AcquisitionTakeStatusTypes } from '@/models/api/generated/ApiGen_CodeTypes_AcquisitionTakeStatusTypes'; @@ -54,6 +55,12 @@ const TakeSubForm: React.FunctionComponent = ({ ); const takeStatusTypeCode = getIn(values, withNameSpace(nameSpace, 'takeStatusTypeCode')); + React.useEffect(() => { + if (currentTake.completionDt && currentTake.takeStatusTypeCode !== TakesStatusTypes.COMPLETE) { + setFieldValue(withNameSpace(nameSpace, 'completionDt'), ''); + } + }, [currentTake.completionDt, currentTake.takeStatusTypeCode, nameSpace, setFieldValue]); + const getModalWarning = (onOk: () => void) => { return (e: React.ChangeEvent) => { if (e.target.value === 'false') { @@ -121,6 +128,20 @@ const TakeSubForm: React.FunctionComponent = ({ disabled={!canEditTake} /> + + + + + + + +
@@ -601,7 +673,7 @@ exports[`TakesUpdateForm component renders as expected 1`] = `

isNewLandAct, then: Yup.string().required('Land Act is required'), }), + completionDt: Yup.string().when('takeStatusTypeCode', { + is: (takeStatusTypeCode: string) => takeStatusTypeCode === TakesStatusTypes.COMPLETE, + then: Yup.string().nullable().required('A completed take must have a completion date.'), + }), }), ), }); export class TakeModel { id?: number; + completionDt: string | null; description: string; isThereSurplus: 'false' | 'true'; isNewHighwayDedication: 'false' | 'true'; @@ -103,6 +109,7 @@ export class TakeModel { this.newHighwayDedicationArea = base.newHighwayDedicationArea ?? 0; this.newHighwayDedicationAreaUnitTypeCode = fromTypeCodeNullable(base.areaUnitTypeCode) ?? AreaUnitTypes.SquareMeters.toString(); + this.completionDt = base.completionDt; this.appCreateTimestamp = base.appCreateTimestamp ?? null; } @@ -157,6 +164,7 @@ export class TakeModel { isNewLicenseToConstruct: this.isNewLicenseToConstruct === 'true', isNewInterestInSrw: this.isNewInterestInSrw === 'true', ...getEmptyBaseAudit(this.rowVersion), + completionDt: stringToNull(this.completionDt), }; } } diff --git a/source/frontend/src/mocks/takes.mock.ts b/source/frontend/src/mocks/takes.mock.ts index 12ee36bb7f..64ed9cdbc8 100644 --- a/source/frontend/src/mocks/takes.mock.ts +++ b/source/frontend/src/mocks/takes.mock.ts @@ -37,6 +37,7 @@ export const getMockApiTakes = (): ApiGen_Concepts_Take[] => [ displayOrder: null, isDisabled: false, }, + completionDt: '', rowVersion: 2, }, ]; diff --git a/source/frontend/src/models/api/generated/ApiGen_Concepts_Take.ts b/source/frontend/src/models/api/generated/ApiGen_Concepts_Take.ts index 7d75db225b..aad66215c1 100644 --- a/source/frontend/src/models/api/generated/ApiGen_Concepts_Take.ts +++ b/source/frontend/src/models/api/generated/ApiGen_Concepts_Take.ts @@ -22,6 +22,7 @@ export interface ApiGen_Concepts_Take extends ApiGen_Base_BaseAudit { ltcEndDt: string | null; landActArea: number | null; landActEndDt: string | null; + completionDt: string | null; propertyAcquisitionFile: ApiGen_Concepts_AcquisitionFile | null; propertyAcquisitionFileId: number; statutoryRightOfWayArea: number | null; From 8fb5d163f1cb9513b222bab6b53a38afa078f840 Mon Sep 17 00:00:00 2001 From: devinleighsmith Date: Tue, 19 Mar 2024 20:39:35 -0700 Subject: [PATCH 2/7] add take read-only completion date. --- .../property/tabs/takes/detail/TakesDetailView.tsx | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/source/frontend/src/features/mapSideBar/property/tabs/takes/detail/TakesDetailView.tsx b/source/frontend/src/features/mapSideBar/property/tabs/takes/detail/TakesDetailView.tsx index 5ccdab3b13..17c25f67a7 100644 --- a/source/frontend/src/features/mapSideBar/property/tabs/takes/detail/TakesDetailView.tsx +++ b/source/frontend/src/features/mapSideBar/property/tabs/takes/detail/TakesDetailView.tsx @@ -114,6 +114,11 @@ export const TakesDetailView: React.FunctionComponent = ( ? getCodeById(API.TAKE_STATUS_TYPES, take.takeStatusTypeCode.id) : ''} + {take.completionDt && ( + + {prettyFormatDate(take.completionDt)} + + )} {take.takeSiteContamTypeCode?.id ? getCodeById(API.TAKE_SITE_CONTAM_TYPES, take.takeSiteContamTypeCode.id) From f132ddb7808935970910b959f029d92074c6b8d2 Mon Sep 17 00:00:00 2001 From: devinleighsmith Date: Thu, 4 Apr 2024 15:59:40 -0700 Subject: [PATCH 3/7] corrections. --- source/backend/api/Services/TakeService.cs | 2 +- .../backend/apimodels/Models/Concepts/Take/TakeMap.cs | 2 ++ .../tabs/takes/repositories/useTakesRepository.tsx | 1 + .../tabs/takes/update/TakesUpdateContainer.tsx | 6 ++++-- .../mapSideBar/property/tabs/takes/update/models.ts | 10 ++++++---- 5 files changed, 14 insertions(+), 7 deletions(-) diff --git a/source/backend/api/Services/TakeService.cs b/source/backend/api/Services/TakeService.cs index bbb176aa19..b8c3069b66 100644 --- a/source/backend/api/Services/TakeService.cs +++ b/source/backend/api/Services/TakeService.cs @@ -91,7 +91,7 @@ public IEnumerable UpdateAcquisitionPropertyTakes(long acquisitionFile } } } - else if (takes.Any(t => t.TakeStatusTypeCode == TakeStatusTypes.COMPLETE.ToString())) + else if (takes.Any(t => t.TakeStatusTypeCode == TakeStatusTypes.COMPLETE.ToString() && t.CompletionDt == null)) { throw new BusinessRuleViolationException("A completed take must have a completion date."); } diff --git a/source/backend/apimodels/Models/Concepts/Take/TakeMap.cs b/source/backend/apimodels/Models/Concepts/Take/TakeMap.cs index 92feeb3f5e..de195e4ba0 100644 --- a/source/backend/apimodels/Models/Concepts/Take/TakeMap.cs +++ b/source/backend/apimodels/Models/Concepts/Take/TakeMap.cs @@ -32,6 +32,7 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.TakeTypeCode, src => src.TakeTypeCodeNavigation) .Map(dest => dest.TakeStatusTypeCode, src => src.TakeStatusTypeCodeNavigation) .Map(dest => dest.LandActTypeCode, src => src.LandActTypeCodeNavigation) + .Map(dest => dest.CompletionDt, src => src.CompletionDt) .Inherits(); config.NewConfig() @@ -58,6 +59,7 @@ public void Register(TypeAdapterConfig config) .Map(dest => dest.TakeTypeCode, src => src.TakeTypeCode.Id) .Map(dest => dest.TakeStatusTypeCode, src => src.TakeStatusTypeCode.Id) .Map(dest => dest.LandActTypeCode, src => src.LandActTypeCode.Id) + .Map(dest => dest.CompletionDt, src => src.CompletionDt) .Inherits(); } } diff --git a/source/frontend/src/features/mapSideBar/property/tabs/takes/repositories/useTakesRepository.tsx b/source/frontend/src/features/mapSideBar/property/tabs/takes/repositories/useTakesRepository.tsx index ba34ab026e..b953412338 100644 --- a/source/frontend/src/features/mapSideBar/property/tabs/takes/repositories/useTakesRepository.tsx +++ b/source/frontend/src/features/mapSideBar/property/tabs/takes/repositories/useTakesRepository.tsx @@ -67,6 +67,7 @@ export const useTakesRepository = () => { requestName: 'UpdateTakesByAcquisitionPropertyId', onSuccess: useAxiosSuccessHandler(), onError: useAxiosErrorHandler(), + throwError: true, }); return useMemo( diff --git a/source/frontend/src/features/mapSideBar/property/tabs/takes/update/TakesUpdateContainer.tsx b/source/frontend/src/features/mapSideBar/property/tabs/takes/update/TakesUpdateContainer.tsx index 3ab5c17446..0e11392b61 100644 --- a/source/frontend/src/features/mapSideBar/property/tabs/takes/update/TakesUpdateContainer.tsx +++ b/source/frontend/src/features/mapSideBar/property/tabs/takes/update/TakesUpdateContainer.tsx @@ -56,8 +56,10 @@ export const TakesUpdateContainer = React.forwardRef, ITakesDet t.propertyAcquisitionFileId = fileProperty.id ?? 0; return t.toApi(); }); - fileProperty.id && (await updateTakesByPropertyFile(fileProperty.id, takes)); - onSuccess(); + if (fileProperty.id) { + await updateTakesByPropertyFile(fileProperty.id, takes); + onSuccess(); + } } finally { formikHelpers.setSubmitting(false); } diff --git a/source/frontend/src/features/mapSideBar/property/tabs/takes/update/models.ts b/source/frontend/src/features/mapSideBar/property/tabs/takes/update/models.ts index a28865353c..1ef485595d 100644 --- a/source/frontend/src/features/mapSideBar/property/tabs/takes/update/models.ts +++ b/source/frontend/src/features/mapSideBar/property/tabs/takes/update/models.ts @@ -32,10 +32,12 @@ export const TakesYupSchema = Yup.object().shape({ is: (isNewLandAct: boolean) => isNewLandAct, then: Yup.string().required('Land Act is required'), }), - completionDt: Yup.string().when('takeStatusTypeCode', { - is: (takeStatusTypeCode: string) => takeStatusTypeCode === TakesStatusTypes.COMPLETE, - then: Yup.string().nullable().required('A completed take must have a completion date.'), - }), + completionDt: Yup.string() + .nullable() + .when('takeStatusTypeCode', { + is: (takeStatusTypeCode: string) => takeStatusTypeCode === TakesStatusTypes.COMPLETE, + then: Yup.string().nullable().required('A completed take must have a completion date.'), + }), }), ), }); From 0002578769ed28c18aea3d59ccd0ddb9e441eb14 Mon Sep 17 00:00:00 2001 From: devinleighsmith Date: Thu, 4 Apr 2024 16:07:43 -0700 Subject: [PATCH 4/7] sort imports. --- .../mapSideBar/property/tabs/takes/update/TakeSubForm.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/frontend/src/features/mapSideBar/property/tabs/takes/update/TakeSubForm.tsx b/source/frontend/src/features/mapSideBar/property/tabs/takes/update/TakeSubForm.tsx index 35038d7a70..794d880eff 100644 --- a/source/frontend/src/features/mapSideBar/property/tabs/takes/update/TakeSubForm.tsx +++ b/source/frontend/src/features/mapSideBar/property/tabs/takes/update/TakeSubForm.tsx @@ -10,8 +10,8 @@ import { SectionField } from '@/components/common/Section/SectionField'; import AreaContainer from '@/components/measurements/AreaContainer'; import { Roles } from '@/constants'; import * as API from '@/constants/API'; -import useKeycloakWrapper from '@/hooks/useKeycloakWrapper'; import { TakesStatusTypes } from '@/constants/takesStatusTypes'; +import useKeycloakWrapper from '@/hooks/useKeycloakWrapper'; import useLookupCodeHelpers from '@/hooks/useLookupCodeHelpers'; import { getDeleteModalProps, useModalContext } from '@/hooks/useModalContext'; import { ApiGen_CodeTypes_AcquisitionTakeStatusTypes } from '@/models/api/generated/ApiGen_CodeTypes_AcquisitionTakeStatusTypes'; From a6c5389fb7c599dac35bc43b9784cf0edb4cf7f6 Mon Sep 17 00:00:00 2001 From: devinleighsmith Date: Thu, 4 Apr 2024 16:14:51 -0700 Subject: [PATCH 5/7] make correction. --- source/backend/api/Services/TakeService.cs | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/backend/api/Services/TakeService.cs b/source/backend/api/Services/TakeService.cs index b8c3069b66..ae7f5ba9ea 100644 --- a/source/backend/api/Services/TakeService.cs +++ b/source/backend/api/Services/TakeService.cs @@ -3,6 +3,7 @@ using System.Linq; using System.Security.Claims; using Microsoft.Extensions.Logging; +using Pims.Api.Constants; using Pims.Api.Models.CodeTypes; using Pims.Core.Exceptions; using Pims.Dal.Entities; @@ -70,6 +71,10 @@ public IEnumerable UpdateAcquisitionPropertyTakes(long acquisitionFile { throw new BusinessRuleViolationException("Retired records are referenced for historical purposes only and cannot be edited or deleted. If the take has been added in error, contact your system administrator to re-open the file, which will allow take deletion."); } + else if (takes.Any(t => t.TakeStatusTypeCode == TakeStatusTypes.COMPLETE.ToString() && t.CompletionDt == null)) + { + throw new BusinessRuleViolationException("A completed take must have a completion date."); + } else { // Complete Takes can only be deleted or set to InProgress by Admins when File is Active/Draft @@ -91,10 +96,6 @@ public IEnumerable UpdateAcquisitionPropertyTakes(long acquisitionFile } } } - else if (takes.Any(t => t.TakeStatusTypeCode == TakeStatusTypes.COMPLETE.ToString() && t.CompletionDt == null)) - { - throw new BusinessRuleViolationException("A completed take must have a completion date."); - } _takeRepository.UpdateAcquisitionPropertyTakes(acquisitionFilePropertyId, takes); _takeRepository.CommitTransaction(); From b3ca697ae2eea48a7eb8894c9fc96ec8fd3716ac Mon Sep 17 00:00:00 2001 From: devinleighsmith Date: Mon, 8 Apr 2024 08:40:01 -0700 Subject: [PATCH 6/7] code review comments. --- .../backend/api/Constants/TakeStatusTypes.cs | 18 ------------------ source/backend/api/Services/TakeService.cs | 2 +- .../frontend/src/constants/takesStatusTypes.ts | 5 ----- .../property/tabs/takes/update/TakeSubForm.tsx | 14 ++++++++++---- 4 files changed, 11 insertions(+), 28 deletions(-) delete mode 100644 source/backend/api/Constants/TakeStatusTypes.cs delete mode 100644 source/frontend/src/constants/takesStatusTypes.ts diff --git a/source/backend/api/Constants/TakeStatusTypes.cs b/source/backend/api/Constants/TakeStatusTypes.cs deleted file mode 100644 index 34c0126b33..0000000000 --- a/source/backend/api/Constants/TakeStatusTypes.cs +++ /dev/null @@ -1,18 +0,0 @@ -using System.Runtime.Serialization; -using System.Text.Json.Serialization; - -namespace Pims.Api.Constants -{ - [JsonConverter(typeof(JsonStringEnumMemberConverter))] - public enum TakeStatusTypes - { - [EnumMember(Value = "INPROGRESS")] - INPROGRESS, - - [EnumMember(Value = "CANCELLED")] - CANCELLED, - - [EnumMember(Value = "COMPLETE")] - COMPLETE, - } -} diff --git a/source/backend/api/Services/TakeService.cs b/source/backend/api/Services/TakeService.cs index ae7f5ba9ea..025be59341 100644 --- a/source/backend/api/Services/TakeService.cs +++ b/source/backend/api/Services/TakeService.cs @@ -71,7 +71,7 @@ public IEnumerable UpdateAcquisitionPropertyTakes(long acquisitionFile { throw new BusinessRuleViolationException("Retired records are referenced for historical purposes only and cannot be edited or deleted. If the take has been added in error, contact your system administrator to re-open the file, which will allow take deletion."); } - else if (takes.Any(t => t.TakeStatusTypeCode == TakeStatusTypes.COMPLETE.ToString() && t.CompletionDt == null)) + else if (takes.Any(t => t.TakeStatusTypeCode == AcquisitionTakeStatusTypes.COMPLETE.ToString() && t.CompletionDt == null)) { throw new BusinessRuleViolationException("A completed take must have a completion date."); } diff --git a/source/frontend/src/constants/takesStatusTypes.ts b/source/frontend/src/constants/takesStatusTypes.ts deleted file mode 100644 index c7817499be..0000000000 --- a/source/frontend/src/constants/takesStatusTypes.ts +++ /dev/null @@ -1,5 +0,0 @@ -export enum TakesStatusTypes { - CANCELLED = 'CANCELLED', - COMPLETE = 'COMPLETE', - INPROGRESS = 'INPROGRESS', -} diff --git a/source/frontend/src/features/mapSideBar/property/tabs/takes/update/TakeSubForm.tsx b/source/frontend/src/features/mapSideBar/property/tabs/takes/update/TakeSubForm.tsx index 794d880eff..c1a8d0bf6c 100644 --- a/source/frontend/src/features/mapSideBar/property/tabs/takes/update/TakeSubForm.tsx +++ b/source/frontend/src/features/mapSideBar/property/tabs/takes/update/TakeSubForm.tsx @@ -10,7 +10,6 @@ import { SectionField } from '@/components/common/Section/SectionField'; import AreaContainer from '@/components/measurements/AreaContainer'; import { Roles } from '@/constants'; import * as API from '@/constants/API'; -import { TakesStatusTypes } from '@/constants/takesStatusTypes'; import useKeycloakWrapper from '@/hooks/useKeycloakWrapper'; import useLookupCodeHelpers from '@/hooks/useLookupCodeHelpers'; import { getDeleteModalProps, useModalContext } from '@/hooks/useModalContext'; @@ -56,7 +55,10 @@ const TakeSubForm: React.FunctionComponent = ({ const takeStatusTypeCode = getIn(values, withNameSpace(nameSpace, 'takeStatusTypeCode')); React.useEffect(() => { - if (currentTake.completionDt && currentTake.takeStatusTypeCode !== TakesStatusTypes.COMPLETE) { + if ( + currentTake.completionDt && + currentTake.takeStatusTypeCode !== ApiGen_CodeTypes_AcquisitionTakeStatusTypes.COMPLETE + ) { setFieldValue(withNameSpace(nameSpace, 'completionDt'), ''); } }, [currentTake.completionDt, currentTake.takeStatusTypeCode, nameSpace, setFieldValue]); @@ -130,7 +132,9 @@ const TakeSubForm: React.FunctionComponent = ({ = ({ formikProps={formikProps} field={withNameSpace(nameSpace, 'completionDt')} maxDate={new Date()} - disabled={currentTake.takeStatusTypeCode !== TakesStatusTypes.COMPLETE} + disabled={ + currentTake.takeStatusTypeCode !== ApiGen_CodeTypes_AcquisitionTakeStatusTypes.COMPLETE + } /> From 16c498b32abde3f9fec09c6f3a03ae9a985588d1 Mon Sep 17 00:00:00 2001 From: devinleighsmith Date: Mon, 8 Apr 2024 08:56:10 -0700 Subject: [PATCH 7/7] corrections. --- .../property/tabs/takes/detail/TakesDetailView.tsx | 6 +++--- .../mapSideBar/property/tabs/takes/update/models.ts | 6 ++++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/source/frontend/src/features/mapSideBar/property/tabs/takes/detail/TakesDetailView.tsx b/source/frontend/src/features/mapSideBar/property/tabs/takes/detail/TakesDetailView.tsx index 17c25f67a7..d0628df85d 100644 --- a/source/frontend/src/features/mapSideBar/property/tabs/takes/detail/TakesDetailView.tsx +++ b/source/frontend/src/features/mapSideBar/property/tabs/takes/detail/TakesDetailView.tsx @@ -12,11 +12,11 @@ import TooltipIcon from '@/components/common/TooltipIcon'; import AreaContainer from '@/components/measurements/AreaContainer'; import * as API from '@/constants/API'; import { Claims } from '@/constants/claims'; -import { TakesStatusTypes } from '@/constants/takesStatusTypes'; import { isAcquisitionFile } from '@/features/mapSideBar/acquisition/add/models'; import StatusUpdateSolver from '@/features/mapSideBar/acquisition/tabs/fileDetails/detail/statusUpdateSolver'; import useKeycloakWrapper from '@/hooks/useKeycloakWrapper'; import useLookupCodeHelpers from '@/hooks/useLookupCodeHelpers'; +import { ApiGen_CodeTypes_AcquisitionTakeStatusTypes } from '@/models/api/generated/ApiGen_CodeTypes_AcquisitionTakeStatusTypes'; import { ApiGen_Concepts_FileProperty } from '@/models/api/generated/ApiGen_Concepts_FileProperty'; import { ApiGen_Concepts_Take } from '@/models/api/generated/ApiGen_Concepts_Take'; import { getApiPropertyName, prettyFormatDate, prettyFormatUTCDate } from '@/utils'; @@ -39,10 +39,10 @@ export const TakesDetailView: React.FunctionComponent = ( onEdit, }) => { const cancelledTakes = takes?.filter( - t => t.takeStatusTypeCode?.id === TakesStatusTypes.CANCELLED, + t => t.takeStatusTypeCode?.id === ApiGen_CodeTypes_AcquisitionTakeStatusTypes.CANCELLED, ); const nonCancelledTakes = takes?.filter( - t => t.takeStatusTypeCode?.id !== TakesStatusTypes.CANCELLED, + t => t.takeStatusTypeCode?.id !== ApiGen_CodeTypes_AcquisitionTakeStatusTypes.CANCELLED, ); const takesNotInFile = allTakesCount - (takes?.length ?? 0); diff --git a/source/frontend/src/features/mapSideBar/property/tabs/takes/update/models.ts b/source/frontend/src/features/mapSideBar/property/tabs/takes/update/models.ts index 1ef485595d..2dff3cf630 100644 --- a/source/frontend/src/features/mapSideBar/property/tabs/takes/update/models.ts +++ b/source/frontend/src/features/mapSideBar/property/tabs/takes/update/models.ts @@ -1,13 +1,14 @@ import * as Yup from 'yup'; import { AreaUnitTypes } from '@/constants/areaUnitTypes'; -import { TakesStatusTypes } from '@/constants/takesStatusTypes'; import { ApiGen_Concepts_Take } from '@/models/api/generated/ApiGen_Concepts_Take'; import { UtcIsoDateTime } from '@/models/api/UtcIsoDateTime'; import { getEmptyBaseAudit } from '@/models/defaultInitializers'; import { convertArea } from '@/utils/convertUtils'; import { fromTypeCodeNullable, stringToNull, toTypeCodeNullable } from '@/utils/formUtils'; +import { ApiGen_CodeTypes_AcquisitionTakeStatusTypes } from './../../../../../../models/api/generated/ApiGen_CodeTypes_AcquisitionTakeStatusTypes'; + /* eslint-disable no-template-curly-in-string */ export const TakesYupSchema = Yup.object().shape({ takes: Yup.array().of( @@ -35,7 +36,8 @@ export const TakesYupSchema = Yup.object().shape({ completionDt: Yup.string() .nullable() .when('takeStatusTypeCode', { - is: (takeStatusTypeCode: string) => takeStatusTypeCode === TakesStatusTypes.COMPLETE, + is: (takeStatusTypeCode: string) => + takeStatusTypeCode === ApiGen_CodeTypes_AcquisitionTakeStatusTypes.COMPLETE, then: Yup.string().nullable().required('A completed take must have a completion date.'), }), }),