Skip to content

Commit

Permalink
Merge pull request #15 from nhattpn/nhat
Browse files Browse the repository at this point in the history
Add course register and update BE
  • Loading branch information
nhattpn authored Apr 23, 2024
2 parents ea20a2f + 39366de commit 6619597
Show file tree
Hide file tree
Showing 44 changed files with 949 additions and 295 deletions.
38 changes: 0 additions & 38 deletions login-frontend/src/App.css

This file was deleted.

25 changes: 15 additions & 10 deletions login-frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import React, { useState } from 'react';
import { BrowserRouter as Router, Routes, Route, Link } from 'react-router-dom';
import { BrowserRouter as Router, Routes, Route} from 'react-router-dom';

import './App.css';
import '../node_modules/bootstrap/dist/css/bootstrap.min.css';

import FirstPage from './pages/FirstPage';
import AuthPage from './pages/authPage';
import StudentDashBoard from './pages/StudentDashboard';
import Course from './components/coursePage/Course';
import Course1 from './components/coursePage/Course1';
import StudentDashBoard from './pages/dashboardPage/StudentDashboard';
import Course from './pages/coursePage/Course';
import Course1 from './pages/coursePage/Course1';
import CourseRegistration from './pages/coursePage/CourseRegistration';
import TeacherDashBoard from './pages/dashboardPage/TeacherDashBoard';

function App() {
const [username, setUsername] = useState('');
Expand All @@ -27,19 +28,23 @@ function App() {
const data = await response.text();
setMessage(data);
};

return (
<Router>
<Routes>
<Route path='/' element={<FirstPage />} />
<Route path='/teacher' element={<AuthPage />} />
<Route path='/student' element={<AuthPage />} />
<Route path='/admin' element={<AuthPage />} />
<Route path='/teacher/dashboard' element={< StudentDashBoard/>} />
<Route path='/teacher/login' element={<AuthPage />} />
<Route path='/student/login' element={<AuthPage />} />
<Route path='/admin/login' element={<AuthPage />} />
<Route path='/teacher/changepassword' element={<AuthPage />} />
<Route path='/student/changepassword' element={<AuthPage />} />
<Route path='/admin/changepassword' element={<AuthPage />} />

<Route path='/teacher/dashboard' element={< TeacherDashBoard/>} />
<Route path='/student/dashboard' element={< StudentDashBoard/>} />
<Route path='/admin/dashboard' element={< StudentDashBoard/>} />
<Route path='/course' element={<Course />} />
<Route path='/course1' element={<Course1 />} />
<Route path='/courseRegistration' element={<CourseRegistration />} />
</Routes>
</Router>
);
Expand Down
87 changes: 87 additions & 0 deletions login-frontend/src/components/auth/changePassword.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
import React, { useState } from 'react';
import { useAuth } from '../../hooks/useAuth'; // Assuming useAuth hook exists
import Alert from '@mui/material/Alert'
import { useNavigate } from 'react-router-dom';
function ChangePassword(props) {
const [email, setEmail] = useState('');
const [password, setPassword] = useState('');
const [retypepass, setRetypepass] = useState('');
const [errorMsg, setErrorMsg] = useState(null);
const [successMsg, setSuccessMsg] = useState(null);
const auth = useAuth();
const navigate = useNavigate();
const handleLogin = async (event) => {
event.preventDefault();
try {
const response = await auth.login(email, password);
console.log("response data: ", response);
if (response.message === "Login successful") {
setErrorMsg(null);
setSuccessMsg("Login successful!");
navigate('/student/dashboard');
} else {
setErrorMsg(response.message);
setSuccessMsg(null);
}
} catch (error) {
setErrorMsg(error?.message || "Error");
console.error('Login error:', error.message);
}
};
return (
<div className='login' style={{marginTop: '5vh'}}>
{errorMsg && <Alert severity="error">{errorMsg}</Alert>}
{successMsg && <Alert severity="success">{successMsg}</Alert>}
<form className='was-validated' onSubmit={handleLogin}>
<label htmlFor="email">
<input
className="form-control"
style={{ width: '40vh', height: '6vh'}}
type="email"
placeholder="Enter email address"
value={email}
onChange={(e) => setEmail(e.target.value)}
id="email"
required
/>
<div className="valid-feedback">Valid</div>
<div className="invalid-feedback">Please fill this field</div>
</label>
<label htmlFor="password">
<input
className="form-control"
style={{ width: '40vh', height: '6vh'}}
type="password"
placeholder="New password"
value={password}
onChange={(e) => setPassword(e.target.value)}
id="password"
required
/>
<div className="valid-feedback">Valid</div>
<div className="invalid-feedback">Please fill this field</div>
</label>
<label htmlFor="password">
<input
className="form-control"
style={{ width: '40vh', height: '6vh'}}
type="password"
placeholder="Re-type new password"
value={retypepass}
onChange={(e) => setRetypepass(e.target.value)}
id="password"
required
/>
<div className="valid-feedback">Valid</div>
<div className="invalid-feedback">Please fill this field</div>
</label>
<button style={{padding: '5%', width: '20vh', fontWeight: 'bold', color: 'bisque', margin: '2vh'}} className="btn btn-block bg-primary" type="submit" id="login">
Change Password
</button>
</form>
</div>
);
}

export default ChangePassword;

19 changes: 4 additions & 15 deletions login-frontend/src/components/auth/login.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import React, { useState } from 'react';
import { useAuth } from '../../hooks/useAuth'; // Assuming useAuth hook exists
import Alert from '@mui/material/Alert'
import { BrowserRouter as Router, Routes, Route, Link } from 'react-router-dom';
import { useNavigate } from 'react-router-dom';
function Login(props) {
const [email, setEmail] = useState('');
Expand Down Expand Up @@ -31,10 +30,6 @@ function Login(props) {
}
};

const handleClickChange = () => {
props.handleViewChange('Register');
};

return (
<div className='login' style={{marginTop: '5vh'}}>
{errorMsg && <Alert severity="error">{errorMsg}</Alert>}
Expand All @@ -43,12 +38,12 @@ function Login(props) {
<label htmlFor="email">
<input
className="form-control"
style={{ width: '40vh', height: '6vh'}} // Use object style syntax for consistency
style={{ width: '40vh', height: '6vh'}}
type="email"
placeholder="Enter email address"
value={email}
onChange={(e) => setEmail(e.target.value)}
id="email" // Add ID for proper label association
id="email"
required
/>
<div className="valid-feedback">Valid</div>
Expand All @@ -57,12 +52,12 @@ function Login(props) {
<label htmlFor="password">
<input
className="form-control"
style={{ width: '40vh', height: '6vh'}} // Use object style syntax for consistency
style={{ width: '40vh', height: '6vh'}}
type="password"
placeholder="Enter password"
value={password}
onChange={(e) => setPassword(e.target.value)}
id="password" // Add ID for proper label association
id="password"
required
/>
<div className="valid-feedback">Valid</div>
Expand All @@ -72,12 +67,6 @@ function Login(props) {
Login
</button>
</form>
<p>or doesn't have an account?</p>
<button
className="btn btn-block bg-success" style={{padding: '5%', width: '30vh', fontWeight: 'bold', color: 'bisque', margin: '2vh'}} onClick={handleClickChange}
>
Register
</button>
</div>
);
}
Expand Down
38 changes: 0 additions & 38 deletions login-frontend/src/components/auth/register.js

This file was deleted.

18 changes: 18 additions & 0 deletions login-frontend/src/components/dashboard/lessonPlan.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react'; // Use React for functional components
import '../../../node_modules/bootstrap/dist/css/bootstrap.min.css';
function SubjectSchedule(props){
return(
<>
<nav>
<div className="navigation long_navigation" style={{width: '100%', borderTop: '3px solid blue'}}>
<h3
>
COURSE REGISTRATION
</h3>
</div>
</nav>
<div className='subjectBox' style={{width: '20vh'}}></div>
</>
)
}
export default SubjectSchedule;
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,15 @@ function StudentInfo(props) {
</div>
<div className="data-box">
<p style={{ fontWeight: 'bold' }}>#Class</p>
<p>SV000000</p>
<p>None</p>
<p style={{ fontWeight: 'bold' }}>#Major</p>
<p>None</p>
<p style={{ fontWeight: 'bold' }}>#Faculty</p>
<p>None</p>
</div>
<div className="data-box">
<p style={{ fontWeight: 'bold' }}>#Identity Card Number</p>
<p>SV000000</p>
<p>None</p>
<p style={{ fontWeight: 'bold' }}>#Date of issue of identity card</p>
<p>None</p>
<p style={{ fontWeight: 'bold' }}>#Place of issue of identity card</p>
Expand Down
18 changes: 18 additions & 0 deletions login-frontend/src/components/dashboard/subjectSchedule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react'; // Use React for functional components
import '../../../node_modules/bootstrap/dist/css/bootstrap.min.css';
function SubjectSchedule(props){
return(
<>
<nav>
<div className="navigation long_navigation" style={{width: '100%', borderTop: '3px solid blue'}}>
<h3
>
DASHBOARD
</h3>
</div>
</nav>
<div className='subjectBox' style={{width: '20vh'}}></div>
</>
)
}
export default SubjectSchedule;
Loading

0 comments on commit 6619597

Please sign in to comment.