-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
MehdiAloui
committed
Sep 25, 2023
1 parent
b925bae
commit 5b91789
Showing
17 changed files
with
4,181 additions
and
69 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
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
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
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,91 @@ | ||
import React, { Component } from 'react'; | ||
import EmployeeService from '../servises/EnseignantService'; | ||
import { withRouter } from './withRouter'; | ||
class CreateEmployeeComponent extends Component { | ||
constructor(props) { | ||
super(props) | ||
this.state = { | ||
firstName: '', | ||
lastName: '', | ||
emailId: '', | ||
gender: '' | ||
} | ||
this.changeFirstNameHandler = this.changeFirstNameHandler.bind(this); | ||
this.changeLastNameHandler = this.changeLastNameHandler.bind(this); | ||
this.changeEmailIdHandler = this.changeEmailIdHandler.bind(this); | ||
this.changeGenderIdHandler = this.changeGenderIdHandler.bind(this); | ||
this.saveEmployee = this.saveEmployee.bind(this) | ||
} | ||
changeFirstNameHandler(event) { | ||
this.setState({ firstName: event.target.value }) | ||
|
||
} | ||
changeLastNameHandler(event) { | ||
this.setState({ lastName: event.target.value }) | ||
|
||
} | ||
changeEmailIdHandler(event) { | ||
this.setState({ emailId: event.target.value }) | ||
|
||
} | ||
changeGenderIdHandler(event) { | ||
this.setState({ gender: event.target.value }) | ||
} | ||
|
||
saveEmployee = (e) => { | ||
e.preventDefault(); | ||
|
||
let employee = { firstName: this.state.firstName, lastName: this.state.lastName, emailId: this.state.emailId, gender: this.state.gender }; | ||
console.log('employee=>' + JSON.stringify(employee)); | ||
EmployeeService.createEmployees(employee).then(res => { | ||
this.props.navigate('/employees'); | ||
}); | ||
} | ||
cancel() { | ||
this.props.navigate('/employees'); | ||
} | ||
render() { | ||
return ( | ||
<div> | ||
<div className='container'> | ||
<div className='row'> | ||
<div className='card col-md-6 offset-md-3 offset-md-3'> | ||
<h3 className='text-center'>Add Employee</h3> | ||
<div className='form-group'> | ||
<label> first Name</label> | ||
<input placeholder='First Name' name='firstName' className='form-control' value={this.state.firstName} onChange={this.changeFirstNameHandler} /> | ||
|
||
</div> | ||
<div className='form-group'> | ||
<label> Last Name</label> | ||
<input placeholder='Last Name' name='lastName' className='form-control' value={this.state.lastName} onChange={this.changeLastNameHandler} /> | ||
|
||
</div> | ||
<div className='form-group'> | ||
<label> Email Adress</label> | ||
<input placeholder='Email Adress' name='emailId' className='form-control' value={this.state.emailId} onChange={this.changeEmailIdHandler} /> | ||
|
||
</div> | ||
<div> | ||
<label>Gender</label> | ||
</div> | ||
<div> | ||
<input className="form-check-input" type="radio" value="Male" name="gender" onChange={this.changeGenderIdHandler}/> Male | ||
<input className="form-check-input" type="radio" value="Female" name="gender" onChange={this.changeGenderIdHandler}/> Female | ||
</div> | ||
|
||
|
||
<button className="btn btn-success" onClick={this.saveEmployee}>Save</button> | ||
<button className="btn btn-danger" onClick={this.cancel.bind(this)} >Cancel</button> | ||
|
||
</div> | ||
|
||
</div> | ||
|
||
</div> | ||
</div > | ||
); | ||
} | ||
} | ||
|
||
export default withRouter(CreateEmployeeComponent); |
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,95 @@ | ||
import React, { useState, useEffect } from 'react'; | ||
import axios from 'axios'; | ||
import Modal from 'react-modal'; | ||
|
||
|
||
const Enseignant = () => { | ||
const [enseignants, setEnseignants] = useState([]); | ||
|
||
useEffect(() => { | ||
axios.get('http://localhost:9001/enseignant-service/enseignants') | ||
.then(res => setEnseignants(res.data)) | ||
.catch(err => console.log(err)); | ||
}, []); | ||
|
||
return ( | ||
<div> | ||
<h2 className='text-center'>enseignant List</h2> | ||
<div className='row'> | ||
{/*<button className='btn btn-primary' onClick={this.addEmployee}> Add Employee</button>*/} | ||
</div> | ||
<div className='row'> | ||
<table className='table table-striped table-bordered'> | ||
<thead> | ||
<tr> | ||
<th> | ||
enseignant First name | ||
</th> | ||
<th> | ||
enseignant Last name | ||
</th> | ||
<th> | ||
enseignant Email ID | ||
</th> | ||
<th> | ||
Gender | ||
</th> | ||
<th> | ||
Actions | ||
</th> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
|
||
|
||
{enseignants.map(enseignant => ( | ||
<tr key={enseignant.id}> | ||
<td>{enseignant.nom}</td> | ||
<td>{enseignant.prenom}</td> | ||
<td>{enseignant.cin}</td> | ||
<td>{enseignant.email}</td> | ||
|
||
|
||
<Modal> | ||
<div className='container'> | ||
<div className='row'> | ||
<div className='card col-md-6 offset-md-3 offset-md-3'> | ||
<h3 className='text-center'>Update Employee</h3> | ||
<div className='form-group'> | ||
<label> first Name</label> | ||
<input placeholder='First Name' name='prenom' className='form-control' value={enseignant.nom} /> | ||
|
||
</div> | ||
<div className='form-group'> | ||
<label> Last Name</label> | ||
<input placeholder='Last Name' name='nomame' className='form-control' value={enseignant.prenom} /> | ||
|
||
</div> | ||
<div className='form-group'> | ||
<label> Email Adress</label> | ||
<input placeholder='Email Adress' name='email' className='form-control' value={enseignant.email}/> | ||
|
||
</div> | ||
{/*<button className="btn btn-success" onClick={this.updateEmployee}>Save</button> | ||
<button className="btn btn-danger" onClick={this.handleCloseModal} >Cancel</button>*/} | ||
</div> | ||
</div> | ||
|
||
</div> | ||
{/*<UpdateEmployeeComponent employee={employee} />*/} | ||
</Modal> | ||
<button /*onClick={() => this.deleteEmployee(employee.id)}*/ className="btn btn-info">Delete</button> | ||
|
||
</tr> | ||
))} | ||
|
||
</tbody> | ||
</table> | ||
|
||
|
||
</div> | ||
|
||
</div >)} | ||
|
||
|
||
export default Enseignant; |
Oops, something went wrong.