Skip to content

Commit

Permalink
All - UI: add sbc web messenger (#450)
Browse files Browse the repository at this point in the history
* sbc messenger draft

* fix

* fix

* fix

* working

* switch to middleware

* fix

* fix

* add msg config to all apps

* fix

* fix

* add return if missing config

* update vaults env
  • Loading branch information
deetz99 authored Jan 13, 2025
1 parent 5cfa7b4 commit 8d1383f
Show file tree
Hide file tree
Showing 18 changed files with 147 additions and 7 deletions.
4 changes: 4 additions & 0 deletions strr-base-web/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ export default defineAppConfig({
hrefRtcKey: ''
}
}
},
sbcWebMsg: {
enable: false,
allowedRoutes: undefined
}
},
ui: {
Expand Down
70 changes: 70 additions & 0 deletions strr-base-web/app/middleware/enable-sbc-web-messenger.global.ts
Original file line number Diff line number Diff line change
@@ -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()
}
}
})
22 changes: 22 additions & 0 deletions strr-base-web/app/types/strr-base-app-config.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ declare module 'nuxt/schema' {
},
feeWidget?: {
itemLabelTooltip: Record<string, { i18nkey: string, hrefRtcKey?: keyof PublicRuntimeConfig }> // typeCode
},
sbcWebMsg: {
enable: boolean,
allowedRoutes: string[] | undefined
}
}
}
Expand All @@ -37,6 +41,24 @@ declare module 'nuxt/schema' {
},
feeWidget?: {
itemLabelTooltip: Record<string, { i18nkey: string, hrefRtcKey?: keyof PublicRuntimeConfig }> // typeCode
},
sbcWebMsg: {
enable: boolean,
allowedRoutes: string[] | undefined
}
}
}
}

declare global {
interface Window {
_genesysJs: string
Genesys: {
q?: any[]
t?: number
c?: {
environment: string
deploymentId: string
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion strr-base-web/nuxt.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions strr-host-pm-web/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
4 changes: 4 additions & 0 deletions strr-host-pm-web/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ export default defineAppConfig({
hrefRtcKey: 'hostFeesUrl'
}
})
},
sbcWebMsg: {
enable: true,
allowedRoutes: ['application', 'dashboard']
}
},
ui: {}
Expand Down
4 changes: 2 additions & 2 deletions strr-host-pm-web/app/locales/en-CA.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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.',
Expand Down
1 change: 0 additions & 1 deletion strr-host-pm-web/app/pages/application.vue
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
<script setup lang="ts">
import { ConnectStepper, FormReview } from '#components'
const { t } = useI18n()
const route = useRoute()
const localePath = useLocalePath()
Expand Down
5 changes: 5 additions & 0 deletions strr-host-pm-web/devops/vaults.env
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ NUXT_HOST_ACC_ACT_SUMMARY="https://www2.gov.bc.ca/gov/content/housing-tenancy/sh
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="op://webchat/$APP_ENV/base/GENESYS_URL"
NUXT_GENESYS_ENVIRONMENT_KEY="op://webchat/$APP_ENV/base/GENESYS_ENV"
NUXT_GENESYS_DEPLOYMENT_KEY="op://webchat/$APP_ENV/strr/GENESYS_ID"

# vaults api
NUXT_PAY_API_URL="op://API/$APP_ENV/pay-api/PAY_API_URL"
NUXT_PAY_API_VERSION="op://API/$APP_ENV/pay-api/PAY_API_VERSION"
Expand Down
2 changes: 1 addition & 1 deletion strr-host-pm-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "strr-host-pm-web",
"private": true,
"type": "module",
"version": "0.0.34",
"version": "0.0.35",
"scripts": {
"build-check": "nuxt build",
"build": "nuxt generate",
Expand Down
5 changes: 5 additions & 0 deletions strr-platform-web/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,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_PLATFORMS_LEARN_MORE_URL="https://www2.gov.bc.ca/gov/content/housing-tenancy/short-term-rentals/registry/platform-registration/platform-requirements#localgovernmenttakedown"

# 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"
Expand Down
4 changes: 4 additions & 0 deletions strr-platform-web/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export default defineAppConfig({
idps: () => ['bceid', 'bcsc'] // function required to overwrite default value, will merge if no function
}
}
},
sbcWebMsg: {
enable: true,
allowedRoutes: ['application', 'dashboard']
}
},
ui: {
Expand Down
5 changes: 5 additions & 0 deletions strr-platform-web/devops/vaults.env
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,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_PLATFORMS_LEARN_MORE_URL="https://www2.gov.bc.ca/gov/content/housing-tenancy/short-term-rentals/registry/platform-registration/platform-requirements#localgovernmenttakedown"

# vaults sbc/genesys messenger
NUXT_GENESYS_URL="op://webchat/$APP_ENV/base/GENESYS_URL"
NUXT_GENESYS_ENVIRONMENT_KEY="op://webchat/$APP_ENV/base/GENESYS_ENV"
NUXT_GENESYS_DEPLOYMENT_KEY="op://webchat/$APP_ENV/strr/GENESYS_ID"

# vaults api
NUXT_PAY_API_URL="op://API/$APP_ENV/pay-api/PAY_API_URL"
NUXT_PAY_API_VERSION="op://API/$APP_ENV/pay-api/PAY_API_VERSION"
Expand Down
2 changes: 1 addition & 1 deletion strr-platform-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "strr-platform-web",
"private": true,
"type": "module",
"version": "0.0.37",
"version": "0.0.38",
"scripts": {
"build-check": "nuxt build",
"build": "nuxt generate",
Expand Down
5 changes: 5 additions & 0 deletions strr-strata-web/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,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_DOES_PR_APPLY_URL="https://www2.gov.bc.ca/gov/content/housing-tenancy/short-term-rentals/principal-residence-requirement#PRapplies"

# 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"
Expand Down
4 changes: 4 additions & 0 deletions strr-strata-web/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export default defineAppConfig({
idps: () => ['bcsc', 'bceid'] // function required to overwrite default value, will merge if no function
}
}
},
sbcWebMsg: {
enable: true,
allowedRoutes: ['application', 'dashboard']
}
},
ui: {}
Expand Down
5 changes: 5 additions & 0 deletions strr-strata-web/devops/vaults.env
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,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_DOES_PR_APPLY_URL="https://www2.gov.bc.ca/gov/content/housing-tenancy/short-term-rentals/principal-residence-requirement#PRapplies"

# vaults sbc/genesys messenger
NUXT_GENESYS_URL="op://webchat/$APP_ENV/base/GENESYS_URL"
NUXT_GENESYS_ENVIRONMENT_KEY="op://webchat/$APP_ENV/base/GENESYS_ENV"
NUXT_GENESYS_DEPLOYMENT_KEY="op://webchat/$APP_ENV/strr/GENESYS_ID"

# vaults api
NUXT_PAY_API_URL="op://API/$APP_ENV/pay-api/PAY_API_URL"
NUXT_PAY_API_VERSION="op://API/$APP_ENV/pay-api/PAY_API_VERSION"
Expand Down
2 changes: 1 addition & 1 deletion strr-strata-web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "strr-strata-web",
"private": true,
"type": "module",
"version": "0.0.38",
"version": "0.0.39",
"scripts": {
"build-check": "nuxt build",
"build": "nuxt generate",
Expand Down

0 comments on commit 8d1383f

Please sign in to comment.