-
Notifications
You must be signed in to change notification settings - Fork 2
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 #15 from nhattpn/nhat
Add course register and update BE
- Loading branch information
Showing
44 changed files
with
949 additions
and
295 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
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,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; | ||
|
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.
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,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; |
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
File renamed without changes.
18 changes: 18 additions & 0 deletions
18
login-frontend/src/components/dashboard/subjectSchedule.js
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,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; |
Oops, something went wrong.