frontend admin refakctorálás
This commit is contained in:
@@ -528,51 +528,10 @@
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-slate-400 mb-1.5">{{ $t('garages.details.zip') }}</label>
|
||||
<input
|
||||
v-model="editForm.address_zip"
|
||||
type="text"
|
||||
class="w-full px-3 py-2 text-sm bg-slate-700/50 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"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-slate-400 mb-1.5">{{ $t('garages.details.city') }}</label>
|
||||
<input
|
||||
v-model="editForm.address_city"
|
||||
type="text"
|
||||
class="w-full px-3 py-2 text-sm bg-slate-700/50 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"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-slate-400 mb-1.5">{{ $t('garages.details.street_name') }}</label>
|
||||
<input
|
||||
v-model="editForm.address_street_name"
|
||||
type="text"
|
||||
class="w-full px-3 py-2 text-sm bg-slate-700/50 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"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-slate-400 mb-1.5">{{ $t('garages.details.street_type') }}</label>
|
||||
<input
|
||||
v-model="editForm.address_street_type"
|
||||
type="text"
|
||||
class="w-full px-3 py-2 text-sm bg-slate-700/50 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"
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
|
||||
<div>
|
||||
<label class="block text-xs font-medium text-slate-400 mb-1.5">{{ $t('garages.details.house_number') }}</label>
|
||||
<input
|
||||
v-model="editForm.address_house_number"
|
||||
type="text"
|
||||
class="w-full px-3 py-2 text-sm bg-slate-700/50 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"
|
||||
/>
|
||||
</div>
|
||||
<!-- P0 BUGFIX: Use SharedAddressForm for structured address editing -->
|
||||
<div class="border-t border-slate-700/50 pt-4 mt-4">
|
||||
<h4 class="text-sm font-semibold text-white mb-3">{{ $t('garages.details.address') }}</h4>
|
||||
<SharedAddressForm v-if="editForm.address_detail" v-model="editForm.address_detail" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -871,11 +830,21 @@ const editForm = ref({
|
||||
tax_number: '',
|
||||
reg_number: '',
|
||||
org_type: '',
|
||||
address_zip: '',
|
||||
address_city: '',
|
||||
address_street_name: '',
|
||||
address_street_type: '',
|
||||
address_house_number: '',
|
||||
/** P0 BUGFIX: Use address_detail object instead of flat address fields */
|
||||
address_detail: {
|
||||
zip: null as string | null,
|
||||
city: null as string | null,
|
||||
street_name: null as string | null,
|
||||
street_type: null as string | null,
|
||||
house_number: null as string | null,
|
||||
stairwell: null as string | null,
|
||||
floor: null as string | null,
|
||||
door: null as string | null,
|
||||
parcel_id: null as string | null,
|
||||
full_address_text: null as string | null,
|
||||
latitude: null as number | null,
|
||||
longitude: null as number | null,
|
||||
},
|
||||
contact_person_name: '',
|
||||
contact_email: '',
|
||||
contact_phone: '',
|
||||
@@ -1031,6 +1000,8 @@ async function fetchFleetVehicles() {
|
||||
// Edit Modal
|
||||
function openEditModal() {
|
||||
if (!garage.value) return
|
||||
/** P0 BUGFIX: Map address_detail from API response to form.address_detail */
|
||||
const addr = garage.value.address_detail || {}
|
||||
editForm.value = {
|
||||
full_name: garage.value.full_name || '',
|
||||
name: garage.value.name || '',
|
||||
@@ -1040,11 +1011,20 @@ function openEditModal() {
|
||||
tax_number: garage.value.tax_number || '',
|
||||
reg_number: garage.value.reg_number || '',
|
||||
org_type: garage.value.org_type || '',
|
||||
address_zip: garage.value.address_zip || '',
|
||||
address_city: garage.value.address_city || '',
|
||||
address_street_name: garage.value.address_street_name || '',
|
||||
address_street_type: garage.value.address_street_type || '',
|
||||
address_house_number: garage.value.address_house_number || '',
|
||||
address_detail: {
|
||||
zip: addr.zip || addr.address_zip || null,
|
||||
city: addr.city || null,
|
||||
street_name: addr.street_name || addr.address_street_name || null,
|
||||
street_type: addr.street_type || addr.address_street_type || null,
|
||||
house_number: addr.house_number || addr.address_house_number || null,
|
||||
stairwell: addr.stairwell || null,
|
||||
floor: addr.floor || null,
|
||||
door: addr.door || null,
|
||||
parcel_id: addr.parcel_id || null,
|
||||
full_address_text: addr.full_address_text || null,
|
||||
latitude: addr.latitude ?? null,
|
||||
longitude: addr.longitude ?? null,
|
||||
},
|
||||
contact_person_name: garage.value.contact_person_name || '',
|
||||
contact_email: garage.value.contact_email || '',
|
||||
contact_phone: garage.value.contact_phone || '',
|
||||
@@ -1073,12 +1053,57 @@ async function saveEdit() {
|
||||
const tokenCookie = useCookie('access_token')
|
||||
const token = (tokenCookie.value || auth.token || '').trim()
|
||||
|
||||
const payload: Record<string, any> = {}
|
||||
for (const [key, value] of Object.entries(editForm.value)) {
|
||||
if (value !== '' && value !== null && value !== undefined) {
|
||||
payload[key] = value
|
||||
/** P0 BUGFIX: Build payload with address_detail nested object instead of flat address fields */
|
||||
const f = editForm.value
|
||||
const payload: Record<string, any> = {
|
||||
full_name: f.full_name || undefined,
|
||||
name: f.name || undefined,
|
||||
display_name: f.display_name || undefined,
|
||||
email: f.email || undefined,
|
||||
phone: f.phone || undefined,
|
||||
tax_number: f.tax_number || undefined,
|
||||
reg_number: f.reg_number || undefined,
|
||||
org_type: f.org_type || undefined,
|
||||
contact_person_name: f.contact_person_name || undefined,
|
||||
contact_email: f.contact_email || undefined,
|
||||
contact_phone: f.contact_phone || undefined,
|
||||
billing_zip: f.billing_zip || undefined,
|
||||
billing_city: f.billing_city || undefined,
|
||||
billing_street_name: f.billing_street_name || undefined,
|
||||
billing_street_type: f.billing_street_type || undefined,
|
||||
billing_house_number: f.billing_house_number || undefined,
|
||||
notification_zip: f.notification_zip || undefined,
|
||||
notification_city: f.notification_city || undefined,
|
||||
notification_street_name: f.notification_street_name || undefined,
|
||||
notification_street_type: f.notification_street_type || undefined,
|
||||
notification_house_number: f.notification_house_number || undefined,
|
||||
/** Send address_detail as a nested object matching the API contract */
|
||||
address_detail: {
|
||||
zip: f.address_detail.zip,
|
||||
city: f.address_detail.city,
|
||||
street_name: f.address_detail.street_name,
|
||||
street_type: f.address_detail.street_type,
|
||||
house_number: f.address_detail.house_number,
|
||||
stairwell: f.address_detail.stairwell,
|
||||
floor: f.address_detail.floor,
|
||||
door: f.address_detail.door,
|
||||
parcel_id: f.address_detail.parcel_id,
|
||||
full_address_text: f.address_detail.full_address_text,
|
||||
latitude: f.address_detail.latitude,
|
||||
longitude: f.address_detail.longitude,
|
||||
},
|
||||
}
|
||||
|
||||
// Remove undefined values
|
||||
for (const key of Object.keys(payload)) {
|
||||
if (payload[key] === undefined) {
|
||||
delete payload[key]
|
||||
}
|
||||
}
|
||||
// Remove address_detail if all fields are null
|
||||
if (payload.address_detail && Object.values(payload.address_detail).every(v => v === null || v === undefined)) {
|
||||
delete payload.address_detail
|
||||
}
|
||||
|
||||
if (garage.value?.org_type === 'individual') {
|
||||
if (payload.contact_email && !payload.email) payload.email = payload.contact_email
|
||||
|
||||
@@ -154,7 +154,7 @@
|
||||
>
|
||||
{{ garageDisplayName(garage) }}
|
||||
</NuxtLink>
|
||||
<p class="text-xs text-slate-500">{{ garage.city || '—' }} · {{ garage.member_count }} {{ $t('garages.members') }}</p>
|
||||
<p class="text-xs text-slate-500">{{ garage.address_detail?.city || '—' }} · {{ garage.member_count }} {{ $t('garages.members') }}</p>
|
||||
</div>
|
||||
</div>
|
||||
</td>
|
||||
@@ -388,6 +388,14 @@ interface Garage {
|
||||
city: string | null
|
||||
region: string | null
|
||||
segment: string | null
|
||||
address_detail?: {
|
||||
zip: string | null
|
||||
city: string | null
|
||||
street_name: string | null
|
||||
street_type: string | null
|
||||
house_number: string | null
|
||||
full_address_text: string | null
|
||||
} | null
|
||||
member_count: number
|
||||
created_at: string | null
|
||||
subscription: SubscriptionInfo | null
|
||||
|
||||
Reference in New Issue
Block a user