Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mhr History Setup #1955

Merged
merged 6 commits into from
Jun 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.2.27",
"version": "3.2.28",
"private": true,
"appName": "Assets UI",
"sbcName": "SBC Common Components",
Expand Down
2 changes: 1 addition & 1 deletion ppr-ui/src/components/common/Breadcrumb.vue
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ export default defineComponent({
amendBreadcrumb[2].text =
`Base Registration ${getRegistrationNumber.value} - Amendment` || amendBreadcrumb[2].text
return amendBreadcrumb
} else if (name === RouteNames.MHR_INFORMATION) {
} else if ([RouteNames.MHR_INFORMATION, RouteNames.MHR_HISTORY].includes(name as RouteNames)) {
const mhrInfoBreadcrumb = [...tombstoneBreadcrumbMhrInformation]
mhrInfoBreadcrumb[2].text = `MHR Number ${getMhrInformation.value.mhrNumber}`
return mhrInfoBreadcrumb
Expand Down
9 changes: 7 additions & 2 deletions ppr-ui/src/components/common/RegistrationsWrapper.vue
Original file line number Diff line number Diff line change
Expand Up @@ -752,6 +752,9 @@ export default defineComponent({
}
openMhr(mhrInfo)
break
case TableActions.OPEN_MHR_HISTORY:
openMhr(mhrInfo, true)
break
case TableActions.OPEN_DRAFT_CORRECTION:
if (mhrInfo.outOfDate) {
// Handle stale drafts before opening the MHR when flagged as outOfDate
Expand Down Expand Up @@ -820,9 +823,11 @@ export default defineComponent({
await startNewRegistration(MhrRegistrationType, mhrInfo.draftNumber)
}

const openMhr = async (mhrSummary: MhRegistrationSummaryIF): Promise<void> => {
const openMhr = async (mhrSummary: MhRegistrationSummaryIF, isHistory = false): Promise<void> => {
setMhrInformation(mhrSummary)
await router.replace({ name: RouteNames.MHR_INFORMATION })

// Change the route for history
await router.replace({ name: isHistory ? RouteNames.MHR_HISTORY : RouteNames.MHR_INFORMATION })
}

const openDraftMhrCorrection = async (draftMhrCorrection) => {
Expand Down
23 changes: 22 additions & 1 deletion ppr-ui/src/components/tables/common/TableRow.vue
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,17 @@
<span class="ml-1">Non-Residential Exemption</span>
</v-list-item-subtitle>
</v-list-item>
<v-list-item
v-if="isRoleStaffReg"
@click="openMhrHistory(item)"
>
<v-list-item-subtitle>
<v-icon size="small">
mdi-clock
</v-icon>
<span class="ml-1">Historical Home Information</span>
</v-list-item-subtitle>
</v-list-item>
<v-list-item
data-test-id="remove-mhr-row-btn"
@click="handleAction(item, TableActions.REMOVE)"
Expand Down Expand Up @@ -905,6 +916,13 @@ export default defineComponent({
})
}

const openMhrHistory = (item) => {
emit('action', {
action: TableActions.OPEN_MHR_HISTORY,
mhrInfo: item
})
}

const isMhrTransfer = (item: any): boolean => {
const formattedTransferTypes = [
UITransferTypes.SALE_OR_GIFT,
Expand Down Expand Up @@ -1127,6 +1145,7 @@ export default defineComponent({
}, { deep: true, immediate: true })

return {
openMhrHistory,
hasRequiredTransfer,
multipleWordsToTitleCase,
freezeScrolling,
Expand Down Expand Up @@ -1184,7 +1203,6 @@ export default defineComponent({

<style lang="scss" scoped>
@import '@/assets/styles/theme.scss';

.registration-row {
// $blueSelected 0.5 opacity colour at full opacity (needed for .actions-cell overlay)
background-color: #f2f6fb;
Expand All @@ -1199,6 +1217,9 @@ export default defineComponent({
border-bottom: thin solid rgba(0, 0, 0, .12)
}
}
img {
margin-bottom: -2px;
}

.base-registration-row {
background-color: white;
Expand Down
1 change: 1 addition & 0 deletions ppr-ui/src/enums/routeNames.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export enum RouteNames {
YOUR_HOME = 'your-home',
MHR_INFORMATION = 'mhr-information',
MHR_INFORMATION_NOTE = 'mhr-information-note',
MHR_HISTORY = 'mhr-history',
RESIDENTIAL_EXEMPTION = 'residential-exemption',
NON_RESIDENTIAL_EXEMPTION = 'non-residential-exemption',
EXEMPTION_DETAILS = 'exemption-details',
Expand Down
3 changes: 2 additions & 1 deletion ppr-ui/src/enums/tableActions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,6 @@ export enum TableActions {
OPEN_MHR = 'openMhr',
EDIT_NEW_MHR = 'editMhr',
OPEN_DRAFT_CORRECTION = 'openDraftCorrection',
OPEN_DRAFT_RE_REGISTRATION = 'openDraftReRegistration'
OPEN_DRAFT_RE_REGISTRATION = 'openDraftReRegistration',
OPEN_MHR_HISTORY = 'openMhrHistory'
}
1 change: 1 addition & 0 deletions ppr-ui/src/interfaces/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export * from './exemption-interfaces'
export * from './base-data-union-interface'
export * from './updated-badge-interface'
export * from './admin-registration-interfaces'
export * from './mhr-api-interfaces'

/** A filing's business object from the API. */
export interface StaffPaymentIF {
Expand Down
105 changes: 105 additions & 0 deletions ppr-ui/src/interfaces/mhr-api-interfaces/MhrHistoryIF.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
interface Description {
baseInformation?: {
circa?: boolean
make?: string
model?: string
year?: number
}
createDateTime?: string
csaNumber?: string
csaStandard?: string
documentId?: string
documentRegistrationNumber?: string
manufacturer?: string
otherRemarks?: string
rebuiltRemarks?: string
registrationDescription?: string
sectionCount?: number
sections?: Section[]
status?: string
}

interface Section {
lengthFeet?: number
lengthInches?: number
serialNumber?: string
widthFeet?: number
widthInches?: number
}

interface Address {
city?: string
country?: string
postalCode?: string
region?: string
street?: string
}

interface Location {
address?: Address
additionalDescription?: string
createDateTime?: string
documentId?: string
documentRegistrationNumber?: string
endDateTime?: string
endRegistrationDescription?: string
leaveProvince?: boolean
legalDescription?: string
locationId?: number
locationType?: string
pidNumber?: string
registrationDescription?: string
status?: string
taxCertificate?: boolean
}

interface IndividualName {
first?: string
last?: string
middle?: string
}

interface Owner {
address?: Address
createDateTime?: string
documentId?: string
documentRegistrationNumber?: string
endDateTime?: string
endRegistrationDescription?: string
groupCount?: number
groupId?: number
groupOwnerCount?: number
groupTenancyType?: string
individualName?: IndividualName
interest?: string
interestDenominator?: number
interestNumerator?: number
ownerId?: number
partyType?: string
phoneNumber?: string
registrationDescription?: string
status?: string
type?: string
}

interface Registration {
affirmByName?: string
attentionReference?: string
consideration?: string
createDateTime?: string
declaredValue?: number
documentId?: string
documentRegistrationNumber?: string
ownLand?: boolean
registrationDescription?: string
transferDate?: string
}

export interface MhrHistoryRoIF {
descriptions?: Description[]
locations?: Location[]
mhrNumber: string
owners?: Owner[]
registrations?: Registration[]
statusType: string
}
1 change: 1 addition & 0 deletions ppr-ui/src/interfaces/mhr-api-interfaces/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './MhrHistoryIF'
9 changes: 9 additions & 0 deletions ppr-ui/src/router/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
MHRSearch,
MhrRegistration,
MhrInformation,
MhrHistory,
ConfirmMHRSearch,
ReviewConfirm,
RenewRegistration,
Expand Down Expand Up @@ -242,6 +243,14 @@ export const routes: any = [
requiresAuth: true,
},
},
{
path: '/mhr-history',
name: RouteNames.MHR_HISTORY,
component: MhrHistory,
meta: {
requiresAuth: true,
},
},
{
path: '/user-access/qs-access-type',
name: RouteNames.QS_ACCESS_TYPE,
Expand Down
1 change: 1 addition & 0 deletions ppr-ui/src/utils/feature-flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ export const defaultFlagSet: LDFlagSet = {
'mhr-amend-transport-permit-enabled': false,
'mhr-cancel-transport-permit-enabled': false,
'mhr-user-access-enabled': false,
'mhr-history-enabled': false,
'sentry-enable': false, // by default, no sentry logs
'banner-text': '' // by default, there is no banner text
}
Expand Down
33 changes: 32 additions & 1 deletion ppr-ui/src/utils/mhr-api-helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
RegistrationSortIF,
SearchResponseIF,
StaffPaymentIF,
AdminRegistrationIF
AdminRegistrationIF,
MhrHistoryRoIF
} from '@/interfaces'
import { APIMhrTypes, ErrorCategories, ErrorCodes, ErrorRootCauses, StaffPaymentOptions } from '@/enums'
import { useSearch } from '@/composables/useSearch'
Expand Down Expand Up @@ -969,3 +970,33 @@ export async function createExemption (
}
}
}

/**
* Fetches the MHR (Manufactured Home Registry) history for a given MHR number.
*
* @param {string} mhrNumber - The MHR number to fetch history for.
* @returns {Promise<MhrHistoryRoIF>} - A promise that resolves to the MHR history data.
*
* @throws Will throw an error if the API response is invalid or if any non-404 errors occur.
* In case of a 404 error, logs the error and returns null.
*/
export async function getMhrHistory (mhrNumber: string): Promise<MhrHistoryRoIF> {
try {
const response = await axios.get<MhrHistoryRoIF>(`registrations/history/${mhrNumber}`, getDefaultConfig())
const data: MhrHistoryRoIF = response?.data
if (!data) {
throw new Error('Invalid API response')
}
return data
} catch (error: AxiosError | any) {
if (error.response && error.response.status === 404) {
console.error('Resource not found:', error.message)
// Handle 404 gracefully, returning null
return null
} else {
// Handle other errors differently if needed
console.error('API Error:', error.message)
throw error
}
}
}
Loading
Loading