diff --git a/strr-base-web/app/app.config.ts b/strr-base-web/app/app.config.ts index 9b17c8d3e..c9db2f6f0 100644 --- a/strr-base-web/app/app.config.ts +++ b/strr-base-web/app/app.config.ts @@ -20,6 +20,10 @@ export default defineAppConfig({ hrefRtcKey: '' } } + }, + sbcWebMsg: { + enable: false, + allowedRoutes: undefined } }, ui: { diff --git a/strr-base-web/app/middleware/enable-sbc-web-messenger.global.ts b/strr-base-web/app/middleware/enable-sbc-web-messenger.global.ts new file mode 100644 index 000000000..8cec61826 --- /dev/null +++ b/strr-base-web/app/middleware/enable-sbc-web-messenger.global.ts @@ -0,0 +1,70 @@ +export default defineNuxtRouteMiddleware(async (to) => { + const { ldClient, getStoredFlag } = useConnectLaunchdarklyStore() + await ldClient?.waitUntilReady() + const enableSbcWebMsg = getStoredFlag('enable-sbc-web-messenger') + const msgConfig = useAppConfig().strrBaseLayer.sbcWebMsg + + if (ldClient && enableSbcWebMsg && msgConfig.enable) { + const rtc = useRuntimeConfig().public + const genesysUrl = rtc.genesysUrl as string + const environmentKey = rtc.genesysEnvironmentKey as string + const deploymentKey = rtc.genesysDeploymentKey as string + + const initWebMsg = () => { + if (!genesysUrl || !environmentKey || !deploymentKey) { + console.warn('Missing Sbc Web Messenger config, aborting setup.') + return + } + + window._genesysJs = 'Genesys' + window.Genesys = window.Genesys || function (...args: any) { + (window.Genesys.q = window.Genesys.q || []).push(args) + } + window.Genesys.t = new Date().getTime() + window.Genesys.c = { + environment: environmentKey, + deploymentId: deploymentKey + } + + const script = document.createElement('script') + script.async = true + script.src = genesysUrl + document.head.appendChild(script) + localStorage.removeItem('_actmu') + } + + // TODO: how to remove ? + // const removeWebMsg = () => { + // const scripts = document.querySelectorAll('script[src^="https://apps.cac1.pure.cloud"]') + // scripts.forEach(script => script.remove()) + + // const el1 = document.getElementById('genesys-thirdparty') + // if (el1) { + // el1.remove() + // } + + // const el2 = document.getElementById('genesys-messenger') + // if (el2) { + // el2.remove() + // } + + // delete window.Genesys + // delete window._genesysJs + // localStorage.removeItem('_actmu') + // } + + const isRouteAllowed = (path: string): boolean => { + if (msgConfig.allowedRoutes === undefined) { + return true + } + return msgConfig.allowedRoutes.some(route => path.includes(route)) + } + + if (isRouteAllowed(to.path)) { + initWebMsg() + } else { + // TODO: how to remove ? + // removeWebMsg() + } + } +}) diff --git a/strr-base-web/app/types/strr-base-app-config.d.ts b/strr-base-web/app/types/strr-base-app-config.d.ts index 8d74c326c..5a0ee348e 100644 --- a/strr-base-web/app/types/strr-base-app-config.d.ts +++ b/strr-base-web/app/types/strr-base-app-config.d.ts @@ -15,6 +15,10 @@ declare module 'nuxt/schema' { }, feeWidget?: { itemLabelTooltip: Record // typeCode + }, + sbcWebMsg: { + enable: boolean, + allowedRoutes: string[] | undefined } } } @@ -37,6 +41,24 @@ declare module 'nuxt/schema' { }, feeWidget?: { itemLabelTooltip: Record // typeCode + }, + sbcWebMsg: { + enable: boolean, + allowedRoutes: string[] | undefined + } + } + } +} + +declare global { + interface Window { + _genesysJs: string + Genesys: { + q?: any[] + t?: number + c?: { + environment: string + deploymentId: string } } } diff --git a/strr-base-web/nuxt.config.ts b/strr-base-web/nuxt.config.ts index 958fdfea3..a2e5aecf8 100644 --- a/strr-base-web/nuxt.config.ts +++ b/strr-base-web/nuxt.config.ts @@ -90,7 +90,10 @@ export default defineNuxtConfig({ version: `STRR Base UI v${process.env.npm_package_version}`, housingStrrUrl: process.env.NUXT_REGISTRY_HOME_URL, // TODO: update to NUXT_HOUSING_STRR_URL once we get the housing strr url set declineTosRedirectUrl: process.env.NUXT_DECLINE_TOS_REDIRECT_URL, - bcGovStrrUrl: process.env.NUXT_BCGOV_STRR_URL + bcGovStrrUrl: process.env.NUXT_BCGOV_STRR_URL, + genesysUrl: process.env.NUXT_GENESYS_URL, + genesysEnvironmentKey: process.env.NUXT_GENESYS_ENVIRONMENT_KEY, + genesysDeploymentKey: process.env.NUXT_GENESYS_DEPLOYMENT_KEY // set by layer - still required in .env // keycloakAuthUrl - NUXT_KEYCLOAK_AUTH_URL // keycloakClientId - NUXT_KEYCLOAK_CLIENTID diff --git a/strr-host-pm-web/.env.example b/strr-host-pm-web/.env.example index 9fc573b3f..1264712f2 100644 --- a/strr-host-pm-web/.env.example +++ b/strr-host-pm-web/.env.example @@ -29,6 +29,11 @@ NUXT_BCGOV_STRR_URL="https://www.gov.bc.ca/STRRegistry" NUXT_DECLINE_TOS_REDIRECT_URL="https://www2.gov.bc.ca/gov/content/housing-tenancy/short-term-rentals/registry" NUXT_HOST_FEES_URL="https://www2.gov.bc.ca/gov/content/housing-tenancy/short-term-rentals/registry/host-registration#fees" +# vaults sbc/genesys messenger +NUXT_GENESYS_URL="" +NUXT_GENESYS_ENVIRONMENT_KEY="" +NUXT_GENESYS_DEPLOYMENT_KEY="" + #vaults keycloak NUXT_KEYCLOAK_AUTH_URL="https://dev.loginproxy.gov.bc.ca/auth" NUXT_KEYCLOAK_REALM="bcregistry" diff --git a/strr-host-pm-web/app/app.config.ts b/strr-host-pm-web/app/app.config.ts index c8be20213..68719b593 100644 --- a/strr-host-pm-web/app/app.config.ts +++ b/strr-host-pm-web/app/app.config.ts @@ -55,6 +55,10 @@ export default defineAppConfig({ hrefRtcKey: 'hostFeesUrl' } }) + }, + sbcWebMsg: { + enable: true, + allowedRoutes: ['application', 'dashboard'] } }, ui: {} diff --git a/strr-host-pm-web/app/locales/en-CA.ts b/strr-host-pm-web/app/locales/en-CA.ts index 0e0460aa9..98b57e4be 100644 --- a/strr-host-pm-web/app/locales/en-CA.ts +++ b/strr-host-pm-web/app/locales/en-CA.ts @@ -5,8 +5,8 @@ export default { title: 'Your property is in a location where the principal residence requirement applies.' }, straaExempt: { - title: '{boldStart}Registration Not Required:{boldEnd} This address appears to be located on First Nations land and is therefore exempt from the {italicStart}Short-term Rental Accommodations Act{italicEnd}. You do not need to register a short-term rental at this address.', - note: 'Please check with the First Nations for any applicable Short-Term Rental regulations.' + title: '{boldStart}Registration Not Required:{boldEnd} This address appears to be located on First Nation land and is therefore exempt from the {italicStart}Short-term Rental Accommodations Act{italicEnd}. You do not need to register a short-term rental at this address.', + note: 'Please check with the First Nation for any applicable Short-Term Rental regulations.' }, strProhibited: { title: 'Some types of short-term rentals are not permitted by your local government.', diff --git a/strr-host-pm-web/app/pages/application.vue b/strr-host-pm-web/app/pages/application.vue index 28ea27a46..487f615ff 100644 --- a/strr-host-pm-web/app/pages/application.vue +++ b/strr-host-pm-web/app/pages/application.vue @@ -1,6 +1,5 @@