From 9b3e9d5dd0232c43dc2edadbd2e7f0554388072e Mon Sep 17 00:00:00 2001 From: Dima K Date: Wed, 21 Feb 2024 18:45:17 -0800 Subject: [PATCH] Fix to preserve data for Transport Permit. Payload cleanup. (#1744) * Fix to preserve data for Transport Permit * Cleanup payload for Transport Permit. Fix Pad preservation. --- ppr-ui/package-lock.json | 4 ++-- ppr-ui/package.json | 2 +- .../mhrRegistration/ReviewConfirm/HomeLocationReview.vue | 8 +++++++- .../src/composables/mhrInformation/useTransportPermits.ts | 2 -- ppr-ui/src/utils/mhr-api-helper.ts | 3 ++- 5 files changed, 12 insertions(+), 7 deletions(-) diff --git a/ppr-ui/package-lock.json b/ppr-ui/package-lock.json index b6ec4381e..51e740844 100644 --- a/ppr-ui/package-lock.json +++ b/ppr-ui/package-lock.json @@ -1,12 +1,12 @@ { "name": "ppr-ui", - "version": "3.0.46", + "version": "3.0.47", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "ppr-ui", - "version": "3.0.46", + "version": "3.0.47", "dependencies": { "@bcrs-shared-components/input-field-date-picker": "^1.0.0", "@lemoncode/fonk": "^1.5.1", diff --git a/ppr-ui/package.json b/ppr-ui/package.json index 3d6297615..df91f682c 100644 --- a/ppr-ui/package.json +++ b/ppr-ui/package.json @@ -1,6 +1,6 @@ { "name": "ppr-ui", - "version": "3.0.46", + "version": "3.0.47", "private": true, "appName": "Assets UI", "sbcName": "SBC Common Components", diff --git a/ppr-ui/src/components/mhrRegistration/ReviewConfirm/HomeLocationReview.vue b/ppr-ui/src/components/mhrRegistration/ReviewConfirm/HomeLocationReview.vue index 463b4c6f9..8878530a0 100644 --- a/ppr-ui/src/components/mhrRegistration/ReviewConfirm/HomeLocationReview.vue +++ b/ppr-ui/src/components/mhrRegistration/ReviewConfirm/HomeLocationReview.vue @@ -504,7 +504,7 @@ export default defineComponent({ const localState = reactive({ // transport permit currentPadNumber: homeLocationInfo.pad, - newTransportPermitPadNumber: homeLocationInfo.pad, + newTransportPermitPadNumber: '', showTaxCertificateExpiryDate: homeLocationInfo.taxCertificate && isNotManufacturersLot.value && !isMovingWithinSamePark.value, @@ -583,6 +583,12 @@ export default defineComponent({ newPadNumberRef.value?.validate() }) + // is editing Pad number - get the value from either Permit or Registration + watch(() => props.isPadEditable, async () => { + localState.newTransportPermitPadNumber = + getMhrTransportPermit.value.newLocation.pad || structuredClone(homeLocationInfo.pad) + }, { immediate: true }) + return { homeLocationInfo, newPadNumberRef, diff --git a/ppr-ui/src/composables/mhrInformation/useTransportPermits.ts b/ppr-ui/src/composables/mhrInformation/useTransportPermits.ts index eb899ee67..0bdb8963e 100644 --- a/ppr-ui/src/composables/mhrInformation/useTransportPermits.ts +++ b/ppr-ui/src/composables/mhrInformation/useTransportPermits.ts @@ -147,8 +147,6 @@ export const useTransportPermits = () => { .toISOString() .replace('.000Z', '+00:00') } - // set empty postal code because it is not captured in the form - payloadData.newLocation.address.postalCode = ' ' } // api does not support otherType, and it should be set to the locationType diff --git a/ppr-ui/src/utils/mhr-api-helper.ts b/ppr-ui/src/utils/mhr-api-helper.ts index d121d65cd..d53c49556 100644 --- a/ppr-ui/src/utils/mhr-api-helper.ts +++ b/ppr-ui/src/utils/mhr-api-helper.ts @@ -20,6 +20,7 @@ import { APIMhrTypes, ErrorCategories, ErrorCodes, ErrorRootCauses, StaffPayment import { useSearch } from '@/composables/useSearch' import { SessionStorageKeys } from 'sbc-common-components/src/util/constants' import { addTimestampToDate } from '@/utils' +import { trim } from 'lodash' // eslint-disable-next-line @typescript-eslint/no-unused-vars import type { AxiosError } from 'axios' @@ -716,7 +717,7 @@ export function deleteEmptyProperties (obj) { if (Object.keys(obj[key] || {}).length === 0) { delete obj[key] // delete empty nested object } - } else if (obj[key] === null || obj[key] === undefined || obj[key] === '') { + } else if (obj[key] === null || obj[key] === undefined || trim(obj[key]) === '') { delete obj[key] // delete empty property value } }