Skip to content

Commit

Permalink
project setup with React and React Router setup
Browse files Browse the repository at this point in the history
  • Loading branch information
54J4N committed May 25, 2024
1 parent ef1bb90 commit a4ac3d8
Show file tree
Hide file tree
Showing 8 changed files with 776 additions and 18 deletions.
652 changes: 652 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,20 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@emotion/react": "^11.11.4",
"@emotion/styled": "^11.11.5",
"@mui/material": "^5.15.18",
"@reduxjs/toolkit": "^2.2.5",
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.7.2",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-redux": "^9.1.2",
"react-router-dom": "^6.23.1",
"react-scripts": "5.0.1",
"redux": "^5.0.1",
"web-vitals": "^2.1.4"
},
"scripts": {
Expand Down
32 changes: 14 additions & 18 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
import logo from './logo.svg';
import './App.css';
import React from 'react';
import { BrowserRouter as Router, Route, Routes } from 'react-router-dom';
import Navbar from './components/Navbar';
import Dashboard from './components/Dashboard';
import SubmissionForm from './components/SubmissionForm';
import LoginForm from './components/LoginForm';

function App() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<p>
Edit <code>src/App.js</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>
<Navbar />
<Routes>
<Route path="/" element={<Dashboard />} />
<Route path="/submit" element={<SubmissionForm />} />
<Route path="/login" element={<LoginForm />} />
</Routes>
</Router>
);
}

Expand Down
12 changes: 12 additions & 0 deletions src/components/Dashboard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from 'react';

function Dashboard() {
return (
<div>
<h1>Dashboard</h1>
<p>Welcome to your Dashboard. Here you can see the overview of operations.</p>
</div>
);
}

export default Dashboard;
39 changes: 39 additions & 0 deletions src/components/LoginForm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import React, { useState } from 'react';

function LoginForm() {
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');

const handleLogin = (event) => {
event.preventDefault();
// Implement login logic here
console.log(`Login attempt with username: ${username} and password: ${password}`);
};

return (
<div>
<h1>Login</h1>
<form onSubmit={handleLogin}>
<label>
Username:
<input
type="text"
value={username}
onChange={e => setUsername(e.target.value)}
/>
</label>
<label>
Password:
<input
type="password"
value={password}
onChange={e => setPassword(e.target.value)}
/>
</label>
<button type="submit">Login</button>
</form>
</div>
);
}

export default LoginForm;
16 changes: 16 additions & 0 deletions src/components/Navbar.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import React from 'react';
import { Link } from 'react-router-dom';

function Navbar() {
return (
<nav>
<ul>
<li><Link to="/">Dashboard</Link></li>
<li><Link to="/submit">Submit Data</Link></li>
<li><Link to="/login">Login</Link></li>
</ul>
</nav>
);
}

export default Navbar;
27 changes: 27 additions & 0 deletions src/components/SubmissionForm.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React, { useState } from 'react';

function SubmissionForm() {
const [inputValue, setInputValue] = useState('');

const handleSubmit = (event) => {
event.preventDefault();
// Implement what happens when the form is submitted
console.log(inputValue);
};

return (
<form onSubmit={handleSubmit}>
<label>
Enter Data:
<input
type="text"
value={inputValue}
onChange={e => setInputValue(e.target.value)}
/>
</label>
<button type="submit">Submit</button>
</form>
);
}

export default SubmissionForm;
8 changes: 8 additions & 0 deletions src/store.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { configureStore } from '@reduxjs/toolkit';
import submissionReducer from './features/submissions/submissionSlice';

export const store = configureStore({
reducer: {
submissions: submissionReducer
}
});

0 comments on commit a4ac3d8

Please sign in to comment.