Skip to content

Commit

Permalink
feat(web): Directorate of immigration chat changes (#16418)
Browse files Browse the repository at this point in the history
* Remove auth and change what english chat is

* Add feature flag

---------

Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
RunarVestmann and kodiakhq[bot] authored Oct 16, 2024
1 parent a74f1fd commit d3ccc15
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 28 deletions.
32 changes: 17 additions & 15 deletions apps/web/components/ChatPanel/WatsonChatPanel/WatsonChatPanel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import { SUBMIT_WATSON_ASSISTANT_CHAT_FEEDBACK } from '@island.is/web/screens/qu
import { ChatBubble } from '../ChatBubble'
import { WatsonChatPanelProps } from '../types'
import type { WatsonInstance, WatsonInstanceEvent } from './types'
import { onAuthenticatedWatsonAssistantChatLoad } from './utils'
import * as styles from './WatsonChatPanel.css'

const chatLog: WatsonInstanceEvent[] = []
Expand Down Expand Up @@ -295,6 +294,20 @@ export const WatsonChatPanel = (props: WatsonChatPanelProps) => {
const namespaceValue = namespace?.[namespaceKey] ?? {}
const { cssVariables, ...languagePack } = namespaceValue

const replaceDirectorateOfImmigrationWebChatWithAI = Boolean(
namespace?.replaceDirectorateOfImmigrationWebChatWithAI,
)

const propsCopy = { ...props }

if (
!replaceDirectorateOfImmigrationWebChatWithAI &&
props.integrationID === '9e320784-ad44-4da9-9eb3-f305057a196a'
) {
propsCopy.integrationID = '89a03e83-5c73-4642-b5ba-cd3771ceca54'
propsCopy.serviceInstanceID = 'bc3d8312-d862-4750-b8bf-529db282050a'
}

let scriptElement: HTMLScriptElement | null = null

const queryParam = new URLSearchParams(window.location.search).get('wa_lid')
Expand Down Expand Up @@ -322,7 +335,7 @@ export const WatsonChatPanel = (props: WatsonChatPanelProps) => {
serviceDesk: {
skipConnectAgentCard: true,
},
...props,
...propsCopy,
onLoad: (instance) => {
watsonInstance.current = instance
if (Object.keys(cssVariables).length > 0) {
Expand All @@ -334,7 +347,8 @@ export const WatsonChatPanel = (props: WatsonChatPanelProps) => {

if (
// Útlendingastofnun
props.integrationID !== '89a03e83-5c73-4642-b5ba-cd3771ceca54'
props.integrationID !== '89a03e83-5c73-4642-b5ba-cd3771ceca54' &&
props.integrationID !== '9e320784-ad44-4da9-9eb3-f305057a196a'
) {
// Keep the chat log in memory
instance.on({
Expand Down Expand Up @@ -370,18 +384,6 @@ export const WatsonChatPanel = (props: WatsonChatPanelProps) => {
})
}

if (
// Askur - Útlendingastofnun
props.integrationID === '89a03e83-5c73-4642-b5ba-cd3771ceca54'
) {
onAuthenticatedWatsonAssistantChatLoad(
instance,
namespace,
activeLocale,
'directorateOfImmigration',
)
}

if (onLoad) {
onLoad(instance)
}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/components/ChatPanel/WatsonChatPanel/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Locale } from '@island.is/shared/types'
import { uuid } from 'uuidv4'
import { ApolloClient, NormalizedCacheObject } from '@apollo/client'

import { Locale } from '@island.is/shared/types'
import { storageFactory } from '@island.is/shared/utils'
import initApollo from '@island.is/web/graphql/client'
import {
Expand Down
7 changes: 6 additions & 1 deletion apps/web/components/ChatPanel/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ export type WatsonIntegration =
// Útlendingastofnun
| '89a03e83-5c73-4642-b5ba-cd3771ceca54'

// Útlendingastofnun - english
| '9e320784-ad44-4da9-9eb3-f305057a196a'

// Sjúkratryggingar
| 'e625e707-c9ce-4048-802c-c12b905c28be'

Expand Down Expand Up @@ -78,4 +81,6 @@ export type WatsonIntegration =

export type WatsonServiceInstance =
// Askur
'bc3d8312-d862-4750-b8bf-529db282050a'
| 'bc3d8312-d862-4750-b8bf-529db282050a'
// Útlendingastofnun - english
| '2529638b-503c-4374-955c-0310139ec177'
4 changes: 2 additions & 2 deletions apps/web/components/Organization/Wrapper/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,9 @@ export const watsonConfig: Record<
// Útlendingastofnun - Organization
// https://app.contentful.com/spaces/8k0h54kbe6bj/entries/77rXck3sISbMsUv7BO1PG2
'77rXck3sISbMsUv7BO1PG2': {
integrationID: '89a03e83-5c73-4642-b5ba-cd3771ceca54',
integrationID: '9e320784-ad44-4da9-9eb3-f305057a196a',
region: 'eu-gb',
serviceInstanceID: 'bc3d8312-d862-4750-b8bf-529db282050a',
serviceInstanceID: '2529638b-503c-4374-955c-0310139ec177',
showLauncher: false,
carbonTheme: 'g10',
namespaceKey: 'default',
Expand Down
5 changes: 2 additions & 3 deletions apps/web/components/ServiceWeb/config.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Locale } from '@island.is/shared/types'

import { WatsonChatPanelProps } from '@island.is/web/components'

import { BackgroundVariations, Options } from './types'
Expand Down Expand Up @@ -135,9 +134,9 @@ export const watsonConfig: Record<
namespaceKey: 'default',
},
[Organization.DIRECTORATE_OF_IMMIGRATION]: {
integrationID: '89a03e83-5c73-4642-b5ba-cd3771ceca54',
integrationID: '9e320784-ad44-4da9-9eb3-f305057a196a',
region: 'eu-gb',
serviceInstanceID: 'bc3d8312-d862-4750-b8bf-529db282050a',
serviceInstanceID: '2529638b-503c-4374-955c-0310139ec177',
showLauncher: false,
carbonTheme: 'g10',
namespaceKey: 'default',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Locale } from '@island.is/shared/types'

import {
LiveChatIncChatPanelProps,
WatsonChatPanelProps,
Expand Down Expand Up @@ -219,9 +218,9 @@ export const watsonConfig: Record<
// Útlendingastofnun - Organization
// https://app.contentful.com/spaces/8k0h54kbe6bj/entries/77rXck3sISbMsUv7BO1PG2
'77rXck3sISbMsUv7BO1PG2': {
integrationID: '89a03e83-5c73-4642-b5ba-cd3771ceca54',
integrationID: '9e320784-ad44-4da9-9eb3-f305057a196a',
region: 'eu-gb',
serviceInstanceID: 'bc3d8312-d862-4750-b8bf-529db282050a',
serviceInstanceID: '2529638b-503c-4374-955c-0310139ec177',
showLauncher: false,
carbonTheme: 'g10',
namespaceKey: 'default',
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { Locale } from '@island.is/shared/types'

import {
LiveChatIncChatPanelProps,
WatsonChatPanelProps,
Expand Down Expand Up @@ -47,9 +46,9 @@ export const watsonConfig: Record<
// Information for Ukrainian citizens
// https://app.contentful.com/spaces/8k0h54kbe6bj/entries/7GtuCCd7MEZhZKe0oXcHdb
'7GtuCCd7MEZhZKe0oXcHdb': {
integrationID: '89a03e83-5c73-4642-b5ba-cd3771ceca54',
integrationID: '9e320784-ad44-4da9-9eb3-f305057a196a',
region: 'eu-gb',
serviceInstanceID: 'bc3d8312-d862-4750-b8bf-529db282050a',
serviceInstanceID: '2529638b-503c-4374-955c-0310139ec177',
showLauncher: true,
carbonTheme: 'g10',
namespaceKey: 'ukrainian-citizens',
Expand Down

0 comments on commit d3ccc15

Please sign in to comment.