refaktor címjegyzék
This commit is contained in:
@@ -324,49 +324,21 @@
|
||||
═══════════════════════════════════════════════════ -->
|
||||
<div v-if="activeTab === 'location'" class="max-w-3xl">
|
||||
<form @submit.prevent="saveForm">
|
||||
<!-- Smart Address Form (autocomplete zip/city + structured fields) -->
|
||||
<SharedAddressForm v-model="form.address" />
|
||||
|
||||
<!-- Additional location fields -->
|
||||
<div class="bg-slate-800 rounded-xl border border-slate-700 p-6 mb-6">
|
||||
<h2 class="text-lg font-semibold text-white mb-4">Cím adatok</h2>
|
||||
<h2 class="text-lg font-semibold text-white mb-4">További helyszín adatok</h2>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div class="md:col-span-2">
|
||||
<label class="block text-sm font-medium text-slate-300 mb-1">Teljes cím</label>
|
||||
<label class="block text-sm font-medium text-slate-300 mb-1">Teljes cím szövege</label>
|
||||
<input
|
||||
v-model="form.address"
|
||||
v-model="form.address.full_address_text"
|
||||
placeholder="Teljes cím szövege"
|
||||
class="w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-slate-300 mb-1">Város</label>
|
||||
<input
|
||||
v-model="form.city"
|
||||
placeholder="Budapest"
|
||||
class="w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-slate-300 mb-1">Irányítószám</label>
|
||||
<input
|
||||
v-model="form.address_zip"
|
||||
placeholder="1011"
|
||||
class="w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-slate-300 mb-1">Utca</label>
|
||||
<input
|
||||
v-model="form.address_street_name"
|
||||
placeholder="Egressy"
|
||||
class="w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-sm font-medium text-slate-300 mb-1">Házszám</label>
|
||||
<input
|
||||
v-model="form.address_house_number"
|
||||
placeholder="4/b"
|
||||
class="w-full px-3 py-2 bg-slate-700 border border-slate-600 rounded-lg text-white placeholder-slate-500 focus:outline-none focus:ring-2 focus:ring-indigo-500/50 focus:border-indigo-500 text-sm"
|
||||
/>
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label class="block text-sm font-medium text-slate-300 mb-1">Plus Code</label>
|
||||
<input
|
||||
@@ -670,6 +642,21 @@ const form = reactive({
|
||||
} as Record<string, string[]>,
|
||||
opening_hours: {} as Record<string, { open: string; close: string } | null>,
|
||||
is_always_open: false,
|
||||
// Nested address object matching AddressIn schema (used by SharedAddressForm)
|
||||
address: {
|
||||
zip: '',
|
||||
city: '',
|
||||
street_name: '',
|
||||
street_type: '',
|
||||
house_number: '',
|
||||
stairwell: '',
|
||||
floor: '',
|
||||
door: '',
|
||||
parcel_id: '',
|
||||
full_address_text: '',
|
||||
latitude: null as number | null,
|
||||
longitude: null as number | null,
|
||||
},
|
||||
})
|
||||
|
||||
// ── Computed ───────────────────────────────────────────
|
||||
@@ -690,12 +677,14 @@ const hasChanges = computed(() => {
|
||||
// Scalar field comparisons
|
||||
if (form.name !== (p.name || '')) return true
|
||||
if (form.address !== (p.address || '')) return true
|
||||
if (form.city !== (p.city || '')) return true
|
||||
if (form.address_zip !== (p.address_zip || '')) return true
|
||||
if (form.address_street_name !== (p.address_street_name || '')) return true
|
||||
if (form.address_street_type !== (p.address_street_type || '')) return true
|
||||
if (form.address_house_number !== (p.address_house_number || '')) return true
|
||||
if (form.plus_code !== (p.plus_code || '')) return true
|
||||
|
||||
// Nested address comparison (via SharedAddressForm)
|
||||
if (form.address.zip !== (p.address_zip || '')) return true
|
||||
if (form.address.city !== (p.city || '')) return true
|
||||
if (form.address.street_name !== (p.address_street_name || '')) return true
|
||||
if (form.address.street_type !== (p.address_street_type || '')) return true
|
||||
if (form.address.house_number !== (p.address_house_number || '')) return true
|
||||
if (form.contact_phone !== (p.contact_phone || '')) return true
|
||||
if (form.contact_email !== (p.contact_email || '')) return true
|
||||
if (form.website !== (p.website || '')) return true
|
||||
@@ -777,11 +766,20 @@ function mapProviderToForm(p: ProviderDetail) {
|
||||
form.name = p.name || ''
|
||||
form.address = p.address || ''
|
||||
form.city = p.city || ''
|
||||
form.address_zip = p.address_zip || ''
|
||||
form.address_street_name = p.address_street_name || ''
|
||||
form.address_street_type = p.address_street_type || ''
|
||||
form.address_house_number = p.address_house_number || ''
|
||||
form.plus_code = p.plus_code || ''
|
||||
|
||||
// Populate nested address object from address_detail (unified AddressOut)
|
||||
const addr = p.address_detail || {}
|
||||
form.address_zip = addr.zip || ''
|
||||
form.address_street_name = addr.street_name || ''
|
||||
form.address_street_type = addr.street_type || ''
|
||||
form.address_house_number = addr.house_number || ''
|
||||
form.address.zip = addr.zip || ''
|
||||
form.address.city = addr.city || p.city || ''
|
||||
form.address.street_name = addr.street_name || ''
|
||||
form.address.street_type = addr.street_type || ''
|
||||
form.address.house_number = addr.house_number || ''
|
||||
form.address.full_address_text = addr.full_address_text || p.address || ''
|
||||
form.contact_phone = p.contact_phone || ''
|
||||
form.contact_email = p.contact_email || ''
|
||||
form.website = p.website || ''
|
||||
@@ -1050,7 +1048,7 @@ async function saveForm() {
|
||||
|
||||
// CRITICAL BUGFIX (2026-07-01): address is NOT NULL in the DB schema,
|
||||
// so we must never send null for it. Fall back to name if empty.
|
||||
const safeAddress = form.address?.trim() || form.name
|
||||
const safeAddress = form.address?.full_address_text?.trim() || form.name
|
||||
|
||||
const payload: Record<string, any> = {
|
||||
name: form.name,
|
||||
@@ -1059,17 +1057,27 @@ async function saveForm() {
|
||||
contact_phone: form.contact_phone || null,
|
||||
contact_email: form.contact_email || null,
|
||||
website: form.website || null,
|
||||
city: form.city || null,
|
||||
address_zip: form.address_zip || null,
|
||||
address_street_name: form.address_street_name || null,
|
||||
address_street_type: form.address_street_type || null,
|
||||
address_house_number: form.address_house_number || null,
|
||||
plus_code: form.plus_code || null,
|
||||
category_ids: form.category_ids,
|
||||
supported_vehicle_classes: form.supported_vehicle_classes,
|
||||
specializations: form.specializations,
|
||||
opening_hours: form.opening_hours,
|
||||
is_always_open: form.is_always_open,
|
||||
// Send nested address object matching AddressIn schema
|
||||
address_detail: {
|
||||
zip: form.address.zip || null,
|
||||
city: form.address.city || null,
|
||||
street_name: form.address.street_name || null,
|
||||
street_type: form.address.street_type || null,
|
||||
house_number: form.address.house_number || null,
|
||||
stairwell: form.address.stairwell || null,
|
||||
floor: form.address.floor || null,
|
||||
door: form.address.door || null,
|
||||
parcel_id: form.address.parcel_id || null,
|
||||
full_address_text: safeAddress,
|
||||
latitude: form.address.latitude,
|
||||
longitude: form.address.longitude,
|
||||
},
|
||||
}
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user