This commit is contained in:
2023-07-01 23:22:11 +02:00
parent 2ab62770dc
commit 02e8cf1cd3
10 changed files with 200 additions and 38 deletions

View File

@ -7,17 +7,17 @@
<form class="form_add">
<div class=form_group>
<div class=form_group_label>
<label for="brand">Značka:</label>
<input type="text" name="brand" id="brand" enable>
</div>
<div class=form_group_label>
<label for="name">Název:</label>
<label for="name">Název, značka:</label>
<input type="text" name="name" id="name" enable>
</div>
<div class=form_group_label>
<label for="degree">Stupeň:</label>
<input type="text" name="degree" id="degree" enable>
</div>
<div class=form_group_label>
<label for="percentage">Procento:</label>
<input type="text" name="percentage" id="percentage" enable>
</div>
</div>
<div class=form_group>
@ -26,7 +26,9 @@
<select id="packaging" name="packaging" enable>
<option value="1">Plech</option>
<option value="2">Sklo</option>
<option value="3">Jiné</option>
<option value="3">Sud</option>
<option value="4">Tank</option>
<option value="5">Jiné</option>
</select>
</div>
</div>
@ -38,7 +40,7 @@
<div class="form_group">
<div class=form_group_label>
<label for="photo">Foto:</label>
<input type="file" name="image" id="image" enable>
<input type="file" name="photo" id="photo" enable>
</div>
</div>

View File

@ -9,16 +9,18 @@
<div class=form_group_label>
<label for="user">Uživatel:</label>
<select id="user" name="user" enable>
<option value="">Dž</option>
<option value="">Dý Ej En</option>
<option value="">frfr</option>
<option value="649f42f62b93542c8a465526">Dž</option>
<option value="649f43182b93542c8a465528">Dý Ej En</option>
<option value="649f42c32b93542c8a465524">frfr</option>
<option value="649f43332b93542c8a46552a">Pch</option>
<option value="649f46072b93542c8a46552f">Sš</option>
</select>
</div>
</div>
<div class=form_group>
<div class=form_group_label>
<label for="beer">Beer:</label>
<select name="beer" id="beer">
<select name="beer_id" id="beer_id">
</select>
</div>
</div>
@ -90,7 +92,13 @@
<div class=form_group_label>
<label for="attendedts">S kým:</label>
<input type="text" name="attendedts" id="attendents" enable>
<select id="attendedts" name="attendedts" multiple size="3" enable>
<option value="649f42f62b93542c8a465526">Dž</option>
<option value="649f43182b93542c8a465528">Dý Ej En</option>
<option value="649f42c32b93542c8a465524">frfr</option>
<option value="649f43332b93542c8a46552a">Pch</option>
<option value="649f46072b93542c8a46552f">Sš</option>
</select>
</div>
<div class=form_group_label>
@ -170,10 +178,11 @@
}
return pckgs[id_pckg]
}
(async() => {
// get beers and fill form data
const beerData = await getBeers()
const beer = document.querySelector('#beer')
const beer = document.querySelector('#beer_id')
const beerOptions = beerData?.map((beer) => {
return `

View File

@ -0,0 +1,54 @@
<?php
$API_URL = "http://localhost:6060"
?>
<link rel="stylesheet" href="/css/add.css">
<form class="form_add">
<label for="username">Uživatelské jméno:</label>
<input type="text" name="username" id="username">
<label for="email">E-mail:</label>
<input type="email" name="email" id="email">
<label for="password">Heslo:</label>
<input type="password" name="password" id="password">
<button id="submit" class="btn-send">Registrovat se</button>
</form>
<script>
const btn = document.querySelector('.btn-send')
console.log(btn)
btn.addEventListener('click', (e) => {
e.preventDefault()
send()
})
function send() {
let form = new FormData(document.querySelector("form"));
let body = JSON.stringify(Object.fromEntries(form))
fetch('<?php echo $API_URL;?>/api/v1/user/add', {
credentials: 'include',
headers: {
'Content-Type': 'application/json',
},
method: 'POST',
body: body,
})
.then(res => {
console.log(res)
console.log(res.json())
})
.then(data => {
console.log(data)
})
.catch(err => {
console.log(err)
})
}
</script>