Skip to content

Commit 4a1e934

Browse files
committed
fix: linting errors
1 parent 728f4fa commit 4a1e934

10 files changed

+133
-121
lines changed

src/components/App.tsx

+56-58
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,26 @@
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"
52
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"
66

7-
import {
8-
useExternalScript,
9-
useFreshworksWidget,
10-
useCountdown,
11-
useEventListener,
12-
} from "../hooks"
137
import { InactiveDialog, ScreenTimeDialog } from "../features"
8+
import {
9+
// configureFreshworksWidget,
10+
toggleOneTrustInfoDisplay,
11+
} from "../helpers/window"
12+
import { useCountdown, useEventListener } from "../hooks"
1413
import "../scripts"
1514

16-
export interface AppProps<A extends Action = AnyAction, S = unknown> {
15+
export interface AppProps<A extends Action = Action, S = unknown> {
1716
theme: ThemeProviderProps["theme"]
1817
store: ProviderProps<A, S>["store"]
1918
children: React.ReactNode
2019
maxIdleSeconds?: number
2120
maxTotalSeconds?: number
2221
}
2322

24-
const App = <A extends Action = AnyAction, S = unknown>({
23+
const App = <A extends Action = Action, S = unknown>({
2524
theme,
2625
store,
2726
children,
@@ -34,30 +33,26 @@ const App = <A extends Action = AnyAction, S = unknown>({
3433
const isAuthenticated = true
3534
const [idleSeconds, setIdleSeconds] = useCountdown(maxIdleSeconds)
3635
const [totalSeconds, setTotalSeconds] = useCountdown(maxTotalSeconds)
36+
const resetIdleSeconds = useCallback(() => {
37+
setIdleSeconds(maxIdleSeconds)
38+
}, [setIdleSeconds, maxIdleSeconds])
3739

3840
const isIdle = isAuthenticated && idleSeconds === 0
3941
const tooMuchScreenTime = totalSeconds === 0
4042

41-
function resetIdleSeconds(): void {
42-
setIdleSeconds(maxIdleSeconds)
43-
}
44-
function resetTotalSeconds(): void {
45-
setTotalSeconds(maxTotalSeconds)
46-
}
47-
4843
useEventListener(root, "mousemove", resetIdleSeconds)
4944
useEventListener(root, "keypress", resetIdleSeconds)
5045

5146
React.useEffect(() => {
5247
if (isAuthenticated) resetIdleSeconds()
53-
}, [isAuthenticated])
48+
}, [isAuthenticated, resetIdleSeconds])
5449

55-
React.useEffect(() => {
56-
useFreshworksWidget("hide")
57-
}, [])
50+
// React.useEffect(() => {
51+
// configureFreshworksWidget("hide")
52+
// }, [])
5853

5954
if (process.env.NODE_ENV !== "development") {
60-
useOneTrustScripts()
55+
toggleOneTrustInfoDisplay()
6156
}
6257

6358
return (
@@ -91,7 +86,9 @@ const App = <A extends Action = AnyAction, S = unknown>({
9186
<InactiveDialog open={isIdle} onClose={resetIdleSeconds} />
9287
<ScreenTimeDialog
9388
open={!isIdle && tooMuchScreenTime}
94-
onClose={resetTotalSeconds}
89+
onClose={() => {
90+
setTotalSeconds(maxTotalSeconds)
91+
}}
9592
/>
9693
{children}
9794
</Provider>
@@ -101,36 +98,37 @@ const App = <A extends Action = AnyAction, S = unknown>({
10198

10299
export default App
103100

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+
// }

src/components/ScrollRoutes.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from "react"
2-
import { Routes, type RoutesProps, useLocation } from "react-router-dom"
2+
import { Routes, useLocation, type RoutesProps } from "react-router-dom"
33

44
export interface ScrollRoutesProps extends RoutesProps {
55
x?: number
@@ -15,7 +15,7 @@ const ScrollRoutes: React.FC<ScrollRoutesProps> = ({
1515

1616
React.useEffect(() => {
1717
window.scroll(x, y)
18-
}, [pathname])
18+
}, [pathname, x, y])
1919

2020
return <Routes {...routesProps} />
2121
}

src/components/form/AutocompleteField.tsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
1-
import React from "react"
2-
import { flushSync } from "react-dom"
1+
import { ErrorOutline as ErrorOutlineIcon } from "@mui/icons-material"
32
import {
43
Autocomplete,
4+
InputAdornment,
5+
TextField,
6+
useTheme,
57
type AutocompleteProps,
68
type ChipTypeMap,
7-
TextField,
89
type TextFieldProps,
9-
useTheme,
10-
InputAdornment,
1110
} from "@mui/material"
12-
import { ErrorOutline as ErrorOutlineIcon } from "@mui/icons-material"
13-
import { Field, type FieldProps, type FieldConfig } from "formik"
11+
import { Field, type FieldConfig, type FieldProps } from "formik"
12+
import React from "react"
13+
import { flushSync } from "react-dom"
1414
import { string as YupString, ValidationError as YupValidationError } from "yup"
1515

1616
import { wrap } from "../../helpers"
@@ -80,6 +80,8 @@ const AutocompleteField = <
8080
return (
8181
<Field {...fieldConfig}>
8282
{({ form, meta }: FieldProps) => {
83+
// TODO: simplify this component and remove this state.
84+
// eslint-disable-next-line react-hooks/rules-of-hooks
8385
const [showError, setShowError] = React.useState(false)
8486

8587
let { sx, onBlur, ...otherTextFieldProps } = textFieldProps

src/components/form/CheckboxField.tsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
1-
import React from "react"
1+
import { Error as ErrorIcon } from "@mui/icons-material"
22
import {
3-
FormControlLabel,
4-
type FormControlLabelProps,
53
Checkbox,
6-
type CheckboxProps,
4+
FormControlLabel,
75
Stack,
6+
type CheckboxProps,
7+
type FormControlLabelProps,
88
} from "@mui/material"
9-
import { Error as ErrorIcon } from "@mui/icons-material"
109
import {
1110
Field,
12-
type FieldProps,
1311
type FieldConfig,
12+
type FieldProps,
1413
type FieldValidator,
1514
} from "formik"
16-
import { bool as YupBool, BooleanSchema, ValidationError } from "yup"
15+
import React from "react"
16+
import { BooleanSchema, ValidationError, bool as YupBool } from "yup"
1717

1818
import { wrap } from "../../helpers"
1919
import { form as formTypography } from "../../theme/typography"
@@ -62,6 +62,8 @@ const CheckboxField: React.FC<CheckboxFieldProps> = ({
6262
return (
6363
<Field {...fieldConfig}>
6464
{({ form, meta }: FieldProps) => {
65+
// TODO: simplify this component and remove this state.
66+
// eslint-disable-next-line react-hooks/rules-of-hooks
6567
const [showError, setShowError] = React.useState(false)
6668

6769
onChange = wrap(

src/components/form/DateField.tsx

+9-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
1-
import React from "react"
21
import {
2+
FormHelperText,
33
Unstable_Grid2 as Grid,
4-
Select,
5-
type SelectProps,
64
MenuItem,
7-
FormHelperText,
5+
Select,
86
type FormHelperTextProps,
97
type SelectChangeEvent,
8+
type SelectProps,
109
} from "@mui/material"
11-
import { Field, type FieldProps, type FieldConfig } from "formik"
10+
import { Field, type FieldConfig, type FieldProps } from "formik"
11+
import React from "react"
1212

13-
import { form as formTypography } from "../../theme/typography"
1413
import { MIN_DATE } from "../../helpers/general"
14+
import { form as formTypography } from "../../theme/typography"
1515

1616
const monthOptions = [
1717
"January",
@@ -62,14 +62,16 @@ const DateField: React.FC<DateFieldProps> = ({
6262
return (
6363
<Field {...fieldConfig}>
6464
{({ form }: FieldProps<Date>) => {
65+
// TODO: simplify this component and relocate this effect.
66+
// eslint-disable-next-line react-hooks/rules-of-hooks
6567
React.useEffect(() => {
6668
const date =
6769
[day, month, year].includes(0) || !isDateValid
6870
? MIN_DATE
6971
: new Date(year, month - 1, day)
7072

7173
form.setFieldValue(name, date, true)
72-
}, [day, month, year])
74+
}, [form])
7375

7476
function getLastDay(month: number, year: number): number {
7577
return new Date(year, month, 0).getDate()

src/components/form/Form.tsx

+2-3
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
1-
import React from "react"
21
import { Stack, type StackProps } from "@mui/material"
32
import {
43
Formik,
5-
type FormikValues,
6-
type FormikConfig,
74
Form as FormikForm,
5+
type FormikConfig,
6+
type FormikValues,
87
} from "formik"
98

109
export interface FormProps<Values> extends FormikConfig<Values> {

src/components/form/TextField.tsx

+15-9
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
1-
import React from "react"
1+
import { ErrorOutline as ErrorOutlineIcon } from "@mui/icons-material"
22
import {
3+
InputAdornment,
34
TextField as MuiTextField,
45
type TextFieldProps as MuiTextFieldProps,
5-
InputAdornment,
66
} from "@mui/material"
7-
import { ErrorOutline as ErrorOutlineIcon } from "@mui/icons-material"
87
import {
98
Field,
10-
type FieldProps,
119
type FieldConfig,
10+
type FieldProps,
1211
type FieldValidator,
1312
} from "formik"
13+
import React from "react"
1414
import {
15-
string as YupString,
16-
array as YupArray,
1715
Schema,
18-
type StringSchema,
19-
type ArraySchema,
20-
type AnyObject,
2116
ValidationError,
17+
array as YupArray,
18+
string as YupString,
19+
type AnyObject,
20+
type ArraySchema,
21+
type StringSchema,
2222
} from "yup"
2323

2424
import { wrap } from "../../helpers"
@@ -92,6 +92,8 @@ const _TextField: React.FC<
9292
return (
9393
<Field {...fieldConfig}>
9494
{({ meta, form }: FieldProps) => {
95+
// TODO: simplify this component and remove this state.
96+
// eslint-disable-next-line react-hooks/rules-of-hooks
9597
const [showError, setShowError] = React.useState(false)
9698

9799
let { endAdornment, ...otherInputProps } = InputProps
@@ -202,6 +204,8 @@ const TextField: ITextField<true> & ITextField<false> = ({
202204

203205
return (
204206
<>
207+
{/* TODO: simplify this component and remove this sub component. */}
208+
{/* eslint-disable-next-line react/jsx-pascal-case */}
205209
<_TextField
206210
validate={validate}
207211
split={split}
@@ -210,6 +214,8 @@ const TextField: ITextField<true> & ITextField<false> = ({
210214
{...otherTextFieldProps}
211215
/>
212216
{repeat.map(({ name, inheritProps = true, ...repeatTextFieldProps }) => (
217+
// TODO: simplify this component and remove this sub component.
218+
// eslint-disable-next-line react/jsx-pascal-case
213219
<_TextField
214220
key={name}
215221
name={name}

src/components/page/TabBar.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ import {
55
import {
66
IconButton,
77
Tab,
8-
type TabScrollButtonProps,
98
Tabs,
109
Typography,
10+
type TabScrollButtonProps,
1111
} from "@mui/material"
1212
import React from "react"
1313
import { generatePath, useNavigate, useParams } from "react-router-dom"
@@ -59,7 +59,7 @@ const TabBar: React.FC<TabBarProps> = ({
5959
if (tab !== undefined) {
6060
_setValue(paths.indexOf(tab))
6161
}
62-
}, [params])
62+
}, [params, paths])
6363

6464
return (
6565
<>

src/helpers/window.ts

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
export function configureFreshworksWidget(display: "open" | "hide"): void {
2+
// @ts-expect-error defined in external script
3+
window.FreshworksWidget(display)
4+
}
5+
6+
export function toggleOneTrustInfoDisplay(): void {
7+
// @ts-expect-error defined in external script
8+
window.Optanon.ToggleInfoDisplay()
9+
}

0 commit comments

Comments
 (0)