first fixes

This commit is contained in:
Kevin
2026-06-29 22:48:59 +02:00
parent 184de52ad2
commit 66a97be5c6
25 changed files with 646 additions and 471 deletions
+9 -10
View File
@@ -2,19 +2,18 @@
import { computed, reactive } from 'vue'
import { Link, useForm } from '@inertiajs/vue3'
const props = defineProps<{ types: any[]; errors?: any[] }>()
const errors = computed(() => props.errors || [])
const props = defineProps<{ types: any[]; errors?: Record<string, string> }>()
const errors = computed(() => props.errors || {})
const form = reactive({
name: '',
price: 0,
type_id: null,
purchase_date: new Date().toISOString().split('T')[0],
typeId: null,
purchaseDate: new Date().toISOString().split('T')[0],
quantity: 1,
})
function getErrorMessage(field: string): string | null {
const error = errors.value.find((error) => error.field === field)
return error ? error.message : null
return errors.value[field] || null
}
function formatDateForMySQL(date: string) {
@@ -60,8 +59,8 @@ function submitForm() {
<div>
<label class="block text-gray-700 text-sm font-bold mb-2" for="type">Type</label>
<select
name="type_id"
v-model.number="form.type_id"
name="typeId"
v-model.number="form.typeId"
id="type"
class="w-full mt-2 border-gray-200 focus:border-indigo-600 focus:ring-indigo-500 px-3 py-2 focus:ring-1 border rounded text-gray-700 bg-white"
>
@@ -77,8 +76,8 @@ function submitForm() {
>Purchase Date</label
>
<input
name="purchase_date"
v-model="form.purchase_date"
name="purchaseDate"
v-model="form.purchaseDate"
class="w-full mt-2 border-gray-200 focus:border-indigo-600 focus:ring focus:ring-indigo-500/40 border rounded text-gray-700 px-3 py-2"
type="date"
/>