Skip to content

Commit

Permalink
Merge branch 'main' into j-s/court-session-type-arraignment
Browse files Browse the repository at this point in the history
  • Loading branch information
kodiakhq[bot] authored Dec 17, 2024
2 parents 529d562 + 2213255 commit 0065329
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
40 changes: 36 additions & 4 deletions apps/web/components/ChatPanel/BoostChatPanel/BoostChatPanel.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import React, { useEffect, useState } from 'react'
import { config, boostChatPanelEndpoints } from './config'
import React, { useEffect, useMemo, useState } from 'react'
import { useQuery } from '@apollo/client'

import { Query, QueryGetNamespaceArgs } from '@island.is/web/graphql/schema'
import { useNamespaceStrict } from '@island.is/web/hooks'
import { useI18n } from '@island.is/web/i18n'
import { GET_NAMESPACE_QUERY } from '@island.is/web/screens/queries'

import { ChatBubble } from '../ChatBubble'
import { BoostChatPanelProps } from '../types'
import { boostChatPanelEndpoints, config } from './config'

declare global {
interface Window {
Expand All @@ -16,6 +23,7 @@ export const BoostChatPanel: React.FC<
React.PropsWithChildren<BoostChatPanelProps>
> = ({ endpoint, pushUp = false }) => {
const [showButton, setShowButton] = useState(Boolean(window.boost)) // we show button when chat already loaded
const { activeLocale } = useI18n()

useEffect(() => {
// recreate the chat panel if we are on a different endpoint
Expand Down Expand Up @@ -60,19 +68,43 @@ export const BoostChatPanel: React.FC<
)

setShowButton(true)

const queryParam = new URLSearchParams(window.location.search).get(
'wa_lid',
)
if (queryParam && ['t10', 't11'].includes(queryParam)) {
window.boost.chatPanel.show()
}
})

el.src = boostChatPanelEndpoints[endpoint].url
el.id = 'boost-script'
document.body.appendChild(el)
}
}, [])
}, [endpoint])

const { data } = useQuery<Query, QueryGetNamespaceArgs>(GET_NAMESPACE_QUERY, {
variables: {
input: {
lang: activeLocale,
namespace: 'ChatPanels',
},
},
})

const namespace = useMemo(
() => JSON.parse(data?.getNamespace?.fields || '{}'),
[data?.getNamespace?.fields],
)

const n = useNamespaceStrict(namespace)

return (
<ChatBubble
text={'Hæ, get ég aðstoðað?'}
text={n('chatBubbleText', 'Hæ, get ég aðstoðað?')}
onClick={() => window.boost.chatPanel.show()}
isVisible={showButton}
pushUp={pushUp}
/>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ export const transformApplicationToNewPrimarySchoolDTO = (
},
email: parents.parent1.email,
phone: parents.parent1.phoneNumber,
role: 'parent',
role: 'guardian',
},
...(parents.parent2
? [
Expand All @@ -59,7 +59,7 @@ export const transformApplicationToNewPrimarySchoolDTO = (
},
email: parents.parent2.email,
phone: parents.parent2.phoneNumber,
role: 'parent',
role: 'guardian',
},
]
: []),
Expand Down

0 comments on commit 0065329

Please sign in to comment.