-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #66 from intive/P2022-1127
P2022-1127 Routing
- Loading branch information
Showing
13 changed files
with
201 additions
and
176 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,78 @@ | ||
import { useState } from "react"; | ||
import { Routes, Route, useParams, Navigate, Link } from "react-router-dom"; | ||
import { ThemeProvider } from "@mui/material/styles"; | ||
import { theme } from "./theme/mainTheme"; | ||
import { Routes, Route } from "react-router-dom"; | ||
import { Home } from "./views/Home/Home"; | ||
import { SecondPage } from "./views/SecondPage/SecondPage"; | ||
import { Projects } from "./views/Projects/Projects"; | ||
import { Board } from "./views/Board/Board"; | ||
import Navbar from "./components/Navbar/Navbar"; | ||
import { Owl_components } from "./views/Owl/Owl"; | ||
import { Owl_componentsInput } from "./views/OwlInput/OwlInput"; | ||
import { | ||
toProject, | ||
toHome, | ||
toIssue, | ||
toBoard, | ||
toProjects, | ||
} from "./views/routes"; | ||
|
||
const App = () => ( | ||
<> | ||
const Boards = () => { | ||
const { projectID } = useParams(); | ||
|
||
return ( | ||
<div style={{ marginTop: 100 }}> | ||
<h1>Project/Boards list</h1> | ||
{!!projectID && ( | ||
<> | ||
<p>Project: {projectID}</p> | ||
<Link to={toProjects}>Go back to Projects</Link> | ||
<Link style={{ margin: 5 }} to={toBoard({ projectID, boardID: "2" })}> | ||
Go to Board 2 | ||
</Link> | ||
</> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
const Issue = () => { | ||
const { projectID, boardID, issueID } = useParams(); | ||
|
||
return ( | ||
<div style={{ marginTop: 100 }}> | ||
<h1>Issue page</h1> | ||
{!!projectID && !!boardID && !!issueID && ( | ||
<> | ||
<p>Project: {projectID}</p> | ||
<p>Board: {boardID}</p> | ||
<p>Issue: {issueID}</p> | ||
</> | ||
)} | ||
</div> | ||
); | ||
}; | ||
|
||
const App = () => { | ||
const [token, setToken] = useState(true); | ||
|
||
return ( | ||
<ThemeProvider theme={theme}> | ||
<Navbar /> | ||
<Routes> | ||
<Route index element={<Home />} /> | ||
<Route path='second' element={<SecondPage />} /> | ||
<Route path='projects' element={<Projects />} /> | ||
<Route path='projects/:name' element={<Board />} /> | ||
<Route path='owl' element={<Owl_components />} /> | ||
<Route path='owlinput' element={<Owl_componentsInput />} /> | ||
</Routes> | ||
{!token ? ( | ||
<Owl_components | ||
// setToken={setToken} | ||
/> | ||
) : ( | ||
<Routes> | ||
<Route path={toHome} element={<Home />} /> | ||
<Route path={toProjects} element={<Projects />} /> | ||
<Route path={toProject()} element={<Boards />} /> | ||
<Route path={toBoard()} element={<Board />} /> | ||
<Route path={toIssue()} element={<Issue />} /> | ||
<Route path='*' element={<Navigate to={toProjects} />} /> | ||
</Routes> | ||
)} | ||
</ThemeProvider> | ||
</> | ||
); | ||
); | ||
}; | ||
|
||
export default App; |
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,13 @@ | ||
import { styled } from "@mui/material/styles"; | ||
import Box from "@mui/material/Box"; | ||
import CircularProgress from "@mui/material/CircularProgress"; | ||
|
||
export const LoaderWrapper = styled(Box)(({ theme }) => ({ | ||
display: "flex", | ||
justifyContent: "center", | ||
marginTop: 300, | ||
})); | ||
|
||
export const StyledLoader = styled(CircularProgress)(({ theme }) => ({ | ||
color: theme.palette.grey[600], | ||
})); |
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,27 @@ | ||
import { Navigate } from "react-router-dom"; | ||
|
||
import { toHome } from "../../views/routes"; | ||
import { LoaderWrapper, StyledLoader } from "./Content.styled"; | ||
interface ContentProps { | ||
isLoading: boolean; | ||
noContentToShow: boolean; | ||
children: JSX.Element; | ||
} | ||
|
||
const Content = ({ isLoading, noContentToShow, children }: ContentProps) => { | ||
if (isLoading) { | ||
return ( | ||
<LoaderWrapper> | ||
<StyledLoader size={50} /> | ||
</LoaderWrapper> | ||
); | ||
} | ||
|
||
if (noContentToShow) { | ||
return <Navigate to={toHome} />; | ||
} | ||
|
||
return children; | ||
}; | ||
|
||
export default Content; |
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,6 @@ | ||
declare module "*.svg" { | ||
import React = require("react"); | ||
export const ReactComponent: React.FC<React.SVGProps<SVGSVGElement>>; | ||
const src: string; | ||
export default src; | ||
} |
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
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 was deleted.
Oops, something went wrong.
Oops, something went wrong.