diff --git a/.env.example b/.env.example index 6c8f005cc..58cf40618 100644 --- a/.env.example +++ b/.env.example @@ -13,6 +13,7 @@ VUE_APP_DASHBOARD_URL="https://dev.business.bcregistry.gov.bc.ca/" VUE_APP_SITEMINDER_LOGOUT_URL="https://logontest7.gov.bc.ca/clp-cgi/logoff.cgi" VUE_APP_BUSINESS_CREATE_URL="https://dev.create.business.bcregistry.gov.bc.ca/" VUE_APP_BUSINESS_EDIT_URL="https://dev.edit.business.bcregistry.gov.bc.ca/" +VUE_APP_BUSINESS_DASH_URL="https://business-dashboard-dev.web.app/" #vaults API VUE_APP_AUTH_API_URL="https://auth-api-dev.apps.silver.devops.gov.bc.ca" diff --git a/devops/vaults.env b/devops/vaults.env index e62b906b2..d81ab30cb 100644 --- a/devops/vaults.env +++ b/devops/vaults.env @@ -13,6 +13,7 @@ VUE_APP_DASHBOARD_URL="op://web-url/$APP_ENV/business/DASHBOARD_URL" VUE_APP_SITEMINDER_LOGOUT_URL="op://web-url/$APP_ENV/siteminder/SITEMINDER_LOGOUT_URL" VUE_APP_BUSINESS_CREATE_URL="op://web-url/$APP_ENV/business-create/BUSINESS_CREATE_URL" VUE_APP_BUSINESS_EDIT_URL="op://web-url/$APP_ENV/business-edit/BUSINESS_EDIT_URL" +VUE_APP_BUSINESS_DASH_URL="op://web-url/$APP_ENV/business-dash/BUSINESS_DASH_URL" #vaults API VUE_APP_AUTH_API_URL="op://API/$APP_ENV/auth-api/AUTH_API_URL" diff --git a/package-lock.json b/package-lock.json index ff2656ea4..030c93055 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "business-filings-ui", - "version": "7.3.22", + "version": "7.3.23", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "business-filings-ui", - "version": "7.3.22", + "version": "7.3.23", "dependencies": { "@babel/compat-data": "^7.21.5", "@bcrs-shared-components/base-address": "2.0.9", diff --git a/package.json b/package.json index ae5664580..ac57ea59e 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "business-filings-ui", - "version": "7.3.22", + "version": "7.3.23", "private": true, "appName": "Filings UI", "sbcName": "SBC Common Components", diff --git a/src/App.vue b/src/App.vue index 2f86f220c..4b5ac6dd4 100644 --- a/src/App.vue +++ b/src/App.vue @@ -148,6 +148,7 @@ import { } from '@/components/dialogs' import { ConfigJson, + getDashboardBreadcrumb, getMyBusinessRegistryBreadcrumb, getRegistryDashboardBreadcrumb, getStaffDashboardBreadcrumb @@ -309,10 +310,7 @@ export default class App extends Mixins( get breadcrumbs (): Array { const breadcrumbs = this.$route?.meta?.breadcrumb const crumbs: Array = [ - { - text: this.getEntityName || 'Unknown Name', - to: { name: Routes.DASHBOARD } - }, + getDashboardBreadcrumb(this.getEntityName, this.getBusinessDashUrl, this.getIdentifier), ...(breadcrumbs || []) ] diff --git a/src/interfaces/configuration-state-interface.ts b/src/interfaces/configuration-state-interface.ts index 5e9104869..73cf6d2bf 100644 --- a/src/interfaces/configuration-state-interface.ts +++ b/src/interfaces/configuration-state-interface.ts @@ -9,6 +9,7 @@ export interface ConfigurationStateIF { VUE_APP_BUSINESS_EDIT_URL: string, VUE_APP_BUSINESS_FILING_LD_CLIENT_ID: string, VUE_APP_BUSINESSES_URL: string, + VUE_APP_BUSINESS_DASH_URL: string, VUE_APP_CORPORATE_ONLINE_URL: string, VUE_APP_DASHBOARD_URL: string, VUE_APP_HOTJAR_ID: string diff --git a/src/mixins/common-mixin.ts b/src/mixins/common-mixin.ts index 1c052d0db..21cbbd3f3 100644 --- a/src/mixins/common-mixin.ts +++ b/src/mixins/common-mixin.ts @@ -1,12 +1,18 @@ import { Component, Vue } from 'vue-property-decorator' import { isEqual } from 'lodash' import omit from 'lodash.omit' +import { Getter } from 'pinia-class' +import { useConfigurationStore } from '@/stores' +import { GetFeatureFlag, navigate } from '@/utils' +import { Routes } from '@/enums' /** * Mixin that provides some useful common utilities. */ @Component({}) export default class CommonMixin extends Vue { + @Getter(useConfigurationStore) getBusinessDashUrl!: string + /** True if Vitest is running the code. */ get isVitestRunning (): boolean { return (import.meta.env.VITEST !== undefined) @@ -68,4 +74,25 @@ export default class CommonMixin extends Vue { } return true } + + /** + * Navigates to the dashboard page, optionally with a filing ID. + * @param identifier The identifier to include in the dashboard URL + * @param filingId The filing ID to include in the dashboard URL (optional, defaults to null) + */ + protected navigateToBusinessDashboard (identifier: string, filingId: number = null): void { + if (GetFeatureFlag('use-business-dashboard')) { + let dashboardUrl = `${this.getBusinessDashUrl}/${identifier}` + if (filingId !== null) { + dashboardUrl += `?filing_id=${filingId.toString()}` + } + navigate(dashboardUrl) + } else { + const route: any = { name: Routes.DASHBOARD } + if (filingId !== null) { + route.query = { filing_id: filingId.toString() } + } + this.$router.push(route).catch(() => {}) // Ignore potential navigation abort errors + } + } } diff --git a/src/resources/BreadcrumbResources.ts b/src/resources/BreadcrumbResources.ts index 4ae1c23a1..8cc447b50 100644 --- a/src/resources/BreadcrumbResources.ts +++ b/src/resources/BreadcrumbResources.ts @@ -2,6 +2,7 @@ import { BreadcrumbIF } from '@bcrs-shared-components/interfaces' import { Routes } from '@/enums' import { createPinia, setActivePinia } from 'pinia' import { useAuthenticationStore } from '@/stores' +import { GetFeatureFlag } from '@/utils' setActivePinia(createPinia()) const authenticationStore = useAuthenticationStore() @@ -44,3 +45,18 @@ export function getDigitalCredentialBreadcrumb (): BreadcrumbIF { to: { name: Routes.DIGITAL_CREDENTIALS } } } + +/** Returns the breadcrumb to the appropriate dashboard based on the feature flag. */ +export function getDashboardBreadcrumb (entityName: string, businessDashUrl: string, identifier: string): BreadcrumbIF { + if (GetFeatureFlag('use-business-dashboard')) { + return { + text: entityName || 'Unknown Name', + href: `${businessDashUrl}/${identifier}` + } + } else { + return { + text: entityName || 'Unknown Name', + to: { name: Routes.DASHBOARD } + } + } +} diff --git a/src/stores/configurationStore.ts b/src/stores/configurationStore.ts index 758b4e602..418eb9d2f 100644 --- a/src/stores/configurationStore.ts +++ b/src/stores/configurationStore.ts @@ -32,6 +32,10 @@ export const useConfigurationStore = defineStore('configuration', { return state.configuration?.VUE_APP_BUSINESSES_URL || '' }, + getBusinessDashUrl (state: ConfigurationStateIF): string { + return state.configuration?.VUE_APP_BUSINESS_DASH_URL || '' + }, + getCorporateOnlineUrl (state: ConfigurationStateIF): string { return state.configuration?.VUE_APP_CORPORATE_ONLINE_URL || '' }, diff --git a/src/utils/feature-flags.ts b/src/utils/feature-flags.ts index 3f5535c92..2f8e55ed2 100644 --- a/src/utils/feature-flags.ts +++ b/src/utils/feature-flags.ts @@ -26,7 +26,8 @@ const defaultFlagSet: LDFlagSet = { 'supported-correction-entities': [], 'supported-dissolution-entities': [], 'supported-put-back-on-entities': [], - 'supported-restoration-entities': [] + 'supported-restoration-entities': [], + 'use-business-dashboard': false } /** diff --git a/src/views/AgmExtension.vue b/src/views/AgmExtension.vue index 1e571c245..a9c3782e8 100644 --- a/src/views/AgmExtension.vue +++ b/src/views/AgmExtension.vue @@ -174,7 +174,7 @@ import AgmExtensionHelp from '@/components/AgmExtension/AgmExtensionHelp.vue' import ExtensionRequest from '@/components/AgmExtension/ExtensionRequest.vue' import { CommonMixin, DateMixin, FilingMixin, ResourceLookupMixin } from '@/mixins' import { LegalServices } from '@/services/' -import { Routes, SaveErrorReasons } from '@/enums' +import { SaveErrorReasons } from '@/enums' import { FilingCodes, FilingTypes } from '@bcrs-shared-components/enums' import { AgmExtEvalIF, ConfirmDialogType, EmptyAgmExtEval } from '@/interfaces' import { useBusinessStore, useConfigurationStore, useFilingHistoryListStore, useRootStore } from '@/stores' @@ -274,11 +274,10 @@ export default class AgmExtension extends Mixins(CommonMixin, DateMixin, FilingM // this is the id of THIS filing // it must be 0 (meaning new filing) -- we do not support resuming a draft filing + // otherwise, go back to dashboard this.filingId = +this.$route.query.filingId // number or NaN - - // if required data isn't set, go back to dashboard - if (!this.getIdentifier || this.filingId !== 0) { - this.$router.push({ name: Routes.DASHBOARD }) + if (this.filingId !== 0) { + this.navigateToBusinessDashboard(this.getIdentifier) } } @@ -384,7 +383,7 @@ export default class AgmExtension extends Mixins(CommonMixin, DateMixin, FilingM navigate(payUrl) } else { // route to dashboard with filing id parameter - this.$router.push({ name: Routes.DASHBOARD, query: { filing_id: this.filingId.toString() } }) + this.navigateToBusinessDashboard(this.getIdentifier, this.filingId) } } else { // eslint-disable-next-line no-console @@ -476,8 +475,7 @@ export default class AgmExtension extends Mixins(CommonMixin, DateMixin, FilingM // check if there are no data changes if (!this.haveChanges || force) { // route to dashboard - this.$router.push({ name: Routes.DASHBOARD }) - .catch(() => {}) // ignore error in case navigation was aborted + this.navigateToBusinessDashboard(this.getIdentifier) return } @@ -500,8 +498,7 @@ export default class AgmExtension extends Mixins(CommonMixin, DateMixin, FilingM // ignore changes this.haveChanges = false // route to dashboard - this.$router.push({ name: Routes.DASHBOARD }) - .catch(() => {}) // ignore error in case navigation was aborted + this.navigateToBusinessDashboard(this.getIdentifier) }) } diff --git a/src/views/AgmLocationChg.vue b/src/views/AgmLocationChg.vue index b4788d567..3737b8db7 100644 --- a/src/views/AgmLocationChg.vue +++ b/src/views/AgmLocationChg.vue @@ -279,7 +279,7 @@ import { ConfirmDialog, PaymentErrorDialog } from '@/components/dialogs' import { CommonMixin, DateMixin, FilingMixin, ResourceLookupMixin } from '@/mixins' import { ExpandableHelp } from '@bcrs-shared-components/expandable-help' import { LegalServices } from '@/services/' -import { Routes, SaveErrorReasons } from '@/enums' +import { SaveErrorReasons } from '@/enums' import { FilingCodes, FilingTypes } from '@bcrs-shared-components/enums' import { ConfirmDialogType } from '@/interfaces' import { useBusinessStore, useConfigurationStore, useRootStore } from '@/stores' @@ -407,11 +407,10 @@ export default class AgmLocationChg extends Mixins(CommonMixin, DateMixin, Filin // this is the id of THIS filing // it must be 0 (meaning new filing) -- we do not support resuming a draft filing + // otherwise, go back to dashboard this.filingId = +this.$route.query.filingId // number or NaN - - // if required data isn't set, go back to dashboard - if (!this.getIdentifier || this.filingId !== 0) { - this.$router.push({ name: Routes.DASHBOARD }) + if (this.filingId !== 0) { + this.navigateToBusinessDashboard(this.getIdentifier) } } @@ -501,7 +500,7 @@ export default class AgmLocationChg extends Mixins(CommonMixin, DateMixin, Filin navigate(payUrl) } else { // route to dashboard with filing id parameter - this.$router.push({ name: Routes.DASHBOARD, query: { filing_id: this.filingId.toString() } }) + this.navigateToBusinessDashboard(this.getIdentifier, this.filingId) } } else { // eslint-disable-next-line no-console @@ -583,8 +582,7 @@ export default class AgmLocationChg extends Mixins(CommonMixin, DateMixin, Filin // check if there are no data changes if (!this.haveChanges || force) { // route to dashboard - this.$router.push({ name: Routes.DASHBOARD }) - .catch(() => {}) // ignore error in case navigation was aborted + this.navigateToBusinessDashboard(this.getIdentifier) return } @@ -607,8 +605,7 @@ export default class AgmLocationChg extends Mixins(CommonMixin, DateMixin, Filin // ignore changes this.haveChanges = false // route to dashboard - this.$router.push({ name: Routes.DASHBOARD }) - .catch(() => {}) // ignore error in case navigation was aborted + this.navigateToBusinessDashboard(this.getIdentifier) }) } diff --git a/src/views/AmalgamationOut.vue b/src/views/AmalgamationOut.vue index 5a94a6c35..b2ac22bbd 100644 --- a/src/views/AmalgamationOut.vue +++ b/src/views/AmalgamationOut.vue @@ -352,7 +352,7 @@ import { ConfirmDialog, ResumeErrorDialog, SaveErrorDialog } from '@/components/dialogs' import { CommonMixin, DateMixin, FilingMixin, ResourceLookupMixin } from '@/mixins' import { EnumUtilities, LegalServices } from '@/services/' -import { EffectOfOrderTypes, FilingStatus, Routes, SaveErrorReasons } from '@/enums' +import { EffectOfOrderTypes, FilingStatus, SaveErrorReasons } from '@/enums' import { FilingCodes, FilingTypes } from '@bcrs-shared-components/enums' import { ConfirmDialogType } from '@/interfaces' import { CourtOrderPoa } from '@bcrs-shared-components/court-order-poa' @@ -515,8 +515,8 @@ export default class AmalgamationOut extends Mixins(CommonMixin, DateMixin, Fili this.filingId = +this.$route.query.filingId // number or NaN // if required data isn't set, go back to dashboard - if (!this.getIdentifier || isNaN(this.filingId)) { - this.$router.push({ name: Routes.DASHBOARD }) + if (isNaN(this.filingId)) { + this.navigateToBusinessDashboard(this.getIdentifier) } } @@ -680,6 +680,8 @@ export default class AmalgamationOut extends Mixins(CommonMixin, DateMixin, Fili onClickSaveResumeFinish (): void { // safety check if (this.filingId > 0) { + // changes were saved, so clear flag + this.haveChanges = false // changes were saved, so go to dashboard this.goToDashboard(true) } else { @@ -760,7 +762,7 @@ export default class AmalgamationOut extends Mixins(CommonMixin, DateMixin, Fili navigate(payUrl) } else { // route to dashboard with filing id parameter - this.$router.push({ name: Routes.DASHBOARD, query: { filing_id: this.filingId.toString() } }) + this.navigateToBusinessDashboard(this.getIdentifier, this.filingId) } } else { // eslint-disable-next-line no-console @@ -860,8 +862,7 @@ export default class AmalgamationOut extends Mixins(CommonMixin, DateMixin, Fili // check if there are no data changes if (!this.haveChanges || force) { // route to dashboard - this.$router.push({ name: Routes.DASHBOARD }) - .catch(() => {}) // ignore error in case navigation was aborted + this.navigateToBusinessDashboard(this.getIdentifier) return } @@ -884,8 +885,7 @@ export default class AmalgamationOut extends Mixins(CommonMixin, DateMixin, Fili // ignore changes this.haveChanges = false // route to dashboard - this.$router.push({ name: Routes.DASHBOARD }) - .catch(() => {}) // ignore error in case navigation was aborted + this.navigateToBusinessDashboard(this.getIdentifier) }) } diff --git a/src/views/AmalgamationSelection.vue b/src/views/AmalgamationSelection.vue index e04999106..ae49ca0e7 100644 --- a/src/views/AmalgamationSelection.vue +++ b/src/views/AmalgamationSelection.vue @@ -151,7 +151,7 @@ import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module' import { AmalgamationTypes, CorrectNameOptions, FilingTypes } from '@bcrs-shared-components/enums' import { AmlRoles, AmlTypes, Routes } from '@/enums' import { LegalServices } from '@/services' -import { navigate } from '@/utils' +import { GetFeatureFlag, navigate } from '@/utils' import { TechnicalErrorDialog } from '@/components/dialogs' @Component({ @@ -162,6 +162,7 @@ import { TechnicalErrorDialog } from '@/components/dialogs' export default class AmalgamationSelection extends Vue { @Getter(useAuthenticationStore) getAccountId!: string @Getter(useConfigurationStore) getCreateUrl!: string + @Getter(useConfigurationStore) getBusinessDashUrl!: string @Getter(useRootStore) getBusinessEmail!: string @Getter(useRootStore) getFullPhoneNumber!: string @Getter(useBusinessStore) getIdentifier!: string @@ -188,6 +189,11 @@ export default class AmalgamationSelection extends Vue { created (): void { // if required data isn't set, go back to dashboard if (!this.getIdentifier) { + if (GetFeatureFlag('use-business-dashboard')) { + const dashboardUIUrl = `${this.getBusinessDashUrl}/${this.getIdentifier}` + navigate(dashboardUIUrl) + return + } this.$router.push({ name: Routes.DASHBOARD }) } } diff --git a/src/views/AnnualReport.vue b/src/views/AnnualReport.vue index 27e318ae8..16fee9168 100644 --- a/src/views/AnnualReport.vue +++ b/src/views/AnnualReport.vue @@ -427,7 +427,7 @@ import { ConfirmDialog, FetchErrorDialog, PaymentErrorDialog, ResumeErrorDialog, StaffPaymentDialog } from '@/components/dialogs' import { CommonMixin, DateMixin, FilingMixin, ResourceLookupMixin } from '@/mixins' import { LegalServices } from '@/services/' -import { FilingStatus, Routes, SaveErrorReasons } from '@/enums' +import { FilingStatus, SaveErrorReasons } from '@/enums' import { FilingCodes, FilingTypes, StaffPaymentOptions } from '@bcrs-shared-components/enums' import { ConfirmDialogType, StaffPaymentIF } from '@/interfaces' import { useBusinessStore, useConfigurationStore, useRootStore } from '@/stores' @@ -915,6 +915,8 @@ export default class AnnualReport extends Mixins(CommonMixin, DateMixin, FilingM onClickSaveResumeFinish (): void { // safety check if (this.filingId > 0) { + // changes were saved, so clear flag + this.haveChanges = false // changes were saved, so go to dashboard this.goToDashboard(true) } else { @@ -988,7 +990,7 @@ export default class AnnualReport extends Mixins(CommonMixin, DateMixin, FilingM navigate(payUrl) } else { // route to dashboard with filing id parameter - this.$router.push({ name: Routes.DASHBOARD, query: { filing_id: this.filingId.toString() } }) + this.navigateToBusinessDashboard(this.getIdentifier, this.filingId) } } else { // eslint-disable-next-line no-console @@ -1155,8 +1157,7 @@ export default class AnnualReport extends Mixins(CommonMixin, DateMixin, FilingM // check if there are no data changes if (!this.haveChanges || force) { // route to dashboard - this.$router.push({ name: Routes.DASHBOARD }) - .catch(() => {}) // ignore error in case navigation was aborted + this.navigateToBusinessDashboard(this.getIdentifier) return } @@ -1179,8 +1180,7 @@ export default class AnnualReport extends Mixins(CommonMixin, DateMixin, FilingM // ignore changes this.haveChanges = false // route to dashboard - this.$router.push({ name: Routes.DASHBOARD }) - .catch(() => {}) // ignore error in case navigation was aborted + this.navigateToBusinessDashboard(this.getIdentifier) }) } diff --git a/src/views/ConsentAmalgamationOut.vue b/src/views/ConsentAmalgamationOut.vue index 2125fee7a..b194a400b 100644 --- a/src/views/ConsentAmalgamationOut.vue +++ b/src/views/ConsentAmalgamationOut.vue @@ -287,7 +287,7 @@ import { ConfirmDialog, PaymentErrorDialog, ResumeErrorDialog, SaveErrorDialog, from '@/components/dialogs' import { CommonMixin, DateMixin, FilingMixin, ResourceLookupMixin } from '@/mixins' import { EnumUtilities, LegalServices } from '@/services/' -import { EffectOfOrderTypes, FilingStatus, Routes, SaveErrorReasons } from '@/enums' +import { EffectOfOrderTypes, FilingStatus, SaveErrorReasons } from '@/enums' import { FilingCodes, FilingTypes, StaffPaymentOptions } from '@bcrs-shared-components/enums' import { ConfirmDialogType, StaffPaymentIF } from '@/interfaces' import { CourtOrderPoa } from '@bcrs-shared-components/court-order-poa' @@ -423,8 +423,8 @@ export default class ConsentAmalgamationOut extends Mixins(CommonMixin, DateMixi this.filingId = +this.$route.query.filingId // number or NaN // if required data isn't set, go back to dashboard - if (!this.getIdentifier || isNaN(this.filingId)) { - this.$router.push({ name: Routes.DASHBOARD }) + if (isNaN(this.filingId)) { + this.navigateToBusinessDashboard(this.getIdentifier) } } @@ -602,6 +602,8 @@ export default class ConsentAmalgamationOut extends Mixins(CommonMixin, DateMixi onClickSaveResumeFinish (): void { // safety check if (this.filingId > 0) { + // changes were saved, so clear flag + this.haveChanges = false // changes were saved, so go to dashboard this.goToDashboard(true) } else { @@ -686,7 +688,7 @@ export default class ConsentAmalgamationOut extends Mixins(CommonMixin, DateMixi navigate(payUrl) } else { // route to dashboard with filing id parameter - this.$router.push({ name: Routes.DASHBOARD, query: { filing_id: this.filingId.toString() } }) + this.navigateToBusinessDashboard(this.getIdentifier, this.filingId) } } else { // eslint-disable-next-line no-console @@ -802,8 +804,7 @@ export default class ConsentAmalgamationOut extends Mixins(CommonMixin, DateMixi // check if there are no data changes if (!this.haveChanges || force) { // route to dashboard - this.$router.push({ name: Routes.DASHBOARD }) - .catch(() => {}) // ignore error in case navigation was aborted + this.navigateToBusinessDashboard(this.getIdentifier) return } @@ -826,8 +827,7 @@ export default class ConsentAmalgamationOut extends Mixins(CommonMixin, DateMixi // ignore changes this.haveChanges = false // route to dashboard - this.$router.push({ name: Routes.DASHBOARD }) - .catch(() => {}) // ignore error in case navigation was aborted + this.navigateToBusinessDashboard(this.getIdentifier) }) } diff --git a/src/views/ConsentContinuationOut.vue b/src/views/ConsentContinuationOut.vue index 975ad296a..d91d9b933 100644 --- a/src/views/ConsentContinuationOut.vue +++ b/src/views/ConsentContinuationOut.vue @@ -287,7 +287,7 @@ import { ConfirmDialog, PaymentErrorDialog, ResumeErrorDialog, SaveErrorDialog, from '@/components/dialogs' import { CommonMixin, DateMixin, FilingMixin, ResourceLookupMixin } from '@/mixins' import { EnumUtilities, LegalServices } from '@/services/' -import { EffectOfOrderTypes, FilingStatus, Routes, SaveErrorReasons } from '@/enums' +import { EffectOfOrderTypes, FilingStatus, SaveErrorReasons } from '@/enums' import { FilingCodes, FilingTypes, StaffPaymentOptions } from '@bcrs-shared-components/enums' import { ConfirmDialogType, StaffPaymentIF } from '@/interfaces' import { CourtOrderPoa } from '@bcrs-shared-components/court-order-poa' @@ -423,8 +423,8 @@ export default class ConsentContinuationOut extends Mixins(CommonMixin, DateMixi this.filingId = +this.$route.query.filingId // number or NaN // if required data isn't set, go back to dashboard - if (!this.getIdentifier || isNaN(this.filingId)) { - this.$router.push({ name: Routes.DASHBOARD }) + if (isNaN(this.filingId)) { + this.navigateToBusinessDashboard(this.getIdentifier) } } @@ -602,6 +602,8 @@ export default class ConsentContinuationOut extends Mixins(CommonMixin, DateMixi onClickSaveResumeFinish (): void { // safety check if (this.filingId > 0) { + // changes were saved, so clear flag + this.haveChanges = false // changes were saved, so go to dashboard this.goToDashboard(true) } else { @@ -686,7 +688,7 @@ export default class ConsentContinuationOut extends Mixins(CommonMixin, DateMixi navigate(payUrl) } else { // route to dashboard with filing id parameter - this.$router.push({ name: Routes.DASHBOARD, query: { filing_id: this.filingId.toString() } }) + this.navigateToBusinessDashboard(this.getIdentifier, this.filingId) } } else { // eslint-disable-next-line no-console @@ -802,8 +804,7 @@ export default class ConsentContinuationOut extends Mixins(CommonMixin, DateMixi // check if there are no data changes if (!this.haveChanges || force) { // route to dashboard - this.$router.push({ name: Routes.DASHBOARD }) - .catch(() => {}) // ignore error in case navigation was aborted + this.navigateToBusinessDashboard(this.getIdentifier) return } @@ -826,8 +827,7 @@ export default class ConsentContinuationOut extends Mixins(CommonMixin, DateMixi // ignore changes this.haveChanges = false // route to dashboard - this.$router.push({ name: Routes.DASHBOARD }) - .catch(() => {}) // ignore error in case navigation was aborted + this.navigateToBusinessDashboard(this.getIdentifier) }) } diff --git a/src/views/ContinuationOut.vue b/src/views/ContinuationOut.vue index 5e66e690f..926d0fc34 100644 --- a/src/views/ContinuationOut.vue +++ b/src/views/ContinuationOut.vue @@ -308,7 +308,7 @@ import { ConfirmDialog, ResumeErrorDialog, SaveErrorDialog } from '@/components/dialogs' import { CommonMixin, DateMixin, FilingMixin, ResourceLookupMixin } from '@/mixins' import { EnumUtilities, LegalServices } from '@/services/' -import { EffectOfOrderTypes, FilingStatus, Routes, SaveErrorReasons } from '@/enums' +import { EffectOfOrderTypes, FilingStatus, SaveErrorReasons } from '@/enums' import { FilingCodes, FilingTypes } from '@bcrs-shared-components/enums' import { ConfirmDialogType } from '@/interfaces' import { CourtOrderPoa } from '@bcrs-shared-components/court-order-poa' @@ -453,8 +453,8 @@ export default class ContinuationOut extends Mixins(CommonMixin, DateMixin, Fili this.filingId = +this.$route.query.filingId // number or NaN // if required data isn't set, go back to dashboard - if (!this.getIdentifier || isNaN(this.filingId)) { - this.$router.push({ name: Routes.DASHBOARD }) + if (isNaN(this.filingId)) { + this.navigateToBusinessDashboard(this.getIdentifier) } } @@ -614,6 +614,8 @@ export default class ContinuationOut extends Mixins(CommonMixin, DateMixin, Fili onClickSaveResumeFinish (): void { // safety check if (this.filingId > 0) { + // changes were saved, so clear flag + this.haveChanges = false // changes were saved, so go to dashboard this.goToDashboard(true) } else { @@ -690,7 +692,7 @@ export default class ContinuationOut extends Mixins(CommonMixin, DateMixin, Fili navigate(payUrl) } else { // route to dashboard with filing id parameter - this.$router.push({ name: Routes.DASHBOARD, query: { filing_id: this.filingId.toString() } }) + this.navigateToBusinessDashboard(this.getIdentifier, this.filingId) } } else { // eslint-disable-next-line no-console @@ -789,8 +791,7 @@ export default class ContinuationOut extends Mixins(CommonMixin, DateMixin, Fili // check if there are no data changes if (!this.haveChanges || force) { // route to dashboard - this.$router.push({ name: Routes.DASHBOARD }) - .catch(() => {}) // ignore error in case navigation was aborted + this.navigateToBusinessDashboard(this.getIdentifier) return } @@ -813,8 +814,7 @@ export default class ContinuationOut extends Mixins(CommonMixin, DateMixin, Fili // ignore changes this.haveChanges = false // route to dashboard - this.$router.push({ name: Routes.DASHBOARD }) - .catch(() => {}) // ignore error in case navigation was aborted + this.navigateToBusinessDashboard(this.getIdentifier) }) } diff --git a/src/views/StandaloneDirectorsFiling.vue b/src/views/StandaloneDirectorsFiling.vue index 97c4e19af..6ed7a6557 100644 --- a/src/views/StandaloneDirectorsFiling.vue +++ b/src/views/StandaloneDirectorsFiling.vue @@ -376,7 +376,7 @@ import { ConfirmDialog, FetchErrorDialog, PaymentErrorDialog, ResumeErrorDialog, StaffPaymentDialog } from '@/components/dialogs' import { CommonMixin, DateMixin, FilingMixin, ResourceLookupMixin } from '@/mixins' import { LegalServices } from '@/services/' -import { Routes, SaveErrorReasons } from '@/enums' +import { SaveErrorReasons } from '@/enums' import { FilingCodes, FilingTypes, StaffPaymentOptions } from '@bcrs-shared-components/enums' import { ConfirmDialogType, StaffPaymentIF } from '@/interfaces' import { useBusinessStore, useConfigurationStore, useRootStore } from '@/stores' @@ -719,6 +719,8 @@ export default class StandaloneDirectorsFiling extends Mixins(CommonMixin, DateM onClickSaveResumeFinish (): void { // safety check if (this.filingId > 0) { + // changes were saved, so clear flag + this.haveChanges = false // changes were saved, so go to dashboard this.goToDashboard(true) } else { @@ -792,7 +794,7 @@ export default class StandaloneDirectorsFiling extends Mixins(CommonMixin, DateM navigate(payUrl) } else { // route to dashboard with filing id parameter - this.$router.push({ name: Routes.DASHBOARD, query: { filing_id: this.filingId.toString() } }) + this.navigateToBusinessDashboard(this.getIdentifier, this.filingId) } } else { // eslint-disable-next-line no-console @@ -900,11 +902,9 @@ export default class StandaloneDirectorsFiling extends Mixins(CommonMixin, DateM // check if there are no data changes if (!this.haveChanges || force) { // route to dashboard - this.$router.push({ name: Routes.DASHBOARD }) - .catch(() => {}) // ignore error in case navigation was aborted + this.navigateToBusinessDashboard(this.getIdentifier) return } - // open confirmation dialog and wait for response this.$refs.confirm.open( 'Unsaved Changes', @@ -924,8 +924,7 @@ export default class StandaloneDirectorsFiling extends Mixins(CommonMixin, DateM // ignore changes this.haveChanges = false // route to dashboard - this.$router.push({ name: Routes.DASHBOARD }) - .catch(() => {}) // ignore error in case navigation was aborted + this.navigateToBusinessDashboard(this.getIdentifier) }) } diff --git a/src/views/StandaloneOfficeAddressFiling.vue b/src/views/StandaloneOfficeAddressFiling.vue index 977350184..b71aba7de 100644 --- a/src/views/StandaloneOfficeAddressFiling.vue +++ b/src/views/StandaloneOfficeAddressFiling.vue @@ -250,7 +250,7 @@ import { ConfirmDialog, FetchErrorDialog, PaymentErrorDialog, ResumeErrorDialog, StaffPaymentDialog } from '@/components/dialogs' import { CommonMixin, DateMixin, FilingMixin, ResourceLookupMixin } from '@/mixins' import { LegalServices } from '@/services/' -import { Routes, SaveErrorReasons } from '@/enums' +import { SaveErrorReasons } from '@/enums' import { FilingCodes, FilingTypes, StaffPaymentOptions } from '@bcrs-shared-components/enums' import { ConfirmDialogType, StaffPaymentIF } from '@/interfaces' import { useBusinessStore, useConfigurationStore, useRootStore } from '@/stores' @@ -580,6 +580,8 @@ export default class StandaloneOfficeAddressFiling extends Mixins(CommonMixin, D onClickSaveResumeFinish (): void { // safety check if (this.filingId > 0) { + // changes were saved, so clear flag + this.haveChanges = false // changes were saved, so go to dashboard this.goToDashboard(true) } else { @@ -653,7 +655,7 @@ export default class StandaloneOfficeAddressFiling extends Mixins(CommonMixin, D navigate(payUrl) } else { // route to dashboard with filing id parameter - this.$router.push({ name: Routes.DASHBOARD, query: { filing_id: this.filingId.toString() } }) + this.navigateToBusinessDashboard(this.getIdentifier, this.filingId) } } else { // eslint-disable-next-line no-console @@ -776,8 +778,7 @@ export default class StandaloneOfficeAddressFiling extends Mixins(CommonMixin, D // check if there are no data changes if (!this.haveChanges || force) { // route to dashboard - this.$router.push({ name: Routes.DASHBOARD }) - .catch(() => {}) // ignore error in case navigation was aborted + this.navigateToBusinessDashboard(this.getIdentifier) return } @@ -800,8 +801,7 @@ export default class StandaloneOfficeAddressFiling extends Mixins(CommonMixin, D // ignore changes this.haveChanges = false // route to dashboard - this.$router.push({ name: Routes.DASHBOARD }) - .catch(() => {}) // ignore error in case navigation was aborted + this.navigateToBusinessDashboard(this.getIdentifier) }) } diff --git a/tests/unit/AgmExtension.spec.ts b/tests/unit/AgmExtension.spec.ts index 131c21e5d..bbbd8cb5a 100644 --- a/tests/unit/AgmExtension.spec.ts +++ b/tests/unit/AgmExtension.spec.ts @@ -10,6 +10,7 @@ import { CorpTypeCd } from '@/enums' import { FilingTypes } from '@bcrs-shared-components/enums' import { LegalServices } from '@/services' import flushPromises from 'flush-promises' +import * as utils from '@/utils' // components import AgmExtension from '@/views/AgmExtension.vue' @@ -73,6 +74,8 @@ describe('AGM Extension view', () => { }) afterEach(() => { + // restore feature flag + vi.restoreAllMocks() wrapper.destroy() }) @@ -241,4 +244,45 @@ describe('AGM Extension view', () => { // verify redirection to dashboard expect(wrapper.vm.$route.name).toBe('dashboard') }) + + it('navigates to new business dashboard when feature flag is true', async () => { + // mock hasPendingTasks() + LegalServices.hasPendingTasks = vi.fn().mockResolvedValue(false) + + // mock createFiling() + LegalServices.createFiling = vi.fn().mockResolvedValue({ + agmExtension: {}, + business: {}, + header: { + filingId: 1123, + isPaymentActionRequired: false + } + }) + + // simulate eligible data and valid component + wrapper.setData({ + data: { isEligible: true }, + extensionRequestValid: true + }) + + // simulate valid certify data and component + wrapper.setData({ certifiedBy: 'Full Name', isCertified: true, certifyFormValid: true }) + + // verify navigate to the new business dashboard when FF is true + vi.spyOn(utils, 'GetFeatureFlag').mockImplementation(flag => { + if (flag === 'use-business-dashboard') return true + }) + // Mock the navigate function + const mockNavigate = vi.spyOn(utils, 'navigate').mockImplementation(() => { + return true + }) + + await wrapper.find('#file-pay-btn').trigger('click') + + // wait for save to complete and everything to update + await flushPromises() + + const expectedUrl = '/BC1234567?filing_id=1123' + expect(mockNavigate).toHaveBeenCalledWith(expectedUrl) + }) }) diff --git a/tests/unit/AnnualReport.spec.ts b/tests/unit/AnnualReport.spec.ts index 95747ea56..d22474548 100644 --- a/tests/unit/AnnualReport.spec.ts +++ b/tests/unit/AnnualReport.spec.ts @@ -18,6 +18,7 @@ import ArDate from '@/components/AnnualReport/ARDate.vue' import { Certify, OfficeAddresses, SummaryDirectors, SummaryOfficeAddresses } from '@/components/common' import { BusinessConfigCp } from '@/resources/CP' import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module' +import * as utils from '@/utils' // suppress various warnings: // - "Unknown custom element " warnings @@ -1210,6 +1211,8 @@ describe('Annual Report - Part 4 - Saving', () => { }) afterEach(() => { + // restore feature flag + vi.restoreAllMocks() sinon.restore() wrapper.destroy() }) @@ -1279,6 +1282,67 @@ describe('Annual Report - Part 4 - Saving', () => { expect(vm.$route.name).toBe('dashboard') }) + it('saves a filing and navigates to new business Dashboard when the FF is true', async () => { + // make sure form is validated + await wrapper.setData({ + agmDateValid: true, + addressesFormValid: true, + directorFormValid: true, + certifyFormValid: true + }) + + // stub address data + await wrapper.setData({ + addresses: { + registeredOffice: { + deliveryAddress: {}, + mailingAddress: {} + }, + recordsOffice: { + deliveryAddress: {}, + mailingAddress: {} + } + } + }) + // verify navigate to the new business dashboard when FF is true + vi.spyOn(utils, 'GetFeatureFlag').mockImplementation(flag => { + if (flag === 'use-business-dashboard') return true + }) + // Mock the navigate function + const mockNavigate = vi.spyOn(utils, 'navigate').mockImplementation(() => { + return true + }) + await vm.onClickSaveResume() + const expectedUrl = '/CP0001191' + expect(mockNavigate).toHaveBeenCalledWith(expectedUrl) + }) + + it('navigates to new business Dashboard with FF being true when the Cancel button is clicked', async () => { + // make sure form is validated + await wrapper.setData({ + agmDateValid: true, + addressesFormValid: true, + directorFormValid: true, + certifyFormValid: true + }) + // verify navigate to the new business dashboard when FF is true + vi.spyOn(utils, 'GetFeatureFlag').mockImplementation(flag => { + if (flag === 'use-business-dashboard') return true + }) + // Mock the navigate function + const mockNavigate = vi.spyOn(utils, 'navigate').mockImplementation(() => { + return true + }) + // click the Cancel button + // await wrapper.find('#ar-cancel-btn').trigger('click') + // work-around because click trigger isn't working + await vm.goToDashboard() + + // verify navigate to the new Dashboard URL + const expectedUrl = '/CP0001191' + expect(mockNavigate).toHaveBeenCalledWith(expectedUrl) + }) + it('routes to Dashboard URL when the Cancel button is clicked', async () => { // make sure form is validated await wrapper.setData({ diff --git a/tests/unit/StandaloneDirectorsFiling.spec.ts b/tests/unit/StandaloneDirectorsFiling.spec.ts index 7d882a045..4d51266b4 100644 --- a/tests/unit/StandaloneDirectorsFiling.spec.ts +++ b/tests/unit/StandaloneDirectorsFiling.spec.ts @@ -18,6 +18,7 @@ import mockRouter from './mockRouter' import { BusinessConfigCp } from '@/resources/CP' import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module' import { FilingCodes } from '@bcrs-shared-components/enums' +import * as utils from '@/utils' // suppress various warnings: // - "Unknown custom element " warnings @@ -951,6 +952,8 @@ describe('Standalone Directors Filing - Part 3B - Submitting filing that doesn\' }) afterEach(() => { + // restore feature flag + vi.restoreAllMocks() sinon.restore() }) @@ -987,6 +990,40 @@ describe('Standalone Directors Filing - Part 3B - Submitting filing that doesn\' wrapper.destroy() }) + + it('When FF is true, saves a new filing and navigates to new Dashboard when ' + + 'this is a new filing and the File & Pay button is clicked', async () => { + const localVue = createLocalVue() + localVue.use(VueRouter) + const router = mockRouter.mock() + router.push({ name: 'standalone-directors', query: { filingId: '0' } }) // new filing id + + const wrapper = shallowMount(StandaloneDirectorsFiling, { localVue, router }) + const vm: any = wrapper.vm as any + + // make sure form is validated + await wrapper.setData({ + codDateValid: true, + inFilingReview: true, + directorFormValid: true, + certifyFormValid: true + }) + // verify navigate to the new business dashboard when FF is true + vi.spyOn(utils, 'GetFeatureFlag').mockImplementation(flag => { + if (flag === 'use-business-dashboard') return true + }) + // Mock the navigate function + const mockNavigate = vi.spyOn(utils, 'navigate').mockImplementation(() => { + return true + }) + rootStore.setFilingData([{} as any]) // dummy data + await vm.onClickFilePay() + + const expectedUrl = '/CP0001191?filing_id=123' + expect(mockNavigate).toHaveBeenCalledWith(expectedUrl) + + wrapper.destroy() + }) }) describe('Standalone Directors Filing - Part 4 - Saving', () => { diff --git a/tests/unit/StandaloneOfficeAddressFiling.spec.ts b/tests/unit/StandaloneOfficeAddressFiling.spec.ts index c0a490d58..d89b6ab4b 100644 --- a/tests/unit/StandaloneOfficeAddressFiling.spec.ts +++ b/tests/unit/StandaloneOfficeAddressFiling.spec.ts @@ -15,6 +15,7 @@ import VueRouter from 'vue-router' import mockRouter from './mockRouter' import { BusinessConfigBen } from '@/resources/BEN' import { CorpTypeCd } from '@bcrs-shared-components/corp-type-module' +import * as utils from '@/utils' // suppress various warnings: // - "Unknown custom element " warnings @@ -676,6 +677,8 @@ describe('Standalone Office Address Filing - Part 3 - Submitting', () => { }) afterEach(() => { + // restore feature flag + vi.restoreAllMocks() sinon.restore() }) @@ -810,6 +813,69 @@ describe('Standalone Office Address Filing - Part 3 - Submitting', () => { wrapper.destroy() }) + + it('updates an existing filing and navigates to the new dashboard when this is a draft filing ' + + 'and the File & Pay button is clicked and payment action is not required', async () => { + // set necessary session variables + sessionStorage.setItem('BASE_URL', 'https://base.url/') + + // create local Vue and mock router + const localVue = createLocalVue() + localVue.use(VueRouter) + const router = mockRouter.mock() + router.push({ name: 'standalone-addresses', query: { filingId: '123' } }) // existing filing id + + const wrapper = mount(StandaloneOfficeAddressFiling, { + localVue, + router, + stubs: { + OfficeAddresses: true, + Certify: true, + Affix: true, + SbcFeeSummary: true, + ConfirmDialog: true, + PaymentErrorDialog: true, + ResumeErrorDialog: true, + SaveErrorDialog: true + }, + vuetify + }) + const vm: any = wrapper.vm + + // make sure form is validated + await wrapper.setData({ + certifyFormValid: true, + addressesFormValid: true + }) + rootStore.setFilingData([{} as any]) // dummy data + + // make sure a fee is required + vm.totalFee = 100 + + // FUTURE: verify that draft filing was fetched + + const button = wrapper.find('#coa-file-pay-btn') + await Vue.nextTick() + expect(button.attributes('disabled')).toBeUndefined() + + // verify navigate to the new business dashboard when FF is true + vi.spyOn(utils, 'GetFeatureFlag').mockImplementation(flag => { + if (flag === 'use-business-dashboard') return true + }) + // Mock the navigate function + const mockNavigate = vi.spyOn(utils, 'navigate').mockImplementation(() => { + return true + }) + // click the File & Pay button + await button.trigger('click') + await flushPromises() // wait for save to complete and everything to update + + // verify navigate to the new Dashboard URL + const expectedUrl = '/CP0001191?filing_id=123' + expect(mockNavigate).toHaveBeenCalledWith(expectedUrl) + + wrapper.destroy() + }) }) describe('Standalone Office Address Filing - Part 3B - Submitting (BCOMP)', () => {