diff --git a/package-lock.json b/package-lock.json index aa7cf0e1e..c1882dd47 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "business-create-ui", - "version": "4.5.8", + "version": "4.5.9", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "business-create-ui", - "version": "4.5.8", + "version": "4.5.9", "dependencies": { "@babel/compat-data": "^7.19.1", "@bcrs-shared-components/breadcrumb": "2.1.4", diff --git a/package.json b/package.json index 3a7a1be59..8e2143d67 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "business-create-ui", - "version": "4.5.8", + "version": "4.5.9", "private": true, "appName": "Create UI", "sbcName": "SBC Common Components", diff --git a/src/App.vue b/src/App.vue index 1a09aede0..5d70aa64f 100644 --- a/src/App.vue +++ b/src/App.vue @@ -239,6 +239,7 @@ export default class App extends Vue { @Getter getFilingName!: FilingNames @Getter isDissolutionFiling!: boolean @Getter isRestorationFiling!: boolean + @Getter isIncorporationFiling!: boolean @Getter getSteps!: Array @Getter isSbcStaff!: boolean @Getter getFilingSubtitle!: string @@ -417,6 +418,12 @@ export default class App extends Vue { return !this.$route.meta.noStepper } + /** The current domain. */ + get domain (): string { + // remove possible leading period + return window.location.hostname.replace(/^\./, '') + } + /** Helper to check is the current route matches */ private isRouteName (routeName: RouteNames): boolean { return (this.$route.name === routeName) @@ -543,12 +550,11 @@ export default class App extends Vue { /** Called to save or delete "hide survey" cookie. */ protected updateSurveyCookie (doNotShow: boolean): void { - const domain = window.location.hostname if (doNotShow) { // hide survey for 30 days - Cookies.set(this.IA_SURVEY_KEY, 'do-not-show', { domain, expires: 30 }) + Cookies.set(this.IA_SURVEY_KEY, 'do-not-show', { domain: this.domain, expires: 30 }) } else { - Cookies.remove(this.IA_SURVEY_KEY, { domain }) + Cookies.remove(this.IA_SURVEY_KEY, { domain: this.domain }) } } @@ -588,16 +594,6 @@ export default class App extends Vue { // reset errors in case this method is invoked more than once (ie, retry) this.resetFlags() - // check if IA Survey ID is configured - const iaSurveyId = sessionStorage.getItem('IA_SURVEY_ID') - if (iaSurveyId) { - // check for cookie; if it doesn't exist then show survey dialog - // NB: cookie is auto-removed when it expires - const domain = window.location.hostname - const cookie = Cookies.get(this.IA_SURVEY_KEY, { domain }) - if (!cookie) this.filingSurveyDialog = true - } - // check that current route matches a supported filing type const supportedFilings = await GetFeatureFlag('supported-filings') if (!supportedFilings?.includes(this.$route.meta.filingType)) { @@ -1106,6 +1102,19 @@ export default class App extends Vue { // fetch the data await this.fetchData() + + // show survey dialog... + // - if this is an Incorporation Application filing + // - if the IA Survey ID is configured + // - if the cookie doesn't exist (eg, never set, or expired) + if (this.isIncorporationFiling) { + if (sessionStorage.getItem('IA_SURVEY_ID')) { + const cookie = Cookies.get(this.IA_SURVEY_KEY, { domain: this.domain }) + if (!cookie) { + this.filingSurveyDialog = true + } + } + } } } diff --git a/src/utils/FetchConfig.ts b/src/utils/FetchConfig.ts index 8ee846e31..3754fd2b5 100644 --- a/src/utils/FetchConfig.ts +++ b/src/utils/FetchConfig.ts @@ -95,7 +95,8 @@ export async function FetchConfig (): Promise { } const iaSurveyId: string = response.data.IA_SURVEY_ID - sessionStorage.setItem('IA_SURVEY_ID', iaSurveyId) + // NB: assign fallback otherwise sessionStorage will store string "undefined" + sessionStorage.setItem('IA_SURVEY_ID', iaSurveyId || '') const hotjarId: string = response.data.HOTJAR_ID; (window).hotjarId = hotjarId