Skip to content

Commit

Permalink
Updates for Draft SoG/SJT Transfers (#1277)
Browse files Browse the repository at this point in the history
* Updates for Draft SoG/SJT Transfers

* import clean up

* Removed eslint override
  • Loading branch information
cameron-eyds authored Apr 17, 2023
1 parent ded9ecc commit f664f75
Show file tree
Hide file tree
Showing 8 changed files with 55 additions and 46 deletions.
4 changes: 2 additions & 2 deletions ppr-ui/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion ppr-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "ppr-ui",
"version": "1.0.7",
"version": "1.0.8",
"private": true,
"appName": "Assets UI",
"sbcName": "SBC Common Components",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -667,7 +667,7 @@ export default defineComponent({
(isTransferToSurvivingJointTenant.value ? localState.isValidDeathCertificate : true) &&
(isTransferToExecutorProbateWill.value ? TransWill.isValidTransfer.value : true)
)
}, { deep: true })
}, { immediate: true, deep: true })
watch(
() => enableTransferOwnerGroupActions(),
Expand Down
2 changes: 1 addition & 1 deletion ppr-ui/src/components/tables/common/TableRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -595,7 +595,7 @@ export default defineComponent({
const openMhr = (item: MhRegistrationSummaryIF): void => {
emit('action', {
action: item.registrationType === APIMhrTypes.MANUFACTURED_HOME_REGISTRATION
action: (item.registrationType === APIMhrTypes.MANUFACTURED_HOME_REGISTRATION && item.draftNumber)
? TableActions.EDIT_NEW_MHR
: TableActions.OPEN_MHR,
mhrInfo: item
Expand Down
39 changes: 23 additions & 16 deletions ppr-ui/src/composables/mhrInformation/useMhrInformation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {
UIRegistrationTypes,
UITransferTypes
} from '@/enums'
import { fetchMhRegistration, getMhrDraft, normalizeObject } from '@/utils'
import { fetchMhRegistration, normalizeObject } from '@/utils'
import { cloneDeep } from 'lodash'
import { useHomeOwners, useTransferOwners } from '@/composables'

Expand Down Expand Up @@ -53,6 +53,7 @@ export const useMhrInformation = () => {
setIsManualLocation,
setMhrHomeDescription,
setMhrTransferDeclaredValue,
setMhrTransferType,
setMhrTransferDate,
setMhrTransferOwnLand,
setMhrTransferConsideration,
Expand All @@ -63,8 +64,10 @@ export const useMhrInformation = () => {
'setMhrLocation',
'setIsManualLocation',
'setMhrHomeDescription',
'setMhrTransferType',
'setMhrTransferDate',
'setMhrTransferOwnLand',
'setMhrTransferDeclaredValue',
'setMhrTransferConsideration',
'setMhrTransferSubmittingParty'
])
Expand Down Expand Up @@ -131,20 +134,7 @@ export const useMhrInformation = () => {
currentOwnerGroups.forEach((ownerGroup, index) => { ownerGroup.groupId = index + 1 })
setShowGroups(currentOwnerGroups.length > 1)

// Set owners to store
if (getMhrInformation.value.draftNumber) {
// Retrieve owners from draft if it exists
const { registration } = await getMhrDraft(getMhrInformation.value.draftNumber)

// Set draft Transfer details to store
await parseDraftTransferDetails(registration as MhrTransferApiIF)

setShowGroups(registration.addOwnerGroups.length > 1 || registration.deleteOwnerGroups.length > 1)
setMhrTransferHomeOwnerGroups([...registration.addOwnerGroups])
} else {
// Set current owners if there is no draft
setMhrTransferHomeOwnerGroups(cloneDeep(currentOwnerGroups))
}
setMhrTransferHomeOwnerGroups(cloneDeep(currentOwnerGroups))
}

const parseSubmittingPartyInfo = (accountInfo: AccountInfoIF): void => {
Expand Down Expand Up @@ -182,6 +172,21 @@ export const useMhrInformation = () => {
}

/** Draft Filings **/
/**
* Parse a draft MHR Information into State.
* @param draft The draft filing to parse.
*/
const initDraftMhrInformation = async (draft: MhrTransferApiIF): Promise<void> => {
// Set draft transfer type
setMhrTransferType({ transferType: draft.registrationType })

// Set draft transfer details
parseDraftTransferDetails(draft)

// Set draft owner groups
setShowGroups(draft.addOwnerGroups.length > 1 || draft.deleteOwnerGroups.length > 1)
setMhrTransferHomeOwnerGroups([...draft.addOwnerGroups])
}

const parseDraftTransferDetails = (draft: MhrTransferApiIF): void => {
setMhrTransferDeclaredValue(draft.declaredValue || '')
Expand All @@ -207,7 +212,7 @@ export const useMhrInformation = () => {
ownerGroups.push({
...ownerGroup,
owners: isDraft ? ownerGroup.owners : addedEditedOwners,
groupId: ownerGroup.groupId + 1, // Increment from baseline groupID to create a new group for API
groupId: ownerGroup.groupId,
type: ApiHomeTenancyTypes[
Object.keys(HomeTenancyTypes).find(key => HomeTenancyTypes[key] as string === ownerGroup.type)
]
Expand Down Expand Up @@ -261,6 +266,7 @@ export const useMhrInformation = () => {

const buildApiData = async (isDraft: boolean = false): Promise<MhrTransferApiIF> => {
const data: MhrTransferApiIF = {
draftNumber: getMhrInformation.value.draftNumber,
mhrNumber: getMhrInformation.value.mhrNumber,
declaredValue: getMhrTransferDeclaredValue.value,
consideration: getMhrTransferConsideration.value,
Expand Down Expand Up @@ -296,6 +302,7 @@ export const useMhrInformation = () => {
buildApiData,
parseDraftTransferDetails,
parseMhrInformation,
initDraftMhrInformation,
parseSubmittingPartyInfo
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ import {
PaymentIF,
SubmittingPartyIF,
ErrorIF,
TransferTypeSelectIF
TransferTypeSelectIF,
MhrRegistrationIF
} from '@/interfaces'
import { APIMhrTypes, ApiTransferTypes } from '@/enums'

Expand Down Expand Up @@ -44,7 +45,7 @@ export interface MhrTransferApiIF {

export interface MhrDraftApiIF {
type: string
registration: MhrTransferApiIF
registration: MhrTransferApiIF | MhrRegistrationIF
error?: ErrorIF
baseRegistrationNumber?: string
}
Expand Down
25 changes: 13 additions & 12 deletions ppr-ui/src/views/mhrInformation/MhrInformation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@
</template>
</section>
</v-col>
<v-col class="pl-6 pt-5" cols="3" v-if="showMhrFeeSummary || isReviewMode">
<v-col class="pl-6 pt-5" cols="3" v-if="showTransferType || isReviewMode">
<aside>
<affix class="sticky-container" relative-element-selector=".col-9" :offset="{ top: 90, bottom: -100 }">
<sticky-container
Expand Down Expand Up @@ -335,13 +335,13 @@ import {
APIMHRMapSearchTypes,
APISearchTypes,
RouteNames,
UIMHRSearchTypes,
UITransferTypes
UIMHRSearchTypes
} from '@/enums'
import {
createMhrDraft,
deleteMhrDraft,
getAccountInfoFromAuth,
getMhrDraft,
getMHRegistrationSummary,
mhrSearch,
pacificDate,
Expand Down Expand Up @@ -435,6 +435,7 @@ export default defineComponent({
buildApiData,
getUiTransferType,
parseMhrInformation,
initDraftMhrInformation,
parseSubmittingPartyInfo
} = useMhrInformation()
const {
Expand Down Expand Up @@ -462,7 +463,6 @@ export default defineComponent({
loading: false,
isReviewMode: false,
validate: false,
showMhrFeeSummary: false,
refNumValid: false,
accountInfo: null,
feeType: FeeSummaryTypes.MHR_TRANSFER, // FUTURE STATE: To be dynamic, dependent on what changes have been made
Expand All @@ -474,7 +474,7 @@ export default defineComponent({
folioNumber: '',
isPriority: false
},
showTransferType: false,
showTransferType: !!getMhrInformation.value.draftNumber || false,
attentionReference: '',
cancelOptions: unsavedChangesDialog,
saveOptions: registrationSaveDraftError,
Expand Down Expand Up @@ -540,8 +540,14 @@ export default defineComponent({
// Set baseline MHR Information to state
await parseMhrInformation()
// When not a draft Transfer, force no unsaved changes after loading current owners
!getMhrInformation.value.draftNumber && (await setUnsavedChanges(false))
if (getMhrInformation.value.draftNumber) {
// Retrieve draft if it exists
const { registration } = await getMhrDraft(getMhrInformation.value.draftNumber)
await initDraftMhrInformation(registration as MhrTransferApiIF)
} else {
// When not a draft Transfer, force no unsaved changes after loading current owners
await setUnsavedChanges(false)
}
if (isRoleQualifiedSupplier.value && !isRoleStaffReg.value) {
// Get Account Info from Auth to be used in Submitting Party section in Review screen
Expand Down Expand Up @@ -637,8 +643,6 @@ export default defineComponent({
if (!mhrTransferFiling.error) {
setUnsavedChanges(false)
// Delete the draft on successful submission
if (getMhrInformation.value.draftNumber) await deleteMhrDraft(getMhrInformation.value.draftNumber)
const newItem: RegTableNewItemI = {
addedReg: mhrTransferFiling.documentId,
addedRegParent: getMhrInformation.value.mhrNumber,
Expand Down Expand Up @@ -725,8 +729,6 @@ export default defineComponent({
}
localState.showCancelChangeDialog = false
localState.showTransferType = false
localState.showMhrFeeSummary = false
localState.loading = true
await resetMhrInformation()
localState.loading = false
Expand Down Expand Up @@ -779,7 +781,6 @@ export default defineComponent({
}
localState.showTransferType = !localState.showTransferType
localState.showMhrFeeSummary = localState.showTransferType
}
const handleTransferTypeChange = async (transferTypeSelect: TransferTypeSelectIF): Promise<void> => {
Expand Down
22 changes: 11 additions & 11 deletions ppr-ui/tests/unit/MhrInformation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ describe('Mhr Information', () => {
it('should render Attention or Reference Number section on Review screen', async () => {
setupCurrentHomeOwners()
wrapper.vm.$data.dataLoaded = true
wrapper.vm.$data.showMhrFeeSummary = true
wrapper.vm.$data.showTransferType = true
await Vue.nextTick()

expect(wrapper.find('#transfer-ref-num-section').exists()).toBeFalsy()
Expand Down Expand Up @@ -410,7 +410,7 @@ describe('Mhr Information', () => {
it('should render Authorization component on review', async () => {
setupCurrentHomeOwners()
wrapper.vm.$data.dataLoaded = true
wrapper.vm.$data.showMhrFeeSummary = true
wrapper.vm.$data.showTransferType = true
await Vue.nextTick()

expect(wrapper.vm.$data.getMhrTransferCurrentHomeOwnerGroups.length).toBe(1)
Expand Down Expand Up @@ -450,7 +450,7 @@ describe('Mhr Information', () => {
it('should render Submitting Party component on the Review screen', async () => {
setupCurrentHomeOwners()
wrapper.vm.$data.dataLoaded = true
wrapper.vm.$data.showMhrFeeSummary = true
wrapper.vm.$data.showTransferType = true
await Vue.nextTick()

expect(wrapper.find('#account-info').exists()).toBeFalsy()
Expand Down Expand Up @@ -492,7 +492,7 @@ describe('Mhr Information', () => {
await store.dispatch('setAuthRoles', [AuthRoles.PPR_STAFF])
setupCurrentHomeOwners()
wrapper.vm.$data.dataLoaded = true
wrapper.vm.$data.showMhrFeeSummary = true
wrapper.vm.$data.showTransferType = true
await Vue.nextTick()

// Set Wrapper Validations
Expand Down Expand Up @@ -591,7 +591,7 @@ describe('Mhr Information', () => {
it('should render yellow message bar on the Review screen', async () => {
setupCurrentHomeOwners()
wrapper.vm.$data.dataLoaded = true
wrapper.vm.$data.showMhrFeeSummary = true
wrapper.vm.$data.showTransferType = true
await Vue.nextTick()

// doesn't exist on manufactured home page
Expand Down Expand Up @@ -623,7 +623,7 @@ describe('Mhr Information', () => {
it('should render Confirm Completion component on the Review screen', async () => {
setupCurrentHomeOwners()
wrapper.vm.$data.dataLoaded = true
wrapper.vm.$data.showMhrFeeSummary = true
wrapper.vm.$data.showTransferType = true
await Vue.nextTick()

expect(wrapper.find('#transfer-confirm-section').exists()).toBeFalsy()
Expand Down Expand Up @@ -651,7 +651,7 @@ describe('Mhr Information', () => {
it('SALE OR GIFT Flow: display correct Confirm Completion sections', async () => {
setupCurrentHomeOwners()
wrapper.vm.$data.dataLoaded = true
wrapper.vm.$data.showMhrFeeSummary = true
wrapper.vm.$data.showTransferType = true
await Vue.nextTick()

expect(wrapper.find('#transfer-confirm-section').exists()).toBeFalsy()
Expand Down Expand Up @@ -701,7 +701,7 @@ describe('Mhr Information', () => {
it('SURVIVING JOINT TENANT Flow: display correct Confirm Completion sections', async () => {
setupCurrentHomeOwners()
wrapper.vm.$data.dataLoaded = true
wrapper.vm.$data.showMhrFeeSummary = true
wrapper.vm.$data.showTransferType = true
await Vue.nextTick()
await store.dispatch('setAuthRoles', [AuthRoles.STAFF])

Expand Down Expand Up @@ -742,7 +742,7 @@ describe('Mhr Information', () => {
it('TRANS WILL Flow: display correct Confirm Completion sections', async () => {
setupCurrentHomeOwners()
wrapper.vm.$data.dataLoaded = true
wrapper.vm.$data.showMhrFeeSummary = true
wrapper.vm.$data.showTransferType = true
await Vue.nextTick()
await store.dispatch('setAuthRoles', [AuthRoles.STAFF])

Expand Down Expand Up @@ -784,7 +784,7 @@ describe('Mhr Information', () => {
it('should render read only home owners on the Review screen', async () => {
setupCurrentHomeOwners()
wrapper.vm.$data.dataLoaded = true
wrapper.vm.$data.showMhrFeeSummary = true
wrapper.vm.$data.showTransferType = true
await Vue.nextTick()

// TODO: check that removed owners are not displayed in review
Expand Down Expand Up @@ -827,7 +827,7 @@ describe('Mhr Information', () => {
it('should validate and show components errors on Review screen', async () => {
setupCurrentHomeOwners()
wrapper.vm.$data.dataLoaded = true
wrapper.vm.$data.showMhrFeeSummary = true
wrapper.vm.$data.showTransferType = true
await Vue.nextTick()
await triggerUnsavedChange()

Expand Down

0 comments on commit f664f75

Please sign in to comment.