fix: form submit -> post request payload was missing product
This commit is contained in:
parent
e07ad87ea9
commit
da57e37008
3 changed files with 623 additions and 26 deletions
29
public/css/app.css
vendored
29
public/css/app.css
vendored
File diff suppressed because one or more lines are too long
569
public/js/app.js
vendored
569
public/js/app.js
vendored
File diff suppressed because one or more lines are too long
|
@ -148,17 +148,17 @@
|
|||
|
||||
|
||||
<!-- <div class="form-group">
|
||||
<label for="product">{{ __('Resources') }}</label>
|
||||
<select name="product" required id="product" :disabled="!fetchedProducts"
|
||||
x-model="selectedProduct" @change="updateSelectedObjects()" class="custom-select">
|
||||
<option x-text="getProductInputText()" disabled selected hidden value="null"></option>
|
||||
<template x-for="product in products" :key="product.id">
|
||||
<option :disabled="product.minimum_credits > user.credits"
|
||||
x-text="getProductOptionText(product)" :value="product.id">
|
||||
</option>
|
||||
</template>
|
||||
</select>
|
||||
</div> -->
|
||||
<label for="product">{{ __('Resources') }}</label>
|
||||
<select name="product" required id="product" :disabled="!fetchedProducts"
|
||||
x-model="selectedProduct" @change="updateSelectedObjects()" class="custom-select">
|
||||
<option x-text="getProductInputText()" disabled selected hidden value="null"></option>
|
||||
<template x-for="product in products" :key="product.id">
|
||||
<option :disabled="product.minimum_credits > user.credits"
|
||||
x-text="getProductOptionText(product)" :value="product.id">
|
||||
</option>
|
||||
</template>
|
||||
</select>
|
||||
</div> -->
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
@ -224,15 +224,19 @@
|
|||
|
||||
<div class="mt-auto border rounded border-secondary">
|
||||
<div class="d-flex justify-content-between p-2">
|
||||
<span class="d-inline-block">
|
||||
<span class="d-inline-block mr-4">
|
||||
{{ __('Price') }}:
|
||||
</span>
|
||||
<span class="d-inline-block" x-text="product.price + ' Credits'"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<button type="button" class="mt-2 btn btn-primary"
|
||||
:disabled="product.minimum_credits > user.credits">Create Server</button>
|
||||
<button type="submit" x-model="selectedProduct" name="product"
|
||||
:disabled="product.minimum_credits > user.credits"
|
||||
:class="product.minimum_credits > user.credits ? 'disabled' : ''"
|
||||
class="btn btn-primary btn-block mt-2" @click="setProduct(product.id)"
|
||||
x-text=" product.minimum_credits > user.credits ? 'Not enough credits!' : 'Create server'">
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -304,6 +308,19 @@
|
|||
this.updateSelectedObjects()
|
||||
},
|
||||
|
||||
setProduct(productId) {
|
||||
if (!productId) return
|
||||
|
||||
this.selectedProduct = productId;
|
||||
this.updateSelectedObjects();
|
||||
|
||||
},
|
||||
|
||||
debuggershit(e) {
|
||||
this
|
||||
|
||||
},
|
||||
|
||||
/**
|
||||
* @description fetch all available locations based on the selected egg
|
||||
* @note called whenever a server configuration is selected
|
||||
|
@ -353,11 +370,6 @@
|
|||
this.fetchedProducts = true;
|
||||
this.products = response.data
|
||||
|
||||
//automatically select the first entry if there is only 1
|
||||
if (this.products.length === 1) {
|
||||
this.selectedProduct = this.products[0].id;
|
||||
}
|
||||
|
||||
this.loading = false;
|
||||
this.updateSelectedObjects()
|
||||
},
|
||||
|
@ -379,6 +391,7 @@
|
|||
})
|
||||
|
||||
this.selectedProductObject = this.products.find(product => product.id == this.selectedProduct) ?? {}
|
||||
console.log(this.selectedProduct, this.selectedProductObject, this.products)
|
||||
},
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue