fix(admin): init charts and settings after section load + wired settings save fields
This commit is contained in:
@@ -38,11 +38,11 @@
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Nombre de la empresa</label>
|
||||
<input type="text" class="form-control" value="TenerifeProp">
|
||||
<input type="text" class="form-control" id="settingSiteName" placeholder="TenerifeProp">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Idioma principal</label>
|
||||
<select class="form-select">
|
||||
<select class="form-select" id="settingLanguage">
|
||||
<option value="es" selected>Español</option>
|
||||
<option value="ru">Русский</option>
|
||||
<option value="en">English</option>
|
||||
@@ -51,9 +51,9 @@
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Descripción</label>
|
||||
<textarea class="form-control" rows="3">Agencia inmobiliaria especializada en la venta de terrenos y propiedades en Tenerife.</textarea>
|
||||
<textarea class="form-control" rows="3" id="settingDescription" placeholder="Agencia inmobiliaria..."></textarea>
|
||||
</div>
|
||||
<button class="btn btn-primary">Guardar cambios</button>
|
||||
<button class="btn btn-primary settings-save-btn" onclick="admin.saveSettings()">Guardar cambios</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -66,23 +66,22 @@
|
||||
<div class="row mb-3">
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">Teléfono</label>
|
||||
<input type="text" class="form-control" value="+34 922 123 456">
|
||||
<input type="text" class="form-control" id="settingPhone" placeholder="+34 922 123 456">
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<label class="form-label">WhatsApp</label>
|
||||
<input type="text" class="form-control" value="+34 600 123 456">
|
||||
<input type="text" class="form-control" id="settingWhatsapp" placeholder="+34 600 123 456">
|
||||
</div>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Email</label>
|
||||
<input type="email" class="form-control" value="info@tenerifeprop.com">
|
||||
<input type="email" class="form-control" id="settingEmail" placeholder="info@tenerifeprop.com">
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label class="form-label">Dirección</label>
|
||||
<textarea class="form-control" rows="2">Avda. de la Constitución, 25
|
||||
38640 Adeje, Tenerife, España</textarea>
|
||||
<textarea class="form-control" rows="2" id="settingAddress" placeholder="Avda. de la Constitución, 25..."></textarea>
|
||||
</div>
|
||||
<button class="btn btn-primary">Guardar cambios</button>
|
||||
<button class="btn btn-primary settings-save-btn" onclick="admin.saveSettings()">Guardar cambios</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -26,10 +26,7 @@ class AdminPanel {
|
||||
this.initSidebar()
|
||||
this.initTopbar()
|
||||
this.initLanguageSwitcher()
|
||||
this.initSettingsSave()
|
||||
await this.loadDashboardData()
|
||||
this.initCharts()
|
||||
this.updateUI()
|
||||
// Show initial section
|
||||
const hash = window.location.hash.slice(1) || 'dashboard'
|
||||
this.navigateTo(hash)
|
||||
@@ -128,13 +125,13 @@ class AdminPanel {
|
||||
|
||||
async loadSectionData(section) {
|
||||
switch (section) {
|
||||
case 'dashboard': await this.loadDashboardData(); break
|
||||
case 'dashboard': await this.loadDashboardData(); this.initCharts(); this.updateUI(); break
|
||||
case 'properties': await this.loadProperties(); break
|
||||
case 'leads': await this.loadLeads(); break
|
||||
case 'testimonials': await this.loadTestimonials(); break
|
||||
case 'faq': await this.loadFAQ(); break
|
||||
case 'services': await this.loadServices(); break
|
||||
case 'settings': await this.loadSettings(); break
|
||||
case 'settings': await this.loadSettings(); this.initSettingsSave(); break
|
||||
case 'analytics': await this.loadAnalytics(); break
|
||||
}
|
||||
}
|
||||
@@ -702,9 +699,12 @@ class AdminPanel {
|
||||
const d = res.data
|
||||
const setVal = (id, val) => { const el = document.getElementById(id); if (el) el.value = val }
|
||||
setVal('settingSiteName', d.site_name || '')
|
||||
setVal('settingDescription', d.description || '')
|
||||
setVal('settingLanguage', d.language || 'es')
|
||||
setVal('settingPhone', d.phone || '')
|
||||
setVal('settingWhatsapp', d.whatsapp || '')
|
||||
setVal('settingEmail', d.email || '')
|
||||
setVal('settingAddress', d.address || '')
|
||||
}
|
||||
} catch (e) { console.error(e) }
|
||||
}
|
||||
@@ -719,9 +719,12 @@ class AdminPanel {
|
||||
const getVal = id => { const el = document.getElementById(id); return el ? el.value : '' }
|
||||
const data = {
|
||||
site_name: getVal('settingSiteName'),
|
||||
description: getVal('settingDescription'),
|
||||
language: getVal('settingLanguage'),
|
||||
phone: getVal('settingPhone'),
|
||||
whatsapp: getVal('settingWhatsapp'),
|
||||
email: getVal('settingEmail')
|
||||
email: getVal('settingEmail'),
|
||||
address: getVal('settingAddress')
|
||||
}
|
||||
const res = await API.updateSettings(data)
|
||||
if (res.success) this.showNotification('Configuración guardada', 'success')
|
||||
|
||||
Reference in New Issue
Block a user