Skip to content

Commit

Permalink
15538 Don't set initial restoration type + misc cleanup (#693)
Browse files Browse the repository at this point in the history
* - app version = 7.3.24
- misc package updates
- refactored restoration filing init (to support null type)
- refactored restoration filing resume
- deleted unneeded application types

* wip

* - set initial route for Create UI
- updated unit tests

---------

Co-authored-by: Severin Beauvais <severin.beauvais@gov.bc.ca>
  • Loading branch information
severinbeauvais and Severin Beauvais authored Sep 18, 2024
1 parent 2ab102b commit 5c062bf
Show file tree
Hide file tree
Showing 10 changed files with 2,614 additions and 520 deletions.
3,020 changes: 2,576 additions & 444 deletions package-lock.json

Large diffs are not rendered by default.

9 changes: 4 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "business-filings-ui",
"version": "7.3.23",
"version": "7.3.24",
"private": true,
"appName": "Filings UI",
"sbcName": "SBC Common Components",
Expand Down Expand Up @@ -38,7 +38,6 @@
"http-status-codes": "^2.2.0",
"launchdarkly-js-client-sdk": "^2.24.2",
"lodash": "^4.17.21",
"lodash.omit": "^4.5.0",
"pdfjs-dist": "3.9.179",
"pinia": "^2.0.35",
"pinia-class": "^0.0.3",
Expand All @@ -48,7 +47,7 @@
"register-service-worker": "^1.7.2",
"rxjs": "^7.8.1",
"sbc-common-components": "3.0.13",
"vue": "2.7.14",
"vue": "2.7.16",
"vue-affix": "^0.5.2",
"vue-auto-resize": "^1.0.1",
"vue-hotjar": "^1.4.0",
Expand All @@ -60,7 +59,7 @@
},
"devDependencies": {
"@pinia/testing": "^0.0.16",
"@types/lodash": "^4.14.194",
"@types/lodash": "^4.17.7",
"@types/sinon": "^10.0.14",
"@types/vue-the-mask": "^0.11.1",
"@types/vuelidate": "^0.7.16",
Expand All @@ -82,7 +81,7 @@
"vite": "4.5.2",
"vite-plugin-environment": "^1.1.3",
"vitest": "0.33.0",
"volar-service-vetur": "^0.0.54",
"volar-service-vetur": "^0.0.62",
"vue-class-component": "^7.2.6",
"vue-debounce-decorator": "^1.0.1",
"vue-property-decorator": "^9.1.2",
Expand Down
35 changes: 16 additions & 19 deletions src/components/Dashboard/StaffNotation.vue
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@
v-if="isHistorical"
data-type="restoration"
:disabled="!isAllowed(AllowableActions.RESTORATION)"
@click="goToRestorationFiling(ApplicationTypes.CREATE_UI, FilingSubTypes.FULL_RESTORATION)"
@click="goToRestorationFiling()"
>
<v-list-item-title>
<span class="app-blue">Restore Company</span>
Expand Down Expand Up @@ -212,7 +212,7 @@
<v-list-item
v-if="isAllowed(AllowableActions.LIMITED_RESTORATION_EXTENSION)"
data-type="extend-limited-restoration"
@click="goToRestorationFiling(ApplicationTypes.EDIT_UI, FilingSubTypes.LIMITED_RESTORATION_EXTENSION)"
@click="goToRestorationFiling(FilingSubTypes.LIMITED_RESTORATION_EXTENSION)"
>
<v-list-item-title>
<span class="app-blue">Extend Limited Restoration</span>
Expand All @@ -222,7 +222,7 @@
<v-list-item
v-if="isAllowed(AllowableActions.LIMITED_RESTORATION_TO_FULL)"
data-type="convert-full-restoration"
@click="goToRestorationFiling(ApplicationTypes.EDIT_UI, FilingSubTypes.LIMITED_RESTORATION_TO_FULL)"
@click="goToRestorationFiling(FilingSubTypes.LIMITED_RESTORATION_TO_FULL)"
>
<v-list-item-title>
<span class="app-blue">Convert to Full Restoration</span>
Expand All @@ -239,12 +239,7 @@
import { Component, Emit, Mixins, Prop } from 'vue-property-decorator'
import { Action, Getter } from 'pinia-class'
import { GetFeatureFlag, navigate } from '@/utils'
import {
AllowableActions,
ApplicationTypes,
FilingSubTypes,
Routes
} from '@/enums'
import { AllowableActions, FilingSubTypes, Routes } from '@/enums'
import { FilingNames, FilingTypes } from '@bcrs-shared-components/enums'
import { AddStaffNotationDialog } from '@/components/dialogs'
import { AllowableActionsMixin, FilingMixin } from '@/mixins'
Expand All @@ -265,7 +260,6 @@ export default class StaffNotation extends Mixins(AllowableActionsMixin, FilingM
// enums for template
readonly AllowableActions = AllowableActions
readonly ApplicationTypes = ApplicationTypes
readonly FilingNames = FilingNames
readonly FilingSubTypes = FilingSubTypes
readonly FilingTypes = FilingTypes
Expand Down Expand Up @@ -373,9 +367,10 @@ export default class StaffNotation extends Mixins(AllowableActionsMixin, FilingM
this.$router.push({ name: Routes.CONTINUATION_OUT, query: { filingId: '0' } })
}
async goToRestorationFiling (applicationName: ApplicationTypes, restorationType: FilingSubTypes): Promise<void> {
let url: string
async goToRestorationFiling (restorationType: FilingSubTypes = null): Promise<void> {
try {
let url: string
// show spinner since the network calls below can take a few seconds
this.setFetchingDataSpinner(true)
Expand All @@ -386,13 +381,15 @@ export default class StaffNotation extends Mixins(AllowableActionsMixin, FilingM
if (isNaN(id)) throw new Error('Invalid API response')
// navigate to Create UI if Full/Limited restoration
// navigate to Edit UI if Limited extension/Full to Limited conversion
if (applicationName === ApplicationTypes.CREATE_UI) {
url = `${this.getCreateUrl}?id=${this.getIdentifier}`
}
if (applicationName === ApplicationTypes.EDIT_UI) {
url = `${this.getEditUrl}${this.getIdentifier}/` + restorationType + `?restoration-id=${id}`
// navigate to Edit UI for limited restoration extension filing
// navigate to Edit UI for limited restoration to full filing
// navigate to Create UI for full or limited restoration filing
if (restorationType === FilingSubTypes.LIMITED_RESTORATION_EXTENSION) {
url = `${this.getEditUrl}${this.getIdentifier}/limitedRestorationExtension?restoration-id=${id}`
} else if (restorationType === FilingSubTypes.LIMITED_RESTORATION_TO_FULL) {
url = `${this.getEditUrl}${this.getIdentifier}/limitedRestorationToFull?restoration-id=${id}`
} else {
url = `${this.getCreateUrl}restoration-business-name?id=${this.getIdentifier}`
}
navigate(url)
Expand Down
55 changes: 13 additions & 42 deletions src/components/Dashboard/TodoList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2086,54 +2086,25 @@ export default class TodoList extends Mixins(AllowableActionsMixin, DateMixin) {
console.log('doResumeFiling(), invalid filing type =', item)
}
/* Handles the restoration flow inside of doResumeFiling */
navigateForResumeRestoration (item: TodoItemIF): void {
let restorationType: FilingSubTypes
/**
* Type assertion is done to fix TypeScript error.
* "This condition will always return 'false' since the types
* 'FilingSubTypes' and 'RestorationTypes' have no overlap."
*/
if (item.filingSubType === FilingSubTypes.FULL_RESTORATION) {
restorationType = FilingSubTypes.FULL_RESTORATION
}
if (item.filingSubType === FilingSubTypes.LIMITED_RESTORATION) {
restorationType = FilingSubTypes.LIMITED_RESTORATION
}
if (item.filingSubType === FilingSubTypes.LIMITED_RESTORATION_EXTENSION) {
restorationType = FilingSubTypes.LIMITED_RESTORATION_EXTENSION
}
if (item.filingSubType === FilingSubTypes.LIMITED_RESTORATION_TO_FULL) {
restorationType = FilingSubTypes.LIMITED_RESTORATION_TO_FULL
}
navigate(this.buildRestorationUrl(item, restorationType))
}
// navigate to Create UI if Full/Limited restoration or to Edit UI if Limited extension/Full to Limited conversion
buildRestorationUrl (item: TodoItemIF, restorationType: FilingSubTypes): string {
/* Called to resume draft restoration filing. */
private navigateForResumeRestoration (item: TodoItemIF): void {
let url: string
switch (restorationType) {
case FilingSubTypes.FULL_RESTORATION:
case FilingSubTypes.LIMITED_RESTORATION: {
url = `${this.getCreateUrl}?id=${this.getIdentifier}`
break
}
case FilingSubTypes.LIMITED_RESTORATION_EXTENSION:
case FilingSubTypes.LIMITED_RESTORATION_TO_FULL: {
url = `${this.getEditUrl}${this.getIdentifier}/` + restorationType + `?restoration-id=${item.filingId}`
break
}
// navigate to Edit UI to resume limited restoration extension filing
// navigate to Edit UI to resume limited restoration to full filing
// navigate to Create UI to resume full or limited restoration filing
if (item.filingSubType === FilingSubTypes.LIMITED_RESTORATION_EXTENSION) {
url = `${this.getEditUrl}${this.getIdentifier}/limitedRestorationExtension?restoration-id=${item.filingId}`
} else if (item.filingSubType === FilingSubTypes.LIMITED_RESTORATION_TO_FULL) {
url = `${this.getEditUrl}${this.getIdentifier}/limitedRestorationToFull?restoration-id=${item.filingId}`
} else {
url = `${this.getCreateUrl}restoration-business-name?id=${this.getIdentifier}`
}
return url
navigate(url)
}
// this is called for both Resume Payment and Retry Payment
/** Called to change payment type, resume payment or retry payment. */
doResumePayment (item: TodoItemIF): boolean {
const paymentToken = item.paymentToken
Expand Down
4 changes: 0 additions & 4 deletions src/enums/applicationTypes.ts

This file was deleted.

1 change: 0 additions & 1 deletion src/enums/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ export * from './actions'
export * from './affiliationInvitation'
export * from './allowableActions'
export * from './amalgamationEnums'
export * from './applicationTypes'
export * from './correctionTypes'
export * from './digitalCredentialTypes'
export * from './effectOfOrderTypes'
Expand Down
3 changes: 1 addition & 2 deletions src/mixins/common-mixin.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Component, Vue } from 'vue-property-decorator'
import { isEqual } from 'lodash'
import omit from 'lodash.omit'
import { isEqual, omit } from 'lodash'
import { Getter } from 'pinia-class'
import { useConfigurationStore } from '@/stores'
import { GetFeatureFlag, navigate } from '@/utils'
Expand Down
3 changes: 2 additions & 1 deletion src/mixins/filing-mixin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,10 @@ export default class FilingMixin extends DateMixin {

/**
* Builds a Restoration filing body.
* @param restorationType The type of restoration. May be null.
* @returns the filing body
*/
buildRestorationFiling (restorationType = FilingSubTypes.FULL_RESTORATION): RestorationFilingIF {
buildRestorationFiling (restorationType: FilingSubTypes): RestorationFilingIF {
const restoration: RestorationFilingIF = {
header: {
date: this.getCurrentDate,
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/StaffNotation.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ describe('StaffNotation', () => {
await Vue.nextTick()

// verify redirection
expect(window.location.assign).toHaveBeenCalledWith('https://create.url/?id=BC1234567')
expect(window.location.assign).toHaveBeenCalledWith('https://create.url/restoration-business-name?id=BC1234567')

wrapper.destroy()
sinon.restore()
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/TodoList1.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3315,7 +3315,7 @@ describe('TodoList - Click Tests - Full and Limited Restoration', () => {

// verify redirection
const accountId = JSON.parse(sessionStorage.getItem('CURRENT_ACCOUNT'))?.id
const createUrl = `https://create.url/?id=${test.businessId}`
const createUrl = `https://create.url/restoration-business-name?id=${test.businessId}`
expect(window.location.assign).toHaveBeenCalledWith(createUrl + '&accountid=' + accountId)

wrapper.destroy()
Expand Down

0 comments on commit 5c062bf

Please sign in to comment.