@campxdev/shared 1.8.18 → 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,6 +1,6 @@
1
1
  {
2
2
  "name": "@campxdev/shared",
3
- "version": "1.8.18",
3
+ "version": "1.8.19",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -2,7 +2,6 @@ import { HelpOutline } from '@mui/icons-material'
2
2
  import { Button } from '@mui/material'
3
3
  import DropDownButton from '../../../DropDownButton/DropDownButton'
4
4
  import { UserStore } from '../../../../shared-state'
5
- import { toast } from 'react-toastify'
6
5
 
7
6
  export default function FreshDeskHelpButton() {
8
7
  const { user } = UserStore.useState()
@@ -17,10 +16,20 @@ export default function FreshDeskHelpButton() {
17
16
  }
18
17
 
19
18
  const handleFreshChat = () => {
19
+ const _window = window as any
20
20
  try {
21
- ;(window as any)?.fcWidget?.open()
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
+ })
22
32
  } catch (error) {
23
- toast.error('Error launching Freshdesk Chat')
24
33
  // eslint-disable-next-line no-console
25
34
  console.log(error)
26
35
  // eslint-disable-next-line no-console
@@ -12,18 +12,27 @@ const getInnerHtml = (user: any) => {
12
12
  },
13
13
  }
14
14
 
15
+ const phone = user?.mobile?.substring(user?.mobile?.length - 10)
16
+
15
17
  return `
16
18
  window.fcWidgetMessengerConfig = ${JSON.stringify(fcWidgetMessengerConfig)}
17
19
  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}')
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
+ }
23
31
  }
24
- }
25
- `
32
+
33
+ `
26
34
  }
35
+ // window.fcWidget.user.setPhone('${user?.mobile}')
27
36
 
28
37
  interface IHelmetProps {
29
38
  appTitle: string