refactor:

This commit is contained in:
Arek 2022-06-09 01:54:13 +02:00
parent a4a9c1c640
commit 2cbd9c29d7
4 changed files with 76 additions and 30 deletions

View File

@ -28,21 +28,21 @@
<img src="src/mail.svg">
<input placeholder="Email" id="regmail">
<br>
<img src="src/phone.svg">
<input placeholder="Telefon" id="regphone">
<br>
<img src="src/lock.svg">
<input placeholder="Hasło" type="password" id="regpassword" name="password">
<i class="bi bi-eye-slash" id="togglePassword"></i>
<br>
<img src="src/lock.svg">
<input placeholder="Potwierdź hasło" type="password" id="password2" name="password">
<i class="bi bi-eye-slash" id="togglePassword2"></i>
<form action="#">
<form action="reg" onclick="register()">
<input class="myButton" type="submit" value="Zarejestruj" id="regsubmit" />
</form>

View File

@ -28,4 +28,35 @@ document.getElementById("regsubmit").addEventListener("click", function () {
}
xhttp.open("PUT", "https://dragonmaster.pl/inz/user/create");
xhttp.send('{"username":"' + document.getElementById("regusername").value + '","name":"' + document.getElementById("regname").value + '","surname":"' + document.getElementById("regsurname").value + '","password":"' + document.getElementById("regpassword").value + '","mail":"' + document.getElementById("regmail").value + '","phone":"' + document.getElementById("regphone").value + '"}');
});
});
function register() {
fetch('https://dragonmaster.pl/inz/user/create', {
method: "PSOT",
headers: {
'Content-type': 'application/json'
},
body: JSON.stringify(
{
"username": document.getElementById("regusername").value,
"name": document.getElementById("regname").value,
"surname": document.getElementById("regsurname").value,
"password": document.getElementById("regpassword").value,
"mail": document.getElementById("regmail").value,
"phone": document.getElementById("regphone").value
}
)
}
)
.then(res => {
if (res.ok) {
alert("Teraz mozesz się zalogować!")
window.open("../panel_organizatora/logowanie/index.html");
}
else { console.log("Coś poszło nie tak!") }
return res
})
.then(res => res.json())
.then(data => console.log(data))
.catch(error => console.log(error))
}

View File

@ -0,0 +1,8 @@
{
"username": "string",
"name": "string",
"surname": "string",
"password": "string",
"mail": "string",
"phone": "string"
}

View File

@ -32,31 +32,6 @@
// console.error(error);
// });
// fetch(url)
// .then(response => response.json())
// .then((data) => {
// let tournaments = data;
// tournaments.map(function (tournament) {
// let li = document.createElement('li');
// let name = document.createElement('h2');
// let email = document.createElement('span');
// name.innerHTML = '${tournament.name}';
// id.innerHTML = '${tournament.id}';
// li.appendChild(name);
// li.appendChild(id);
// });
// })
// .catch(function (error) {
// console.log(error);
// });
// ul.appendChild(list);
// console.log(fetch('https://dragonmaster.pl/inz/tournaments'))
async function showTournaments() {
let url = 'https://dragonmaster.pl/inz/tournaments';
@ -78,4 +53,36 @@ async function renderTournaments() {
let container = document.querySelector('.tournament-list');
container.innerHTML = html;
}
function register() {
fetch('https://dragonmaster.pl/inz/user/create', {
method: "PUT",
headers: {
'Content-type': 'application/json'
},
body: JSON.stringify(
{
"username": "jaro",
"name": "maro",
"surname": "siaro",
"password": "jaro",
"mail": "jaro@wp.pl",
"phone": "1234567"
}
)
}
)
.then(res => {
if (res.ok) {
alert("Teraz mozesz się zalogować!")
window.open("../panel_organizatora/logowanie/index.html");
}
else { console.log("Coś poszło nie tak!") }
return res
})
.then(res => res.json())
.then(data => console.log(data))
.catch(error => console.log(error))
}