first fixes
This commit is contained in:
@@ -6,23 +6,22 @@ const { props } = usePage<{
|
||||
component: any
|
||||
types: any[]
|
||||
origin: string
|
||||
errors?: any[]
|
||||
errors?: Record<string, string>
|
||||
}>()
|
||||
const { component, types, origin } = props
|
||||
const errors = computed(() => props.errors || [])
|
||||
const errors = computed(() => props.errors || {})
|
||||
|
||||
const form = reactive({
|
||||
id: component.id,
|
||||
name: component.name,
|
||||
price: component.price,
|
||||
type_id: component.type.id,
|
||||
purchase_date: component.purchaseDate,
|
||||
typeId: component.type.id,
|
||||
purchaseDate: component.purchaseDate,
|
||||
origin: origin,
|
||||
})
|
||||
|
||||
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) {
|
||||
@@ -62,7 +61,7 @@ function formatDateForMySQL(date: string) {
|
||||
<div>
|
||||
<label class="block text-gray-700 text-sm font-bold mb-2" for="type">Type</label>
|
||||
<select
|
||||
v-model="form.type_id"
|
||||
v-model="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"
|
||||
>
|
||||
@@ -78,8 +77,8 @@ function formatDateForMySQL(date: string) {
|
||||
>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"
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user