|
|
@ -4,7 +4,8 @@ import axios from 'axios';
|
|
|
|
import user from '../images/user.jpg';
|
|
|
|
import user from '../images/user.jpg';
|
|
|
|
import { TableContainer, Table, TableHead, TableBody, TableRow, TableCell } from '@mui/material';
|
|
|
|
import { TableContainer, Table, TableHead, TableBody, TableRow, TableCell } from '@mui/material';
|
|
|
|
import { Paper } from '@mui/material';
|
|
|
|
import { Paper } from '@mui/material';
|
|
|
|
|
|
|
|
import { NavLink } from 'react-router-dom';
|
|
|
|
|
|
|
|
import { useNavigate } from 'react-router-dom';
|
|
|
|
|
|
|
|
|
|
|
|
const api = axios.create({
|
|
|
|
const api = axios.create({
|
|
|
|
baseURL: 'http://localhost:8080'
|
|
|
|
baseURL: 'http://localhost:8080'
|
|
|
@ -12,7 +13,7 @@ const api = axios.create({
|
|
|
|
|
|
|
|
|
|
|
|
function Repertoire() {
|
|
|
|
function Repertoire() {
|
|
|
|
|
|
|
|
|
|
|
|
const [theme, setTheme] = useState("light");
|
|
|
|
const [theme, setTheme] = useState("light");
|
|
|
|
if (localStorage.getItem('theme') && localStorage.getItem("theme") !== '' && localStorage.getItem("theme") !== theme) {
|
|
|
|
if (localStorage.getItem('theme') && localStorage.getItem("theme") !== '' && localStorage.getItem("theme") !== theme) {
|
|
|
|
setTheme(localStorage.getItem("theme"))
|
|
|
|
setTheme(localStorage.getItem("theme"))
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -21,7 +22,7 @@ function Repertoire() {
|
|
|
|
const [SearchTerm, setSearchTerm] = useState("");
|
|
|
|
const [SearchTerm, setSearchTerm] = useState("");
|
|
|
|
const [SearchResults, setSearchResults] = useState([]);
|
|
|
|
const [SearchResults, setSearchResults] = useState([]);
|
|
|
|
const [customers, setCustomers] = useState([]);
|
|
|
|
const [customers, setCustomers] = useState([]);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
useEffect(() => {
|
|
|
|
api.get('/Contact/AllWithCustomerName').then((response) => {
|
|
|
|
api.get('/Contact/AllWithCustomerName').then((response) => {
|
|
|
@ -62,7 +63,9 @@ function Repertoire() {
|
|
|
|
<i class="uil uil-search search-icon"></i>
|
|
|
|
<i class="uil uil-search search-icon"></i>
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<button onClick={ajouter()} className="boutonAddContact">Ajouter</button>
|
|
|
|
<NavLink to="/Repertoire/add">
|
|
|
|
|
|
|
|
<button className="boutonAddContact">Ajouter</button>
|
|
|
|
|
|
|
|
</NavLink>
|
|
|
|
</span>
|
|
|
|
</span>
|
|
|
|
<TableContainer component={Paper} className="tabListContact">
|
|
|
|
<TableContainer component={Paper} className="tabListContact">
|
|
|
|
<Table>
|
|
|
|
<Table>
|
|
|
@ -119,10 +122,44 @@ function Repertoire() {
|
|
|
|
);
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
function ajouter() {
|
|
|
|
function AddContact(props) {
|
|
|
|
console.log("ajouter");
|
|
|
|
|
|
|
|
|
|
|
|
const navigate = useNavigate();
|
|
|
|
|
|
|
|
const [User, setUser] = useState({ name: "", email: "" });
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let add = (e) => {
|
|
|
|
|
|
|
|
e.preventDefault();
|
|
|
|
|
|
|
|
if (User.name === "" || User.email === "") {
|
|
|
|
|
|
|
|
alert("All fields are mandatory!!!");
|
|
|
|
|
|
|
|
return
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
// THIS IS USED TO SHOW THE LIST DATA ON THE APP.JS FILE
|
|
|
|
|
|
|
|
props.addContactHandler(User);
|
|
|
|
|
|
|
|
// THIS IS USED FOR WHEN THE ADD BUTTON IS PRESSED THE INPUT FILED AGAIN GETS EMPTY
|
|
|
|
|
|
|
|
setUser({ name: "", email: "" });
|
|
|
|
|
|
|
|
//console.log(props);
|
|
|
|
|
|
|
|
navigate('/');
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
|
|
|
<div className='ui main'>
|
|
|
|
|
|
|
|
<h2>Add Contact</h2>
|
|
|
|
|
|
|
|
<form className='ui form' onSubmit={add}>
|
|
|
|
|
|
|
|
<div className='field'>
|
|
|
|
|
|
|
|
<label>Name</label>
|
|
|
|
|
|
|
|
<input type="text" name="Name" placeholder='Name' value={User.name} onChange={e => setUser({ ...User, name: e.target.value })} />
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div className='field'>
|
|
|
|
|
|
|
|
<label>Email</label>
|
|
|
|
|
|
|
|
<input type="text" name="Email" placeholder='Email' value={User.email} onChange={e => setUser({ ...User, email: e.target.value })} />
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<button className='ui secondary button'>Add</button>
|
|
|
|
|
|
|
|
</form>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
);
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// function Repertoire() {
|
|
|
|
// function Repertoire() {
|
|
|
|
|
|
|
|
|
|
|
|
// // NOW WITH THE USE OF HOOKS WE WILL GET THE CONTACTS
|
|
|
|
// // NOW WITH THE USE OF HOOKS WE WILL GET THE CONTACTS
|
|
|
|