1
Fork 0
mirror of https://github.com/Steffo99/sophon.git synced 2024-12-23 07:14:21 +00:00
sophon/frontend/src/App.tsx

113 lines
5.8 KiB
TypeScript
Raw Normal View History

import {faProjectDiagram, faUsers} from "@fortawesome/free-solid-svg-icons"
import * as Reach from "@reach/router"
import {RouteComponentProps} from "@reach/router"
2021-10-12 02:40:48 +00:00
import {Chapter, LayoutThreeCol} from "@steffo/bluelib-react"
import * as React from "react"
import {AuthorizationRouter} from "./components/authorization/AuthorizationRouter"
import {AuthorizationStepPage} from "./components/authorization/AuthorizationStepPage"
import {SophonFooter} from "./components/elements/SophonFooter"
import {ErrorCatcherBox} from "./components/errors/ErrorCatcherBox"
2021-10-13 02:45:53 +00:00
import {ResourceDescriptionBox} from "./components/generic/ResourceDescriptionBox"
import {GroupCreateBox} from "./components/group/GroupCreateBox"
2021-10-07 00:36:49 +00:00
import {GroupListBox} from "./components/group/GroupListBox"
2021-10-12 02:40:48 +00:00
import {GroupMembersBox} from "./components/group/GroupMembersBox"
2021-10-07 00:14:34 +00:00
import {GroupRouter} from "./components/group/GroupRouter"
2021-10-13 03:05:34 +00:00
import {SophonDescriptionBox} from "./components/informative/SophonDescriptionBox"
2021-10-12 00:17:54 +00:00
import {InstanceDescriptionBox} from "./components/instance/InstanceDescriptionBox"
2021-10-13 03:05:34 +00:00
import {InstanceFormBox} from "./components/instance/InstanceFormBox"
import {InstanceRouter} from "./components/instance/InstanceRouter"
import {NotebookListBox} from "./components/notebook/NotebookListBox"
import {NotebookRouter} from "./components/notebook/NotebookRouter"
import {DebugBox} from "./components/placeholder/DebugBox"
import {ProjectListBox} from "./components/project/ProjectListBox"
2021-10-07 03:17:45 +00:00
import {ProjectRouter} from "./components/project/ProjectRouter"
import {ThemedBluelib} from "./components/theme/ThemedBluelib"
import {ThemedTitle} from "./components/theme/ThemedTitle"
import {AuthorizationProvider} from "./contexts/authorization"
import {CacheProvider} from "./contexts/cache"
import {InstanceProvider} from "./contexts/instance"
import {ThemeProvider} from "./contexts/theme"
2021-10-10 15:11:40 +00:00
function App({..._}: RouteComponentProps) {
return React.useMemo(
2021-10-13 03:05:34 +00:00
() => <>
<SophonDescriptionBox/>
<InstanceProvider>
<InstanceRouter
unselectedRoute={() => <>
2021-10-13 03:05:34 +00:00
<InstanceFormBox/>
</>}
selectedRoute={() => <>
2021-10-13 03:05:34 +00:00
<InstanceDescriptionBox/>
<AuthorizationProvider>
<CacheProvider>
<AuthorizationRouter
unselectedRoute={() => <>
<AuthorizationStepPage/>
</>}
selectedRoute={() => <>
<GroupRouter
unselectedRoute={({viewSet}) => <>
<GroupListBox viewSet={viewSet}/>
<GroupCreateBox viewSet={viewSet}/>
</>}
selectedRoute={({selection}) => <>
<Chapter>
<ResourceDescriptionBox resource={selection} icon={faUsers}/>
<GroupMembersBox resource={selection}/>
</Chapter>
<ProjectRouter
groupPk={selection.value.slug}
unselectedRoute={({viewSet}) => <>
<ProjectListBox viewSet={viewSet}/>
<GroupCreateBox resource={selection}/>
</>}
selectedRoute={({selection}) => <>
2021-10-13 03:05:34 +00:00
<ResourceDescriptionBox resource={selection} icon={faProjectDiagram}/>
<NotebookRouter
projectPk={selection.value.slug}
2021-10-13 02:45:53 +00:00
unselectedRoute={({viewSet}) => <>
<NotebookListBox viewSet={viewSet}/>
</>}
selectedRoute={(props) => <>
<DebugBox {...props}/>
</>}
/>
</>}
/>
</>}
/>
</>}
/>
</CacheProvider>
</AuthorizationProvider>
</>}
/>
</InstanceProvider>
2021-10-13 03:05:34 +00:00
</>,
[],
)
}
export default function AppWrapper() {
return (
<ThemeProvider>
<ThemedBluelib>
<LayoutThreeCol>
<LayoutThreeCol.Center>
<ThemedTitle level={1}/>
<ErrorCatcherBox>
<Reach.Router>
<App default/>
</Reach.Router>
</ErrorCatcherBox>
<SophonFooter/>
</LayoutThreeCol.Center>
</LayoutThreeCol>
</ThemedBluelib>
</ThemeProvider>
)
}