1
- import React from "react"
2
- import { Provider , type ProviderProps } from "react-redux"
3
- import { type Action , type AnyAction } from "redux"
4
- import { ThemeProvider , CssBaseline } from "@mui/material"
1
+ import { CssBaseline , ThemeProvider } from "@mui/material"
5
2
import { type ThemeProviderProps } from "@mui/material/styles/ThemeProvider"
3
+ import React , { useCallback } from "react"
4
+ import { Provider , type ProviderProps } from "react-redux"
5
+ import { type Action } from "redux"
6
6
7
- import {
8
- useExternalScript ,
9
- useFreshworksWidget ,
10
- useCountdown ,
11
- useEventListener ,
12
- } from "../hooks"
13
7
import { InactiveDialog , ScreenTimeDialog } from "../features"
8
+ import {
9
+ // configureFreshworksWidget,
10
+ toggleOneTrustInfoDisplay ,
11
+ } from "../helpers/window"
12
+ import { useCountdown , useEventListener } from "../hooks"
14
13
import "../scripts"
15
14
16
- export interface AppProps < A extends Action = AnyAction , S = unknown > {
15
+ export interface AppProps < A extends Action = Action , S = unknown > {
17
16
theme : ThemeProviderProps [ "theme" ]
18
17
store : ProviderProps < A , S > [ "store" ]
19
18
children : React . ReactNode
20
19
maxIdleSeconds ?: number
21
20
maxTotalSeconds ?: number
22
21
}
23
22
24
- const App = < A extends Action = AnyAction , S = unknown > ( {
23
+ const App = < A extends Action = Action , S = unknown > ( {
25
24
theme,
26
25
store,
27
26
children,
@@ -34,30 +33,26 @@ const App = <A extends Action = AnyAction, S = unknown>({
34
33
const isAuthenticated = true
35
34
const [ idleSeconds , setIdleSeconds ] = useCountdown ( maxIdleSeconds )
36
35
const [ totalSeconds , setTotalSeconds ] = useCountdown ( maxTotalSeconds )
36
+ const resetIdleSeconds = useCallback ( ( ) => {
37
+ setIdleSeconds ( maxIdleSeconds )
38
+ } , [ setIdleSeconds , maxIdleSeconds ] )
37
39
38
40
const isIdle = isAuthenticated && idleSeconds === 0
39
41
const tooMuchScreenTime = totalSeconds === 0
40
42
41
- function resetIdleSeconds ( ) : void {
42
- setIdleSeconds ( maxIdleSeconds )
43
- }
44
- function resetTotalSeconds ( ) : void {
45
- setTotalSeconds ( maxTotalSeconds )
46
- }
47
-
48
43
useEventListener ( root , "mousemove" , resetIdleSeconds )
49
44
useEventListener ( root , "keypress" , resetIdleSeconds )
50
45
51
46
React . useEffect ( ( ) => {
52
47
if ( isAuthenticated ) resetIdleSeconds ( )
53
- } , [ isAuthenticated ] )
48
+ } , [ isAuthenticated , resetIdleSeconds ] )
54
49
55
- React . useEffect ( ( ) => {
56
- useFreshworksWidget ( "hide" )
57
- } , [ ] )
50
+ // React.useEffect(() => {
51
+ // configureFreshworksWidget ("hide")
52
+ // }, [])
58
53
59
54
if ( process . env . NODE_ENV !== "development" ) {
60
- useOneTrustScripts ( )
55
+ toggleOneTrustInfoDisplay ( )
61
56
}
62
57
63
58
return (
@@ -91,7 +86,9 @@ const App = <A extends Action = AnyAction, S = unknown>({
91
86
< InactiveDialog open = { isIdle } onClose = { resetIdleSeconds } />
92
87
< ScreenTimeDialog
93
88
open = { ! isIdle && tooMuchScreenTime }
94
- onClose = { resetTotalSeconds }
89
+ onClose = { ( ) => {
90
+ setTotalSeconds ( maxTotalSeconds )
91
+ } }
95
92
/>
96
93
{ children }
97
94
</ Provider >
@@ -101,36 +98,37 @@ const App = <A extends Action = AnyAction, S = unknown>({
101
98
102
99
export default App
103
100
104
- function useOneTrustScripts ( ) : void {
105
- const oneTrustEventTypes = [
106
- useExternalScript ( {
107
- props : {
108
- src : "https://cdn-ukwest.onetrust.com/consent/5da42396-cb12-4493-8d04-5179033cfbad/OtAutoBlock.js" ,
109
- type : "text/javascript" ,
110
- } ,
111
- eventTypes : [ "load" , "error" ] ,
112
- } ) ,
113
- useExternalScript ( {
114
- props : {
115
- src : "https://cdn-ukwest.onetrust.com/scripttemplates/otSDKStub.js" ,
116
- type : "text/javascript" ,
117
- charset : "UTF-8" ,
118
- } ,
119
- attrs : {
120
- "data-domain-script" : "5da42396-cb12-4493-8d04-5179033cfbad" ,
121
- } ,
122
- eventTypes : [ "load" , "error" ] ,
123
- } ) ,
124
- useExternalScript ( {
125
- props : {
126
- src : "https://cdn-ukwest.onetrust.com/scripttemplates/202302.1.0/otBannerSdk.js" ,
127
- async : true ,
128
- type : "text/javascript" ,
129
- } ,
130
- eventTypes : [ "load" , "error" ] ,
131
- } ) ,
132
- ]
133
- if ( oneTrustEventTypes . some ( t => t === "error" ) ) {
134
- alert ( "OneTrust failed to load!" )
135
- }
136
- }
101
+ // TODO: figure out what to do with this
102
+ // function useOneTrustScripts(): void {
103
+ // const oneTrustEventTypes = [
104
+ // useExternalScript({
105
+ // props: {
106
+ // src: "https://cdn-ukwest.onetrust.com/consent/5da42396-cb12-4493-8d04-5179033cfbad/OtAutoBlock.js",
107
+ // type: "text/javascript",
108
+ // },
109
+ // eventTypes: ["load", "error"],
110
+ // }),
111
+ // useExternalScript({
112
+ // props: {
113
+ // src: "https://cdn-ukwest.onetrust.com/scripttemplates/otSDKStub.js",
114
+ // type: "text/javascript",
115
+ // charset: "UTF-8",
116
+ // },
117
+ // attrs: {
118
+ // "data-domain-script": "5da42396-cb12-4493-8d04-5179033cfbad",
119
+ // },
120
+ // eventTypes: ["load", "error"],
121
+ // }),
122
+ // useExternalScript({
123
+ // props: {
124
+ // src: "https://cdn-ukwest.onetrust.com/scripttemplates/202302.1.0/otBannerSdk.js",
125
+ // async: true,
126
+ // type: "text/javascript",
127
+ // },
128
+ // eventTypes: ["load", "error"],
129
+ // }),
130
+ // ]
131
+ // if (oneTrustEventTypes.some(t => t === "error")) {
132
+ // alert("OneTrust failed to load!")
133
+ // }
134
+ // }
0 commit comments