瀏覽代碼

fix: form submit -> post request payload was missing product

IceToast 3 年之前
父節點
當前提交
da57e37008
共有 3 個文件被更改,包括 49 次插入21 次删除
  1. 17 1
      public/css/app.css
  2. 0 1
      public/js/app.js
  3. 32 19
      resources/views/servers/create.blade.php

File diff suppressed because it is too large
+ 17 - 1
public/css/app.css


File diff suppressed because it is too large
+ 0 - 1
public/js/app.js


+ 32 - 19
resources/views/servers/create.blade.php

@@ -148,17 +148,17 @@
 
 
 
 
                             <!-- <div class="form-group">
                             <!-- <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>
                     </div>
                     </div>
 
 
@@ -224,15 +224,19 @@
 
 
                                     <div class="mt-auto border rounded border-secondary">
                                     <div class="mt-auto border rounded border-secondary">
                                         <div class="d-flex justify-content-between p-2">
                                         <div class="d-flex justify-content-between p-2">
-                                            <span class="d-inline-block">
+                                            <span class="d-inline-block mr-4">
                                                 {{ __('Price') }}:
                                                 {{ __('Price') }}:
                                             </span>
                                             </span>
                                             <span class="d-inline-block" x-text="product.price + ' Credits'"></span>
                                             <span class="d-inline-block" x-text="product.price + ' Credits'"></span>
                                         </div>
                                         </div>
                                     </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>
                             </div>
                     </div>
                     </div>
@@ -304,6 +308,19 @@
                     this.updateSelectedObjects()
                     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
                  * @description fetch all available locations based on the selected egg
                  * @note called whenever a server configuration is selected
                  * @note called whenever a server configuration is selected
@@ -353,11 +370,6 @@
                     this.fetchedProducts = true;
                     this.fetchedProducts = true;
                     this.products = response.data
                     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.loading = false;
                     this.updateSelectedObjects()
                     this.updateSelectedObjects()
                 },
                 },
@@ -379,6 +391,7 @@
                     })
                     })
 
 
                     this.selectedProductObject = this.products.find(product => product.id == this.selectedProduct) ?? {}
                     this.selectedProductObject = this.products.find(product => product.id == this.selectedProduct) ?? {}
+                    console.log(this.selectedProduct, this.selectedProductObject, this.products)
                 },
                 },
 
 
                 /**
                 /**

Some files were not shown because too many files changed in this diff