@campxdev/shared 1.8.20 → 1.8.22

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.20",
3
+ "version": "1.8.22",
4
4
  "main": "./exports.ts",
5
5
  "scripts": {
6
6
  "start": "react-scripts start",
@@ -0,0 +1,61 @@
1
+ /* eslint-disable no-console */
2
+ import { useState } from 'react'
3
+ import { UserStore } from '../../../../shared-state'
4
+ import { chatWithUs } from '../assets'
5
+ import { Box, styled } from '@mui/material'
6
+
7
+ export default function FreshChatButton() {
8
+ const _window = window as any
9
+ const { user } = UserStore.useState()
10
+
11
+ var openWidget = function () {
12
+ const el = document.getElementById('fc_frame')
13
+ if (el) {
14
+ el.style.visibility = 'visible'
15
+ }
16
+ _window.fcWidget.open()
17
+ initEvents()
18
+ }
19
+ var initEvents = function () {
20
+ const el = document.getElementById('custom_fc_button')
21
+ _window.fcWidget.on('widget:opened', function (resp) {
22
+ if (el) {
23
+ el.style.visibility = 'hidden'
24
+ }
25
+ })
26
+ _window.fcWidget.on('widget:closed', function (resp) {
27
+ if (el) {
28
+ el.style.visibility = 'visible'
29
+ }
30
+ })
31
+ }
32
+
33
+ if (!user) return null
34
+ return (
35
+ <Box
36
+ id="custom_fc_button"
37
+ sx={{
38
+ position: 'fixed',
39
+ right: 0,
40
+ bottom: '18px',
41
+ cursor: 'pointer',
42
+ '@media print': {
43
+ display: 'none',
44
+ },
45
+ }}
46
+ >
47
+ <a id="open_fc_widget" onClick={openWidget} style={{ cursor: 'pointer' }}>
48
+ <StyledImg src={chatWithUs} />
49
+ </a>
50
+ </Box>
51
+ )
52
+ }
53
+
54
+ const StyledImg = styled('img')(({ theme }) => ({
55
+ width: '35px',
56
+ height: 'auto',
57
+ '&:hover': {
58
+ width: '50px',
59
+ },
60
+ transition: 'width 0.3s',
61
+ }))
@@ -1,6 +1,5 @@
1
1
  import { HelpOutline } from '@mui/icons-material'
2
2
  import { Button } from '@mui/material'
3
- import DropDownButton from '../../../DropDownButton/DropDownButton'
4
3
  import { UserStore } from '../../../../shared-state'
5
4
 
6
5
  export default function FreshDeskHelpButton() {
@@ -15,52 +14,15 @@ export default function FreshDeskHelpButton() {
15
14
  }
16
15
  }
17
16
 
18
- const handleFreshChat = () => {
19
- const _window = window as any
20
- try {
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
- })
32
- } catch (error) {
33
- // eslint-disable-next-line no-console
34
- console.log(error)
35
- // eslint-disable-next-line no-console
36
- console.error('Error launching Freshdesk Chat')
37
- }
38
- }
39
17
  return (
40
- <>
41
- <DropDownButton
42
- anchor={({ open }) => (
43
- <Button
44
- variant="text"
45
- color="secondary"
46
- onClick={open}
47
- startIcon={<HelpOutline />}
48
- sx={{ padding: '20px' }}
49
- >
50
- Help
51
- </Button>
52
- )}
53
- menu={[
54
- {
55
- label: 'Raise a Ticket',
56
- onClick: handleOpenFreshDeskWidget,
57
- },
58
- {
59
- label: 'Chat with us',
60
- onClick: handleFreshChat,
61
- },
62
- ]}
63
- />
64
- </>
18
+ <Button
19
+ variant="text"
20
+ color="secondary"
21
+ onClick={handleOpenFreshDeskWidget}
22
+ startIcon={<HelpOutline />}
23
+ sx={{ padding: '20px' }}
24
+ >
25
+ Help
26
+ </Button>
65
27
  )
66
28
  }
@@ -14,6 +14,7 @@ import commuteSmall from './commutexSmall.svg'
14
14
  import commutex from './commutex.png'
15
15
  import hostelx from './hostelx.png'
16
16
  import enrollSmall from './enroll_logo.svg'
17
+ import chatWithUs from './chat_with_us.png'
17
18
 
18
19
  export {
19
20
  collegex,
@@ -32,4 +33,5 @@ export {
32
33
  commutex,
33
34
  commuteSmall,
34
35
  enrollSmall,
36
+ chatWithUs,
35
37
  }
@@ -1,7 +1,8 @@
1
+ import { ReactNode } from 'react'
1
2
  import { Helmet as ReactHelmet } from 'react-helmet'
2
3
 
3
- type MetaProps = JSX.IntrinsicElements['meta']
4
- type LinkProps = JSX.IntrinsicElements['link']
4
+ // type MetaProps = JSX.IntrinsicElements['meta']
5
+ // type LinkProps = JSX.IntrinsicElements['link']
5
6
 
6
7
  const getInnerHtml = (user: any) => {
7
8
  const fcWidgetMessengerConfig = {
@@ -18,12 +19,8 @@ const getInnerHtml = (user: any) => {
18
19
  window.fcWidgetMessengerConfig = ${JSON.stringify(fcWidgetMessengerConfig)}
19
20
  window.fcSettings = {
20
21
  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}')
22
+ console.log('Fresh Chat Init')
23
+ window.fcWidget.setExternalId('${user?.email}')
27
24
  window.fcWidget.user.setFirstName('${user?.fullName}')
28
25
  window.fcWidget.user.setEmail('${user?.email}')
29
26
  window.fcWidget.user.setPhone('${phone}')
@@ -34,61 +31,75 @@ const getInnerHtml = (user: any) => {
34
31
  }
35
32
  // window.fcWidget.user.setPhone('${user?.mobile}')
36
33
 
34
+ // window.fcWidget.user.clear().then(function() {
35
+ // console.log('User cleared');
36
+ // }, function() {
37
+ // console.log("User Not cleared");
38
+ // });
39
+
37
40
  interface IHelmetProps {
38
41
  appTitle: string
39
42
  favicon: string
40
43
  description?: string
41
- meta?: MetaProps[] | undefined
42
- link?: LinkProps[] | undefined
43
44
  user: any
45
+ extraMetaTags?: ReactNode
44
46
  }
45
47
 
46
48
  export default function Helmet({
47
49
  appTitle,
48
50
  favicon,
49
51
  description,
50
- meta = [],
51
- link = [],
52
52
  user,
53
+ extraMetaTags,
53
54
  }: IHelmetProps) {
54
55
  return (
55
- <ReactHelmet
56
- htmlAttributes={{ lang: 'en' }}
57
- title={appTitle}
58
- meta={[
59
- {
60
- charSet: 'utf-8',
61
- },
62
- {
63
- name: 'description',
64
- content: description,
65
- },
66
- {
67
- name: 'viewport',
68
- content: 'width=device-width, initial-scale=1',
69
- },
70
- ...meta,
71
- ]}
72
- link={[
73
- { rel: 'icon', href: favicon },
74
- {
75
- rel: 'apple-touch-icon',
76
- href: favicon,
77
- },
78
- ...link,
79
- ]}
80
- script={[
81
- {
82
- type: 'text/javascript',
83
- innerHTML: getInnerHtml(user),
84
- defer: true,
85
- },
86
- {
87
- type: 'text/javascript',
88
- src: '//in.fw-cdn.com/30814322/430238.js',
89
- defer: true,
90
- },
91
- ]}
92
- />
56
+ <ReactHelmet htmlAttributes={{ lang: 'en' }}>
57
+ <title>{appTitle}</title>
58
+ <meta charSet="utf-8" />
59
+ <meta name="description" content={description} />
60
+ <meta name="viewport" content="width=device-width, initial-scale=1" />
61
+ {extraMetaTags}
62
+ <link rel="icon" href={favicon} />
63
+ <link rel="apple-touch-icon" href={favicon} />
64
+ <script
65
+ type="text/javascript"
66
+ src="//in.fw-cdn.com/30814322/430238.js"
67
+ defer
68
+ />
69
+ <script defer>{getInnerHtml(user)}</script>
70
+
71
+ <script async defer>
72
+ {`
73
+ window.fwSettings = {
74
+ widget_id: 85000000149,
75
+ }
76
+ !(function () {
77
+ window.openFreshDeskWidget = function openFreshDeskWidget() {
78
+ FreshworksWidget('open', 'ticketForm')
79
+ }
80
+ if ('function' != typeof window.FreshworksWidget) {
81
+ var n = function () {
82
+ n.q.push(arguments)
83
+ }
84
+ ;(n.q = []), (window.FreshworksWidget = n)
85
+ }
86
+ FreshworksWidget('hide', 'launcher')
87
+ })()
88
+ `}
89
+ </script>
90
+ <script
91
+ type="text/javascript"
92
+ src="https://ind-widget.freshworks.com/widgets/85000000149.js"
93
+ defer
94
+ ></script>
95
+ <style type="text/css">
96
+ {`
97
+ #fc_frame {
98
+ bottom: 0 !important;
99
+ right: 0 !important;
100
+ }
101
+ `}
102
+ </style>
103
+ </ReactHelmet>
93
104
  )
94
105
  }
@@ -8,19 +8,14 @@ const LoginContext = createContext<{
8
8
  openLoginForm: (loginUrl: string) => {},
9
9
  })
10
10
 
11
- export default function LoginFormProvider({ children, showSuperAdminForm }) {
11
+ export default function LoginFormProvider({ children }) {
12
12
  const modal = useModal()
13
13
 
14
14
  const onLogin = (loginUrl: string) => {
15
15
  modal({
16
16
  title: 'Developer Login',
17
17
  content({ close }) {
18
- return (
19
- <LoginForm
20
- loginUrl={loginUrl}
21
- showSuperAdminForm={showSuperAdminForm}
22
- />
23
- )
18
+ return <LoginForm loginUrl={loginUrl} />
24
19
  },
25
20
  })
26
21
  }
@@ -9,6 +9,7 @@ import { ToastContainer } from '../components'
9
9
  import DialogProvider from '../components/DrawerWrapper/DrawerWrapper'
10
10
  import GlobalNetworkLoadingIndicator from '../components/ErrorBoundary/GlobalNetworkLoadingIndicator'
11
11
  import LoginFormProvider from './LoginFormProvider'
12
+ import FreshChatButton from '../components/Layout/Header/HeaderActions/FreshChatButton'
12
13
 
13
14
  export const campxTenantKey = Cookies.get('campx_tenant')
14
15
  export const urlTenantKey = window.location.pathname.split('/')[1]
@@ -36,9 +37,10 @@ export default function Providers({
36
37
  <MuiThemeProvider>
37
38
  <ConfirmContextProvider>
38
39
  <DialogProvider>
39
- <LoginFormProvider showSuperAdminForm={showSuperAdminLoginForm}>
40
+ <LoginFormProvider>
40
41
  {children}
41
42
  <GlobalNetworkLoadingIndicator />
43
+ <FreshChatButton />
42
44
  </LoginFormProvider>
43
45
  <ToastContainer />
44
46
  </DialogProvider>