@campxdev/shared 1.8.37 → 1.8.39
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 +1 -1
- package/src/components/Layout/Helmet.tsx +38 -37
- package/src/hooks/useAuth.ts +8 -4
package/package.json
CHANGED
|
@@ -1,10 +1,31 @@
|
|
|
1
1
|
import { ReactNode } from 'react'
|
|
2
2
|
import { Helmet as ReactHelmet } from 'react-helmet'
|
|
3
3
|
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
const isLocalHost = process.env.NODE_ENV === 'development'
|
|
5
|
+
|
|
6
|
+
const freshDeskInnerHtml = `
|
|
7
|
+
window.fwSettings = {
|
|
8
|
+
widget_id: 85000000149,
|
|
9
|
+
}
|
|
10
|
+
!(function () {
|
|
11
|
+
window.openFreshDeskWidget = function openFreshDeskWidget() {
|
|
12
|
+
FreshworksWidget('open', 'ticketForm')
|
|
13
|
+
}
|
|
14
|
+
if ('function' != typeof window.FreshworksWidget) {
|
|
15
|
+
var n = function () {
|
|
16
|
+
n.q.push(arguments)
|
|
17
|
+
}
|
|
18
|
+
;(n.q = []), (window.FreshworksWidget = n)
|
|
19
|
+
}
|
|
20
|
+
FreshworksWidget('hide', 'launcher')
|
|
21
|
+
})()
|
|
22
|
+
|
|
23
|
+
`
|
|
6
24
|
|
|
7
25
|
const getInnerHtml = (user: any) => {
|
|
26
|
+
if (isLocalHost) {
|
|
27
|
+
return ''
|
|
28
|
+
}
|
|
8
29
|
const fcWidgetMessengerConfig = {
|
|
9
30
|
config: {
|
|
10
31
|
headerProperty: {
|
|
@@ -29,13 +50,6 @@ const getInnerHtml = (user: any) => {
|
|
|
29
50
|
|
|
30
51
|
`
|
|
31
52
|
}
|
|
32
|
-
// window.fcWidget.user.setPhone('${user?.mobile}')
|
|
33
|
-
|
|
34
|
-
// window.fcWidget.user.clear().then(function() {
|
|
35
|
-
// console.log('User cleared');
|
|
36
|
-
// }, function() {
|
|
37
|
-
// console.log("User Not cleared");
|
|
38
|
-
// });
|
|
39
53
|
|
|
40
54
|
interface IHelmetProps {
|
|
41
55
|
appTitle: string
|
|
@@ -61,37 +75,24 @@ export default function Helmet({
|
|
|
61
75
|
{extraMetaTags}
|
|
62
76
|
<link rel="icon" href={favicon} />
|
|
63
77
|
<link rel="apple-touch-icon" href={favicon} />
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
78
|
+
{isLocalHost && (
|
|
79
|
+
<script
|
|
80
|
+
type="text/javascript"
|
|
81
|
+
src="//in.fw-cdn.com/30814322/430238.js"
|
|
82
|
+
defer
|
|
83
|
+
/>
|
|
84
|
+
)}
|
|
69
85
|
<script defer>{getInnerHtml(user)}</script>
|
|
70
|
-
|
|
71
86
|
<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
|
-
`}
|
|
87
|
+
{freshDeskInnerHtml}
|
|
89
88
|
</script>
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
89
|
+
{isLocalHost && (
|
|
90
|
+
<script
|
|
91
|
+
type="text/javascript"
|
|
92
|
+
src="https://ind-widget.freshworks.com/widgets/85000000149.js"
|
|
93
|
+
defer
|
|
94
|
+
></script>
|
|
95
|
+
)}
|
|
95
96
|
<style type="text/css">
|
|
96
97
|
{`
|
|
97
98
|
#fc_frame {
|
package/src/hooks/useAuth.ts
CHANGED
|
@@ -33,6 +33,7 @@ const ApplicationObj = {
|
|
|
33
33
|
payments: 'payments',
|
|
34
34
|
exams: 'exams',
|
|
35
35
|
}
|
|
36
|
+
|
|
36
37
|
const checkIsAdmin = (user) => {
|
|
37
38
|
let subDomain = window.location.host.split('.')?.slice(-3)[0]
|
|
38
39
|
const localSubDomain = process.env.REACT_APP_SUBDOMAIN
|
|
@@ -43,7 +44,7 @@ const checkIsAdmin = (user) => {
|
|
|
43
44
|
subDomain = localSubDomain
|
|
44
45
|
|
|
45
46
|
if (!localSubDomain) {
|
|
46
|
-
toast.warn('
|
|
47
|
+
toast.warn('missing REACT_APP_SUBDOMAIN in .env')
|
|
47
48
|
}
|
|
48
49
|
}
|
|
49
50
|
|
|
@@ -55,7 +56,7 @@ const checkIsAdmin = (user) => {
|
|
|
55
56
|
subDomain,
|
|
56
57
|
)
|
|
57
58
|
|
|
58
|
-
const profile = user?.
|
|
59
|
+
const profile = user?.profiles?.find(
|
|
59
60
|
(item) => item.application == ApplicationObj[subDomain],
|
|
60
61
|
)
|
|
61
62
|
return profile ? (profile.isAdmin == true ? 1 : 0) : 0
|
|
@@ -94,6 +95,9 @@ function useAuth({ permissionsEndpoint, loginUrl }: AuthParams): AuthResponse {
|
|
|
94
95
|
s.user = res.data?.user
|
|
95
96
|
s.roles = res.data?.roles
|
|
96
97
|
})
|
|
98
|
+
const isAdmin = checkIsAdmin(res.data.user)
|
|
99
|
+
// eslint-disable-next-line no-console
|
|
100
|
+
console.log('Is Admin -> ', isAdmin)
|
|
97
101
|
|
|
98
102
|
PermissionsStore.update((s) => {
|
|
99
103
|
s.permissions = {
|
|
@@ -101,8 +105,8 @@ function useAuth({ permissionsEndpoint, loginUrl }: AuthParams): AuthResponse {
|
|
|
101
105
|
can_settings_view: 1,
|
|
102
106
|
can_dashboard_view: 1,
|
|
103
107
|
can_individual_pages_view: 1,
|
|
104
|
-
can_analatics_view:
|
|
105
|
-
can_admin_view:
|
|
108
|
+
can_analatics_view: isAdmin,
|
|
109
|
+
can_admin_view: isAdmin,
|
|
106
110
|
} as any
|
|
107
111
|
s.applications = res.data?.applications ?? []
|
|
108
112
|
})
|