@campxdev/shared 1.8.17 → 1.8.18
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -1,8 +1,12 @@
|
|
|
1
1
|
import { HelpOutline } from '@mui/icons-material'
|
|
2
2
|
import { Button } from '@mui/material'
|
|
3
3
|
import DropDownButton from '../../../DropDownButton/DropDownButton'
|
|
4
|
+
import { UserStore } from '../../../../shared-state'
|
|
5
|
+
import { toast } from 'react-toastify'
|
|
4
6
|
|
|
5
7
|
export default function FreshDeskHelpButton() {
|
|
8
|
+
const { user } = UserStore.useState()
|
|
9
|
+
|
|
6
10
|
const handleOpenFreshDeskWidget = () => {
|
|
7
11
|
try {
|
|
8
12
|
;(window as any)?.openFreshDeskWidget()
|
|
@@ -16,6 +20,9 @@ export default function FreshDeskHelpButton() {
|
|
|
16
20
|
try {
|
|
17
21
|
;(window as any)?.fcWidget?.open()
|
|
18
22
|
} catch (error) {
|
|
23
|
+
toast.error('Error launching Freshdesk Chat')
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.log(error)
|
|
19
26
|
// eslint-disable-next-line no-console
|
|
20
27
|
console.error('Error launching Freshdesk Chat')
|
|
21
28
|
}
|
|
@@ -3,12 +3,35 @@ import { Helmet as ReactHelmet } from 'react-helmet'
|
|
|
3
3
|
type MetaProps = JSX.IntrinsicElements['meta']
|
|
4
4
|
type LinkProps = JSX.IntrinsicElements['link']
|
|
5
5
|
|
|
6
|
+
const getInnerHtml = (user: any) => {
|
|
7
|
+
const fcWidgetMessengerConfig = {
|
|
8
|
+
config: {
|
|
9
|
+
headerProperty: {
|
|
10
|
+
hideChatButton: true,
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return `
|
|
16
|
+
window.fcWidgetMessengerConfig = ${JSON.stringify(fcWidgetMessengerConfig)}
|
|
17
|
+
window.fcSettings = {
|
|
18
|
+
onInit: function() {
|
|
19
|
+
window.fcWidget.setExternalId('${user?.email}')
|
|
20
|
+
window.fcWidget.user.setFirstName('${user?.fullName}')
|
|
21
|
+
window.fcWidget.user.setEmail('${user?.email}')
|
|
22
|
+
window.fcWidget.user.setPhone('${user?.mobile}')
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
`
|
|
26
|
+
}
|
|
27
|
+
|
|
6
28
|
interface IHelmetProps {
|
|
7
29
|
appTitle: string
|
|
8
30
|
favicon: string
|
|
9
31
|
description?: string
|
|
10
32
|
meta?: MetaProps[] | undefined
|
|
11
33
|
link?: LinkProps[] | undefined
|
|
34
|
+
user: any
|
|
12
35
|
}
|
|
13
36
|
|
|
14
37
|
export default function Helmet({
|
|
@@ -17,6 +40,7 @@ export default function Helmet({
|
|
|
17
40
|
description,
|
|
18
41
|
meta = [],
|
|
19
42
|
link = [],
|
|
43
|
+
user,
|
|
20
44
|
}: IHelmetProps) {
|
|
21
45
|
return (
|
|
22
46
|
<ReactHelmet
|
|
@@ -47,8 +71,7 @@ export default function Helmet({
|
|
|
47
71
|
script={[
|
|
48
72
|
{
|
|
49
73
|
type: 'text/javascript',
|
|
50
|
-
innerHTML:
|
|
51
|
-
'window.fcWidgetMessengerConfig = {config: {headerProperty: {hideChatButton: true}}}',
|
|
74
|
+
innerHTML: getInnerHtml(user),
|
|
52
75
|
defer: true,
|
|
53
76
|
},
|
|
54
77
|
{
|