Skip to content

Commit

Permalink
add router, header and footer
Browse files Browse the repository at this point in the history
  • Loading branch information
SKairinos committed Aug 14, 2024
1 parent 82c05c5 commit ccc248d
Showing 1 changed file with 17 additions and 2 deletions.
19 changes: 17 additions & 2 deletions src/components/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@ import { CssBaseline, ThemeProvider } from "@mui/material"
import { type ThemeProviderProps } from "@mui/material/styles/ThemeProvider"
import { type ReactNode, useCallback } from "react"
import { Provider, type ProviderProps } from "react-redux"
import { BrowserRouter, Routes } from "react-router-dom"
import { type Action } from "redux"

import { InactiveDialog, ScreenTimeDialog } from "../features"
import { useCountdown, useEventListener } from "../hooks"
import { useCountdown, useEventListener, useLocation } from "../hooks"
// import "../scripts"
// import {
// configureFreshworksWidget,
Expand All @@ -16,6 +17,10 @@ export interface AppProps<A extends Action = Action, S = unknown> {
theme: ThemeProviderProps["theme"]
store: ProviderProps<A, S>["store"]
children: ReactNode
header?: ReactNode
footer?: ReactNode
headerExcludePaths?: string[]
footerExcludePaths?: string[]
maxIdleSeconds?: number
maxTotalSeconds?: number
}
Expand All @@ -24,11 +29,17 @@ const App = <A extends Action = Action, S = unknown>({
theme,
store,
children,
header, // TODO: "header = <Header />"
footer, // TODO: "footer = <Footer />"
headerExcludePaths = [],
footerExcludePaths = [],
maxIdleSeconds = 60 * 60,
maxTotalSeconds = 60 * 60,
}: AppProps<A, S>): JSX.Element => {
const root = document.getElementById("root") as HTMLElement

const { pathname } = useLocation()

const [idleSeconds, setIdleSeconds] = useCountdown(maxIdleSeconds)
const [totalSeconds, setTotalSeconds] = useCountdown(maxTotalSeconds)
const resetIdleSeconds = useCallback(() => {
Expand Down Expand Up @@ -84,7 +95,11 @@ const App = <A extends Action = Action, S = unknown>({
setTotalSeconds(maxTotalSeconds)
}}
/>
{children}
<BrowserRouter>
{!headerExcludePaths.includes(pathname) && header}
<Routes>{children}</Routes>
{!footerExcludePaths.includes(pathname) && footer}
</BrowserRouter>
</Provider>
</ThemeProvider>
)
Expand Down

0 comments on commit ccc248d

Please sign in to comment.