@campxdev/shared 1.8.17 → 1.8.19
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,11 @@
|
|
|
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'
|
|
4
5
|
|
|
5
6
|
export default function FreshDeskHelpButton() {
|
|
7
|
+
const { user } = UserStore.useState()
|
|
8
|
+
|
|
6
9
|
const handleOpenFreshDeskWidget = () => {
|
|
7
10
|
try {
|
|
8
11
|
;(window as any)?.openFreshDeskWidget()
|
|
@@ -13,9 +16,22 @@ export default function FreshDeskHelpButton() {
|
|
|
13
16
|
}
|
|
14
17
|
|
|
15
18
|
const handleFreshChat = () => {
|
|
19
|
+
const _window = window as any
|
|
16
20
|
try {
|
|
17
|
-
|
|
21
|
+
_window?.fcWidget?.open()
|
|
22
|
+
|
|
23
|
+
_window.fcWidget.on('widget:opened', function (resp) {
|
|
24
|
+
// eslint-disable-next-line no-console
|
|
25
|
+
console.log('Widget Opened', resp)
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
_window.fcWidget.on('widget:closed', function () {
|
|
29
|
+
// eslint-disable-next-line no-console
|
|
30
|
+
console.log('Message Dialog Closed by the User')
|
|
31
|
+
})
|
|
18
32
|
} catch (error) {
|
|
33
|
+
// eslint-disable-next-line no-console
|
|
34
|
+
console.log(error)
|
|
19
35
|
// eslint-disable-next-line no-console
|
|
20
36
|
console.error('Error launching Freshdesk Chat')
|
|
21
37
|
}
|
|
@@ -3,12 +3,44 @@ 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
|
+
const phone = user?.mobile?.substring(user?.mobile?.length - 10)
|
|
16
|
+
|
|
17
|
+
return `
|
|
18
|
+
window.fcWidgetMessengerConfig = ${JSON.stringify(fcWidgetMessengerConfig)}
|
|
19
|
+
window.fcSettings = {
|
|
20
|
+
onInit: function() {
|
|
21
|
+
window.fcWidget.user.clear().then(function() {
|
|
22
|
+
console.log('User cleared');
|
|
23
|
+
}, function() {
|
|
24
|
+
console.log("User Not cleared");
|
|
25
|
+
});
|
|
26
|
+
window.fcWidget.setExternalId('${phone}')
|
|
27
|
+
window.fcWidget.user.setFirstName('${user?.fullName}')
|
|
28
|
+
window.fcWidget.user.setEmail('${user?.email}')
|
|
29
|
+
window.fcWidget.user.setPhone('${phone}')
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
`
|
|
34
|
+
}
|
|
35
|
+
// window.fcWidget.user.setPhone('${user?.mobile}')
|
|
36
|
+
|
|
6
37
|
interface IHelmetProps {
|
|
7
38
|
appTitle: string
|
|
8
39
|
favicon: string
|
|
9
40
|
description?: string
|
|
10
41
|
meta?: MetaProps[] | undefined
|
|
11
42
|
link?: LinkProps[] | undefined
|
|
43
|
+
user: any
|
|
12
44
|
}
|
|
13
45
|
|
|
14
46
|
export default function Helmet({
|
|
@@ -17,6 +49,7 @@ export default function Helmet({
|
|
|
17
49
|
description,
|
|
18
50
|
meta = [],
|
|
19
51
|
link = [],
|
|
52
|
+
user,
|
|
20
53
|
}: IHelmetProps) {
|
|
21
54
|
return (
|
|
22
55
|
<ReactHelmet
|
|
@@ -47,8 +80,7 @@ export default function Helmet({
|
|
|
47
80
|
script={[
|
|
48
81
|
{
|
|
49
82
|
type: 'text/javascript',
|
|
50
|
-
innerHTML:
|
|
51
|
-
'window.fcWidgetMessengerConfig = {config: {headerProperty: {hideChatButton: true}}}',
|
|
83
|
+
innerHTML: getInnerHtml(user),
|
|
52
84
|
defer: true,
|
|
53
85
|
},
|
|
54
86
|
{
|