-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: configure router to go between pods and cronjobs page (#15)
- Loading branch information
1 parent
3ea390e
commit 592a430
Showing
7 changed files
with
201 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { type PropsWithChildren } from "react"; | ||
|
||
import { NamespaceProvider, CurrentNamespaceProvider } from "./namespaces/namespaces"; | ||
|
||
type Provider = ({ children }: PropsWithChildren) => JSX.Element; | ||
|
||
const providers = [NamespaceProvider, CurrentNamespaceProvider]; | ||
|
||
const composeProviders = (providers: Provider[]) => { | ||
// eslint-disable-next-line react/display-name | ||
return providers.reduce((Prev, Curr) => ({ children }: PropsWithChildren) => ( | ||
<Prev> | ||
<Curr>{children}</Curr> | ||
</Prev> | ||
)); | ||
}; | ||
|
||
export const AppProviders = composeProviders(providers); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,16 @@ | ||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; | ||
import type { PropsWithChildren } from "react"; | ||
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"; | ||
import { RouterProvider } from "@tanstack/react-router"; | ||
|
||
import { CronJobs } from "./cron-jobs/cron-jobs"; | ||
import { Layout } from "./layout"; | ||
import { CurrentNamespaceProvider, NamespaceProvider } from "./namespaces/namespaces"; | ||
import { Pods } from "./pods/pods"; | ||
import { router } from "./router"; | ||
|
||
const queryClient = new QueryClient(); | ||
|
||
type Provider = ({ children }: PropsWithChildren) => JSX.Element; | ||
|
||
const providers = [NamespaceProvider, CurrentNamespaceProvider]; | ||
|
||
const composeProviders = (providers: Provider[]) => { | ||
// eslint-disable-next-line react/display-name | ||
return providers.reduce((Prev, Curr) => ({ children }: PropsWithChildren) => ( | ||
<Prev> | ||
<Curr>{children}</Curr> | ||
</Prev> | ||
)); | ||
}; | ||
|
||
const AppProviders = composeProviders(providers); | ||
|
||
export function App() { | ||
return ( | ||
<QueryClientProvider client={queryClient}> | ||
<AppProviders> | ||
<Layout> | ||
{/* <Pods /> */} | ||
<CronJobs /> | ||
</Layout> | ||
</AppProviders> | ||
<RouterProvider router={router} /> | ||
<ReactQueryDevtools /> | ||
</QueryClientProvider> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
import { ReactQueryDevtools } from "@tanstack/react-query-devtools"; | ||
import { Outlet, createReactRouter, createRouteConfig } from "@tanstack/react-router"; | ||
|
||
import { AppProviders } from "./app-providers"; | ||
import { CronJobs } from "./cron-jobs/cron-jobs"; | ||
import { Layout } from "./layout"; | ||
import { Pods } from "./pods/pods"; | ||
|
||
const rootRoute = createRouteConfig({ | ||
component: () => ( | ||
<AppProviders> | ||
<Layout> | ||
<Outlet /> | ||
</Layout> | ||
<ReactQueryDevtools /> | ||
</AppProviders> | ||
), | ||
}); | ||
|
||
const homeRoute = rootRoute.createRoute({ | ||
path: "/", | ||
component: () => <div>TODO: figure out what to show by default</div>, | ||
}); | ||
|
||
const podsRoute = rootRoute.createRoute({ | ||
path: "/pods", | ||
component: Pods, | ||
}); | ||
|
||
const cronJobsRoute = rootRoute.createRoute({ | ||
path: "/cron-jobs", | ||
component: CronJobs, | ||
}); | ||
|
||
const routeConfig = rootRoute.addChildren([homeRoute, podsRoute, cronJobsRoute]); | ||
export const router = createReactRouter({ routeConfig }); | ||
|
||
declare module "@tanstack/react-router" { | ||
interface RegisterRouter { | ||
router: typeof router; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters