Skip to content

Commit

Permalink
Corrections Submissions (bcgov#1800)
Browse files Browse the repository at this point in the history
* Corrections Submissions

* Clean Up
  • Loading branch information
cameron-eyds authored Mar 26, 2024
1 parent cffdf01 commit 23d055a
Show file tree
Hide file tree
Showing 14 changed files with 280 additions and 37 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": "3.0.70",
"version": "3.0.71",
"private": true,
"appName": "Assets UI",
"sbcName": "SBC Common Components",
Expand Down
2 changes: 1 addition & 1 deletion ppr-ui/src/components/common/ButtonsStacked.vue
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ export default defineComponent({
}
const submit = debounce(() => {
emit('submit', true)
}, 500) // prevent multiple submissions by adding a small delay
}, 2500) // prevent multiple submissions by adding a small delay
const save = () => {
emit('save', true)
Expand Down
8 changes: 2 additions & 6 deletions ppr-ui/src/components/common/UpdatedBadge.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,16 @@
xSmall
variant="flat"
color="primary"
:data-test-id="`${defaultAction}-badge`"
:data-test-id="`${action}-badge`"
>
<b class="fs-10">{{ defaultAction }}</b>
<b class="fs-10">{{ action }}</b>
</v-chip>
</div>
</template>
<script setup lang="ts">
import { computed, PropType } from 'vue'
import { BaseDataUnionIF } from '@/interfaces'
import { deepChangesComparison } from '@/utils'
import { ActionTypes } from '@/enums'
const props = withDefaults(defineProps<{
action?: string,
Expand All @@ -31,9 +30,6 @@ const props = withDefaults(defineProps<{
isCaseSensitive: false
})
/** Override default Action to ADDED when there is NO baseline, otherwise rely on prop or prop default. **/
const defaultAction = !!props.baseline ? props.action : ActionTypes.ADDED
/**
* Is true when there is a difference between the baseline and current state
* By default string comparisons are insensitive unless activated by isCaseSensitive Prop
Expand Down
9 changes: 5 additions & 4 deletions ppr-ui/src/components/mhrRegistration/MhrStatusCorrection.vue
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@
<v-col class="py-0 mt-n1">
<UpdatedBadge
class="ml-n2"
:baseline="getMhrBaseline?.statusType"
:currentState="getMhrStatusType"
:baseline="correctionState.status.baseline"
:currentState="correctionState.status.currentState"
/>
</v-col>
</v-row>
Expand All @@ -100,11 +100,12 @@ import { MhApiStatusTypes, MhUIStatusTypes, RouteNames } from '@/enums'
import { UpdatedBadge } from '@/components/common'
import { storeToRefs } from 'pinia'
import { useStore } from '@/store/store'
import { useNavigation } from '@/composables'
import { useMhrCorrections, useNavigation } from '@/composables'
const { containsCurrentRoute } = useNavigation()
const { setMhrCorrectStatusType } = useStore()
const { getMhrBaseline, getMhrStatusType, getMhrInformation } = storeToRefs(useStore())
const { getMhrInformation } = storeToRefs(useStore())
const { correctionState } = useMhrCorrections()
const mhrStatus = ref(getMhrInformation.value?.statusType)
const displayStatusOptions = computed((): boolean => {
Expand Down
70 changes: 66 additions & 4 deletions ppr-ui/src/composables/mhrRegistration/useMhrCorrections.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,22 @@
import { useStore } from '@/store/store'
import { storeToRefs } from 'pinia'
import { computed, ComputedRef, reactive } from 'vue'
import { deleteEmptyProperties, fetchMhRegistration, fromDisplayPhone, getFeatureFlag } from '@/utils'
import {
deepChangesComparison,
deleteEmptyProperties,
fetchMhRegistration,
fromDisplayPhone,
getFeatureFlag
} from '@/utils'
import { ActionTypes, APIRegistrationTypes, HomeCertificationOptions, RouteNames } from '@/enums'
import { useNavigation, useNewMhrRegistration } from '@/composables'
import { AdminRegistrationIF, HomeSectionIF, RegistrationTypeIF, UpdatedBadgeIF } from '@/interfaces'
import { deepChangesComparison } from '@/utils'
import {
AdminRegistrationIF,
HomeSectionIF,
NewMhrRegistrationApiIF,
RegistrationTypeIF,
UpdatedBadgeIF
} from '@/interfaces'
import { cloneDeep, omit } from 'lodash'

export const useMhrCorrections = () => {
Expand All @@ -14,6 +25,7 @@ export const useMhrCorrections = () => {
setRegistrationType,
} = useStore()
const {
getMhrStatusType,
getMhrRegistration,
getMhrInformation,
getRegistrationType,
Expand Down Expand Up @@ -66,8 +78,22 @@ export const useMhrCorrections = () => {
/** Returns true when NOT evaluated during a Correction Filing (ie Base MHR) OR has at least 1 Correction Made **/
const hasMadeMhrCorrections: ComputedRef<boolean> = computed((): boolean => !!getCorrectionsList().length)


/** Array of keys representing description-related correction groups.*/
const descriptionGroup: Array<string> = [
'manufacturer', 'manufacturerYear', 'make', 'model', 'homeCertification', 'rebuilt', 'otherRemarks', 'homeSections'
]

/** Array of keys representing location-related correction groups.*/
const locationGroup: Array<string> = ['locationType', 'civicAddress']

/** Correction State Models: Used in multiple ui-locations for CORRECTED LABELS, centralized for re-use **/
const correctionState = reactive({
// Mhr Status Type
status: computed ((): UpdatedBadgeIF => ({
baseline: getMhrBaseline.value?.statusType,
currentState: getMhrStatusType.value
})),
// Your Home Step
manufacturer: computed((): UpdatedBadgeIF => ({
baseline: getMhrBaseline.value?.description.manufacturer,
Expand Down Expand Up @@ -229,6 +255,41 @@ export const useMhrCorrections = () => {
}
}

/**
* Builds a correction payload based on the provided MHR state.
* @param {NewMhrRegistrationApiIF} mhrState - The state of the Manufactured Home Registration.
* @returns {AdminRegistrationIF} - The correction payload for the Admin Registration.
*/
const buildCorrectionPayload = (mhrState: NewMhrRegistrationApiIF): AdminRegistrationIF => {
return {
attentionReference: mhrState.attentionReference || '',
documentId: mhrState.documentId,
documentType: getRegistrationType.value?.registrationTypeAPI,
submittingParty: mhrState.submittingParty,
...(getCorrectionsList().includes('status') && {
status: getMhrStatusType.value
}),
...(getCorrectionsList().some(value => descriptionGroup.includes(value)) && {
description: mhrState.description
}),
...(getCorrectionsList().includes('ownerGroups') && {
addOwnerGroups: mhrState.ownerGroups
.filter(group => group.action !== ActionTypes.REMOVED)
.map(group => ({
...group,
owners: group.owners.filter(owner => owner.action !== ActionTypes.REMOVED)
})),
deleteOwnerGroups: getMhrBaseline.value.ownerGroups
}),
...(getCorrectionsList().some(value => locationGroup.includes(value)) && {
location: mhrState.location
}),
...(getCorrectionsList().includes('landDetails') && {
ownLand: mhrState.ownLand
})
}
}

/** Build and return payload for an Admin Registration: Registered Location Change **/
const buildLocationChange = (): AdminRegistrationIF => {
const payloadData: AdminRegistrationIF = {
Expand Down Expand Up @@ -256,6 +317,7 @@ export const useMhrCorrections = () => {
hasMadeMhrCorrections,
initMhrCorrection,
correctHomeSection,
buildLocationChange
buildLocationChange,
buildCorrectionPayload
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -441,6 +441,5 @@ export const useNewMhrRegistration = () => {
buildApiData,
parseStaffPayment,
fetchMhRegistrations,
cleanEmpty
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,10 @@ export interface AdminRegistrationIF {
documentType: APIRegistrationTypes
documentId: string
submittingParty: SubmittingPartyIF
statusType?: MhApiStatusTypes
status?: MhApiStatusTypes
location?: MhrRegistrationHomeLocationIF
description?: MhrRegistrationDescriptionIF
deleteOwnerGroups?: Array<MhrHomeOwnerGroupIF>
addOwnerGroups?: Array<MhrHomeOwnerGroupIF>
ownLand?: boolean
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ export interface MhrRegistrationHomeOwnerIF {
action?: ActionTypes
individualName?: {
first: string
middle: string
middle?: string
last: string
},
suffix?: string
organizationName?: string
deathCorpNumber?: string
phoneNumber: string
phoneExtension: string
phoneExtension?: string
address: AddressIF
deathCertificateNumber?: string
deathDateTime?: string
Expand Down
57 changes: 57 additions & 0 deletions ppr-ui/src/resources/buttonFooterConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,63 @@ export const MHRButtonFooterConfig: Array<ButtonConfigIF> = [
nextRouteName: RouteNames.DASHBOARD
}]

export const MHRCorrectionButtonFooterConfig: Array<ButtonConfigIF> = [
{
stepName: RouteNames.SUBMITTING_PARTY,
showCancel: true,
showSave: false,
showSaveResume: false,
showBack: false,
showNext: true,
backRouteName: '',
nextText: 'Describe Your Home',
nextRouteName: RouteNames.YOUR_HOME
},
{
stepName: RouteNames.YOUR_HOME,
showCancel: true,
showSave: false,
showSaveResume: false,
showBack: true,
showNext: true,
backRouteName: RouteNames.SUBMITTING_PARTY,
nextText: 'List the Home Owners',
nextRouteName: RouteNames.HOME_OWNERS
},
{
stepName: RouteNames.HOME_OWNERS,
showCancel: true,
showSave: false,
showSaveResume: false,
showBack: true,
showNext: true,
backRouteName: RouteNames.YOUR_HOME,
nextText: 'Location of Home',
nextRouteName: RouteNames.HOME_LOCATION
},
{
stepName: RouteNames.HOME_LOCATION,
showCancel: true,
showSave: false,
showSaveResume: false,
showBack: true,
showNext: true,
backRouteName: RouteNames.HOME_OWNERS,
nextText: 'Review and Confirm',
nextRouteName: RouteNames.MHR_REVIEW_CONFIRM
},
{
stepName: RouteNames.MHR_REVIEW_CONFIRM,
showCancel: true,
showSave: false,
showSaveResume: false,
showBack: true,
showNext: true,
backRouteName: RouteNames.HOME_LOCATION,
nextText: 'Register and Pay',
nextRouteName: RouteNames.DASHBOARD
}]

export const MHRManufacturerButtonFooterConfig: Array<ButtonConfigIF> = [
{
stepName: RouteNames.YOUR_HOME,
Expand Down
6 changes: 4 additions & 2 deletions ppr-ui/src/store/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ import {
YourHome
} from '@/views'
import {
MHRButtonFooterConfig,
MHRButtonFooterConfig, MHRCorrectionButtonFooterConfig,
MHRManufacturerButtonFooterConfig,
RegistrationButtonFooterConfig
} from '@/resources/buttonFooterConfig'
Expand Down Expand Up @@ -532,7 +532,9 @@ export const useStore = defineStore('assetsStore', () => {
return isMhrRegistration.value ? getMhrButtonFooterConfig.value : RegistrationButtonFooterConfig
})
const getMhrButtonFooterConfig = computed<ButtonConfigIF[]>(() => {
return isMhrManufacturerRegistration.value ? MHRManufacturerButtonFooterConfig : MHRButtonFooterConfig
return isMhrManufacturerRegistration.value
? MHRManufacturerButtonFooterConfig
: useMhrCorrections().isMhrCorrection.value ? MHRCorrectionButtonFooterConfig : MHRButtonFooterConfig
})
const isBusySaving = computed<boolean>(() => {
return false
Expand Down
19 changes: 14 additions & 5 deletions ppr-ui/src/views/newMhrRegistration/MhrRegistration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ import { computed, defineComponent, nextTick, onMounted, reactive, toRefs } from
import { useStore } from '@/store/store'
import { storeToRefs } from 'pinia'
import { APIRegistrationTypes, RegistrationFlowType, UIRegistrationTypes } from '@/enums'
import { getFeatureFlag, getMhrDraft, submitMhrRegistration } from '@/utils'
import { getFeatureFlag, getMhrDraft, submitAdminRegistration, submitMhrRegistration } from '@/utils'
import { ButtonFooter, Stepper, StickyContainer } from '@/components/common'
import {
useAuth,
Expand Down Expand Up @@ -149,6 +149,7 @@ export default defineComponent({
// Getters
getMhrSteps,
getFooterButtonConfig,
getMhrInformation,
getMhrDraftNumber,
getRegistrationType,
getRegistrationFlowType,
Expand All @@ -172,7 +173,8 @@ export default defineComponent({
} = useHomeOwners()
const {
isMhrCorrection,
getCorrectionsList
getCorrectionsList,
buildCorrectionPayload
} = useMhrCorrections()
const localState = reactive({
Expand Down Expand Up @@ -262,14 +264,21 @@ export default defineComponent({
delete data.submittingParty.hasUsedPartyLookup
}
const mhrSubmission = await submitMhrRegistration(data, parseStaffPayment())
const mhrSubmission = isMhrCorrection.value
? await submitAdminRegistration(
getMhrInformation.value.mhrNumber,
buildCorrectionPayload(data),
parseStaffPayment()
)
: await submitMhrRegistration(data, parseStaffPayment())
localState.submitting = false
if (!mhrSubmission.error && mhrSubmission?.mhrNumber) {
resetAllValidations()
setShowGroups(false)
const newRegItem: RegTableNewItemI = {
addedReg: mhrSubmission.mhrNumber,
addedRegParent: '',
addedReg: isMhrCorrection.value ? mhrSubmission.documentRegistrationNumber : mhrSubmission.mhrNumber,
addedRegParent: isMhrCorrection.value ? getMhrInformation.value.mhrNumber : '',
addedRegSummary: mhrSubmission,
prevDraft: mhrSubmission.documentId
}
Expand Down
Loading

0 comments on commit 23d055a

Please sign in to comment.