forked from CRM_Production/JTT_CrM
Merge branch 'master' of https://codefirst.iut.uca.fr/git/CRM_Production/JTT_CrM
commit
575d3f7c21
@ -0,0 +1,6 @@
|
||||
projectKey=jtt_crm
|
||||
serverUrl=https://codefirst.iut.uca.fr/sonar
|
||||
serverVersion=9.6.1.59531
|
||||
dashboardUrl=https://codefirst.iut.uca.fr/sonar/dashboard?id=jtt_crm
|
||||
ceTaskId=AYSvDEjizKKB0GF_0uUi
|
||||
ceTaskUrl=https://codefirst.iut.uca.fr/sonar/api/ce/task?id=AYSvDEjizKKB0GF_0uUi
|
@ -0,0 +1,18 @@
|
||||
{
|
||||
"configurations": [
|
||||
{
|
||||
"name": "macos-clang-arm64",
|
||||
"includePath": [
|
||||
"${workspaceFolder}/**"
|
||||
],
|
||||
"compilerPath": "/usr/bin/clang",
|
||||
"cStandard": "${default}",
|
||||
"cppStandard": "${default}",
|
||||
"intelliSenseMode": "macos-clang-arm64",
|
||||
"compilerArgs": [
|
||||
""
|
||||
]
|
||||
}
|
||||
],
|
||||
"version": 4
|
||||
}
|
@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "C/C++ Runner: Debug Session",
|
||||
"type": "lldb",
|
||||
"request": "launch",
|
||||
"args": [],
|
||||
"cwd": "/Users/malanone/JTT_Production/JTT_CrM",
|
||||
"program": "/Users/malanone/JTT_Production/JTT_CrM/build/Debug/outDebug"
|
||||
}
|
||||
]
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
{
|
||||
"C_Cpp_Runner.cCompilerPath": "clang",
|
||||
"C_Cpp_Runner.cppCompilerPath": "clang++",
|
||||
"C_Cpp_Runner.debuggerPath": "lldb",
|
||||
"C_Cpp_Runner.cStandard": "",
|
||||
"C_Cpp_Runner.cppStandard": "",
|
||||
"C_Cpp_Runner.msvcBatchPath": "",
|
||||
"C_Cpp_Runner.useMsvc": false,
|
||||
"C_Cpp_Runner.warnings": [
|
||||
"-Wall",
|
||||
"-Wextra",
|
||||
"-Wpedantic",
|
||||
"-Wshadow",
|
||||
"-Wformat=2",
|
||||
"-Wconversion",
|
||||
"-Wnull-dereference",
|
||||
"-Wsign-conversion"
|
||||
],
|
||||
"C_Cpp_Runner.enableWarnings": true,
|
||||
"C_Cpp_Runner.warningsAsError": false,
|
||||
"C_Cpp_Runner.compilerArgs": [],
|
||||
"C_Cpp_Runner.linkerArgs": [],
|
||||
"C_Cpp_Runner.includePaths": [],
|
||||
"C_Cpp_Runner.includeSearch": [
|
||||
"*",
|
||||
"**/*"
|
||||
],
|
||||
"C_Cpp_Runner.excludeSearch": [
|
||||
"**/build",
|
||||
"**/build/**",
|
||||
"**/.*",
|
||||
"**/.*/**",
|
||||
"**/.vscode",
|
||||
"**/.vscode/**"
|
||||
]
|
||||
}
|
@ -1,42 +1,97 @@
|
||||
import React, {useState} from 'react'
|
||||
import {useNavigate} from 'react-router-dom';
|
||||
import React, { useState, useEffect } from 'react';
|
||||
import axios from 'axios'
|
||||
import NavigationDashboard from '../NavigationDashboard.js';
|
||||
import CryptoJS from 'crypto-js';
|
||||
import Select, { SelectChangeEvent } from '@mui/material/Select';
|
||||
import MenuItem from '@mui/material/MenuItem';
|
||||
import { NavLink } from 'react-router-dom';
|
||||
import { useNavigate } from "react-router-dom";
|
||||
import { Button } from '@mui/material';
|
||||
import Session from 'react-session-api';
|
||||
// HERE ABOVE useHistory IS REPLACED WITH useNavigate
|
||||
|
||||
function AddContact(props) {
|
||||
|
||||
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('/');
|
||||
}
|
||||
|
||||
const api = axios.create({
|
||||
baseURL: 'http://localhost:8080'
|
||||
})
|
||||
|
||||
function AddContact() {
|
||||
|
||||
const [loginError, setLoginError] = useState(false);
|
||||
const [entreprises, setEntreprises] = useState([]);
|
||||
const [selectedIdEntreprise, setSelectedIdEntreprise] = useState(1);
|
||||
const navigate = useNavigate();
|
||||
|
||||
useEffect(() => {
|
||||
api.get('/Entreprise/All').then((response) => {
|
||||
setEntreprises(response.data);
|
||||
});
|
||||
}, []);
|
||||
|
||||
function handleChangeEntreprise(event) {
|
||||
setSelectedIdEntreprise(event.target.value);
|
||||
console.log("je suis dans handleChangeEntreprise");
|
||||
};
|
||||
|
||||
function checkAdd(event) {
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
const formData = new FormData(event.currentTarget);
|
||||
const values = Object.fromEntries(formData.entries());
|
||||
api.get('/Contact/Exist/' + values.phone).then((response) => {
|
||||
const login = response.data;
|
||||
if (login.length > 0) {
|
||||
setLoginError(true);
|
||||
}
|
||||
else {
|
||||
setLoginError(false);
|
||||
const newContact = { firstname: values.firstname, lastname: values.lastname, phone: values.phone, mail: values.mail, iduser: Session.get('idUser'), idcustomer: selectedIdEntreprise };
|
||||
api.post('/Contact/Add', newContact).then(function (response) {
|
||||
console.log(response.data);
|
||||
});
|
||||
navigate("/Repertoire");
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
};
|
||||
|
||||
|
||||
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 className='addContactPage'>
|
||||
<h2>Ajouter un nouveau contact</h2>
|
||||
<div className="Formulaire">
|
||||
<form className="form" onSubmit={checkAdd}>
|
||||
<table className="Formulaire_de_connexion">
|
||||
<tr>
|
||||
<div className="texte_côté">
|
||||
<p>Nom :</p>
|
||||
<p>Prénom :</p>
|
||||
<p>Téléphone :</p>
|
||||
<p>Email :</p>
|
||||
<p>Entreprise :</p>
|
||||
</div>
|
||||
</tr>
|
||||
<tr>
|
||||
<input id="nom" name='firstname' className="texte_zone" type="text" placeholder="Nom..." required />
|
||||
<input id="prenom" name='lastname' className="texte_zone" type="text" placeholder="Prénom..." required />
|
||||
<input id="phone" name='phone' className="texte_zone" type="tel"
|
||||
placeholder="Téléphone..." pattern="[0-9]{10}" required />
|
||||
<input id="email" name='mail' className="texte_zone" type="email" placeholder="Email..." required />
|
||||
<Select name='idcustomer' value={selectedIdEntreprise} onChange={handleChangeEntreprise}>
|
||||
{entreprises.map(entreprise => (<MenuItem value={entreprise.idcustomer}>{entreprise.name}</MenuItem>))}
|
||||
</Select>
|
||||
</tr>
|
||||
</table>
|
||||
<p>{loginError === true ? "Le contact existe déja" : ''}</p>
|
||||
<div className="bouton_submit">
|
||||
<button className="bouton_val" type="submit">Valider</button>
|
||||
<NavLink className="bouton_ann" to="/Repertoire">Retour</NavLink>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default AddContact
|
||||
export default AddContact;
|
||||
|
@ -1,11 +0,0 @@
|
||||
import React from 'react';
|
||||
|
||||
const Menu = () => {
|
||||
return (
|
||||
<div>
|
||||
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default Menu;
|
@ -0,0 +1,8 @@
|
||||
.addContactPage{
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
justify-content: space-around;
|
||||
align-items: center;
|
||||
|
||||
|
||||
}
|
Loading…
Reference in new issue