Add wish type

This commit is contained in:
grandeljay 2022-02-26 23:15:03 +01:00
parent 8e3d06b084
commit 14ee9d09fd
3 changed files with 21 additions and 7 deletions

View file

@ -24,9 +24,11 @@ switch ($_SERVER['REQUEST_METHOD']) {
$database->query('INSERT INTO `wishes`
(
`wishlist`,
`type`,
`url`
) VALUES ('
. $_POST['wishlist_id'] . ',
"' . $_POST['wish_type'] . '",
"' . $_POST['wish_url'] . '"
)
;');

View file

@ -376,6 +376,8 @@ $(function () {
/**
* Add wish
*/
$('.ui.dropdown.types').dropdown();
$(document).on('click', '.button.wishlist-wish-add', function () {
var modalWishlistWishAdd = $('.ui.modal.wishlist-wish-add');
@ -387,17 +389,16 @@ $(function () {
onApprove: function (button) {
button.addClass('loading');
var form = $('.ui.form.wishlist-wish-fetch');
var formData = new URLSearchParams();
formData.append('wishlist_id', form.find('input[name="wishlist_id"]').val());
formData.append('wish_url', form.find('input[name="wish_url"]').val());
var form = $('.ui.form.wishlist-wish-fetch');
var formData = new URLSearchParams(new FormData(form[0]));
fetch('/src/api/wishes.php', {
method: 'POST',
body: formData
body: formData
})
.then(response => response.json())
.then(response => {
.then(handleFetchError)
.then(handleFetchResponse)
.then(function(response) {
if (response.success) {
$('body').toast({
class: 'success',
@ -411,6 +412,9 @@ $(function () {
}
button.removeClass('loading');
})
.catch(function(error) {
console.log(error);
});
return false;

View file

@ -138,6 +138,14 @@ $page->navigation();
<form class="ui form wishlist-wish-fetch" method="post">
<input type="hidden" name="wishlist_id" />
<div class="field">
<label>Type</label>
<select class="ui fluid selection dropdown types" name="wish_type">
<option value="product">Product</option>
<option value="custom" disabled>Custom</option>
</select>
</div>
<div class="field">
<label>URL</label>
<input type="url" name="wish_url" />