AutoCallManu/www/dashboard/contacts/create.html

128 lines
2.9 KiB
HTML

<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Utilisateurs</title>
<style>
body {
font-family: Arial, Helvetica, sans-serif;
background-color: black;
}
* {
box-sizing: border-box;
}
/* Add padding to containers */
.container {
padding: 16px;
background-color: white;
display: block;
position: relative;
padding-left: 35px;
margin-bottom: 12px;
cursor: pointer;
font-size: 22px;
-webkit-user-select: none;
-moz-user-select: none;
-ms-user-select: none;
user-select: none;
}
/* Full-width input fields */
input[type=text], input[type=password], input[type=tel] {
width: 100%;
padding: 15px;
margin: 5px 0 22px 0;
display: inline-block;
border: none;
background: #f1f1f1;
}
input[type=text]:focus, input[type=password]:focus {
background-color: #ddd;
outline: none;
}
/* Overwrite default styles of hr */
hr {
border: 1px solid #f1f1f1;
margin-bottom: 25px;
}
/* Set a style for the submit button */
.registerbtn {
background-color: #04AA6D;
color: white;
padding: 16px 20px;
margin: 8px 0;
border: none;
cursor: pointer;
width: 100%;
opacity: 0.9;
}
.registerbtn:hover {
opacity: 1;
}
/* Add a blue text color to links */
a {
color: dodgerblue;
}
/* Set a grey background color and center the text of the "sign in" section */
.signin {
background-color: #f1f1f1;
text-align: center;
}
</style>
<script>
function createContactFromForm() {
const form = document.getElementById("contactCreateForm");
fetch(`/api/contacts/${form.phone.value}`, {
method: "POST",
body: JSON.stringify({
phone: form.phone.value,
firstName: form.firstName.value,
lastName: form.lastName.value,
}),
headers: {
"Content-type": "application/json; charset=UTF-8"
}
})
.then(async (response) => {
const res = await response.json();
console.log(res);
if(!response.ok) return alert(res.message);
form.reset();
});
}
</script>
</head>
<body>
<NAVBAR>
<form action="javascript:createContactFromForm()" id="contactCreateForm">
<div class="container">
<h1>Création de contact</h1>
<p>Formulaire d'ajout de contact.</p>
<hr>
<label for="phone"><b>Numéro de téléphone</b></label>
<input type="tel" placeholder="Entrez le numéro de téléphone" name="phone" id="phone" required>
<label for="firstName"><b>Prénom</b></label>
<input type="text" placeholder="Prénom du contact" name="firstName" id="firstName" required>
<label for="lastName"><b>Nom</b></label>
<input type="text" placeholder="Nom du contact" name="lastName" id="lastName" required>
<hr>
<button type="submit" class="registerbtn">Register</button>
</div>
</form>
</body>
</html>