Skip to content

Commit

Permalink
Added React Router DOM for Admin Client navigation
Browse files Browse the repository at this point in the history
  • Loading branch information
arkajyotiadhikary committed Mar 24, 2024
1 parent 5c4f1c4 commit ee59b2e
Show file tree
Hide file tree
Showing 11 changed files with 116 additions and 67 deletions.
64 changes: 64 additions & 0 deletions admin-client/package-lock.json

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

2 changes: 2 additions & 0 deletions admin-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,10 @@
"@types/node": "^16.18.90",
"@types/react": "^18.2.67",
"@types/react-dom": "^18.2.22",
"@types/react-router-dom": "^5.3.3",
"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
9 changes: 0 additions & 9 deletions admin-client/src/App.test.tsx

This file was deleted.

28 changes: 7 additions & 21 deletions admin-client/src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,26 +1,12 @@
import React from 'react';
import logo from './logo.svg';
import './App.css';
import "./App.css";
import { Outlet } from "react-router-dom";

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>
);
return (
<div className="App">
<Outlet />
</div>
);
}

export default App;
26 changes: 10 additions & 16 deletions admin-client/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";

const root = ReactDOM.createRoot(
document.getElementById('root') as HTMLElement
);
import { RouterProvider } from "react-router-dom";
import { Router } from "./routes/routes";

const root = ReactDOM.createRoot(document.getElementById("root") as HTMLElement);
root.render(
<React.StrictMode>
<App />
</React.StrictMode>
<React.StrictMode>
<RouterProvider router={Router} />
</React.StrictMode>
);

// If you want to start measuring performance in your app, pass a function
// to log results (for example: reportWebVitals(console.log))
// or send to an analytics endpoint. Learn more: https://bit.ly/CRA-vitals
reportWebVitals();
1 change: 0 additions & 1 deletion admin-client/src/logo.svg

This file was deleted.

8 changes: 8 additions & 0 deletions admin-client/src/pages/auth.page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { useState } from "react";

const Auth = () => {
const [login, setLogin] = useState<boolean>(false);
return <div className="Auth">{login ? "Login" : "Register"}</div>;
};

export default Auth;
5 changes: 5 additions & 0 deletions admin-client/src/pages/upload.page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const Upload = () => {
return <div className="upload">upload</div>;
};

export default Upload;
15 changes: 0 additions & 15 deletions admin-client/src/reportWebVitals.ts

This file was deleted.

20 changes: 20 additions & 0 deletions admin-client/src/routes/routes.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { createBrowserRouter } from "react-router-dom";
import App from "../App";

// pages
import Auth from "../pages/auth.page";
import Upload from "../pages/upload.page";

export const Router = createBrowserRouter([
{
path: "/",
element: <App />,
children: [
{
path: "/auth",
element: <Auth />,
},
{ path: "/upload", element: <Upload /> },
],
},
]);
5 changes: 0 additions & 5 deletions admin-client/src/setupTests.ts

This file was deleted.

0 comments on commit ee59b2e

Please sign in to comment.