Skip to content

Commit

Permalink
Issue ONEST-Network#12 feat: Added Routing
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekpnt committed Apr 17, 2024
1 parent 5e7628b commit 0af8884
Show file tree
Hide file tree
Showing 6 changed files with 99 additions and 17 deletions.
39 changes: 39 additions & 0 deletions seeker-portal/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions seeker-portal/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"@types/react-dom": "^18.2.25",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router-dom": "^6.22.3",
"react-scripts": "5.0.1",
"typescript": "^4.9.5",
"web-vitals": "^2.1.4"
Expand Down
32 changes: 15 additions & 17 deletions seeker-portal/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
import React from 'react';
import logo from './logo.svg';

import './App.css';
import { Route, BrowserRouter as Router, Routes } from "react-router-dom";
import "./App.css";
import { routes as appRoutes } from "./routes";

function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.tsx</code> and save to reload.
</p>
<a
className="App-link"
href="https://reactjs.org"
target="_blank"
rel="noopener noreferrer"
>
Learn React
</a>
</header>
</div>
<Router>
<Routes>
{appRoutes.map((route) => (
<Route
key={route.key}
path={route.path}
element={<route.component />}
/>
))}
</Routes>
</Router> </div>
);
}

Expand Down
6 changes: 6 additions & 0 deletions seeker-portal/src/components/About.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

const About = () => {
return <div>About</div>
}

export default About
6 changes: 6 additions & 0 deletions seeker-portal/src/components/Home.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

const Home = () => {
return <div>Home</div>
}

export default Home
32 changes: 32 additions & 0 deletions seeker-portal/src/routes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import Home from "./components/Home";
import About from "./components/About";

export const pageRoutes = {
HOME: "/",
ABOUT: "/about"
};

interface Route {
key: string;
title: string;
path: string;
enabled: boolean;
component: React.FC<{}>;
}

export const routes: Route[] = [
{
key: "home-route",
title: "HomePage",
path: "/",
enabled: true,
component: Home,
},
{
key: "about-route",
title: "About",
path: "/About",
enabled: true,
component: About,
}
];

0 comments on commit 0af8884

Please sign in to comment.