1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-22 06:44:21 +00:00

Create ProjectRouter

This commit is contained in:
Steffo 2021-10-07 05:17:45 +02:00
parent abce14d1bf
commit 1d5f142c09
2 changed files with 32 additions and 1 deletions

View file

@ -11,6 +11,7 @@ import {GroupRouter} from "./components/group/GroupRouter"
import {InstanceRouter} from "./components/instance/InstanceRouter"
import {InstanceStepPage} from "./components/instance/InstanceStepPage"
import {DebugBox} from "./components/placeholder/DebugBox"
import {ProjectRouter} from "./components/project/ProjectRouter"
import {ThemedBluelib} from "./components/theme/ThemedBluelib"
import {ThemedTitle} from "./components/theme/ThemedTitle"
import {AuthorizationProvider} from "./contexts/authorization"
@ -34,7 +35,13 @@ function App({}: RouteComponentProps) {
selectedRoute={() => <>
<GroupRouter
unselectedRoute={(props) => <GroupListBox viewSet={props.viewSet}/>}
selectedRoute={DebugBox}
selectedRoute={(props) => <>
<ProjectRouter
groupPk={props.selection.value.slug}
unselectedRoute={DebugBox}
selectedRoute={DebugBox}
/>
</>}
/>
</>}
/>

View file

@ -0,0 +1,24 @@
import * as React from "react"
import {useManagedViewSet} from "../../hooks/useManagedViewSet"
import {Dict} from "../../types/ExtraTypes"
import {SophonResearchProject} from "../../types/SophonTypes"
import {ViewSetRouter} from "../routing/ViewSetRouter"
export interface ProjectRouterProps {
groupPk: string,
unselectedRoute: (props: Dict<any>) => JSX.Element | null,
selectedRoute: (props: Dict<any>) => JSX.Element | null,
}
export function ProjectRouter({groupPk, ...props}: ProjectRouterProps): JSX.Element {
return (
<ViewSetRouter
{...props}
viewSet={useManagedViewSet<SophonResearchProject>(`/api/projects/by-group/${groupPk}`, "slug")}
pathSegment={"researchGroup"}
pkKey={"slug"}
/>
)
}