diff --git a/public/property.html b/public/property.html index 591919b..fb1acb7 100644 --- a/public/property.html +++ b/public/property.html @@ -1228,55 +1228,8 @@

Propiedades Similares

Otras opciones que podrían interesarte

-
-
-
- -Terreno urbano -Urbano - -
-Parcela Urbana en Granadilla -

Granadilla de Abona

- -
-
-
-
-
- -Terreno agrícola -Agrícola - -
-Terreno Agrícola en Güímar -

Güímar, Tenerife Sur

- -
-
-
-
-
- -Villa -Casa - -
-Villa con Vistas al Mar -

Los Cristianos, Arona

- -
-
-
+
+
@@ -1638,7 +1591,77 @@ const urlParams = new URLSearchParams(window.location.search); const lang = urlParams.get('lang') || 'es'; switchLanguage(lang); + + // Load similar properties + loadSimilarProperties(); }); + + // ============ SIMILAR PROPERTIES ============ + async function loadSimilarProperties() { + const container = $('#similarPropertiesGrid'); + const currentSlug = window.location.pathname.split('/').pop() || 'terreno-urbano-adeje'; + + try { + const response = await fetch('/api/properties?limit=3'); + const result = await response.json(); + + if (!result.success || !result.data) { + container.html('
No hay propiedades disponibles
'); + return; + } + + // Filter out current property and get first 3 + const similarProps = result.data + .filter(p => p.slug !== currentSlug) + .slice(0, 3); + + const typeLabels = { + urban: { es: 'Urbano', ru: 'Городской', class: 'urban' }, + agricultural: { es: 'Agrícola', ru: 'Сельхоз', class: 'agricultural' }, + house: { es: 'Casa', ru: 'Дом', class: 'house' }, + apartment: { es: 'Apartamento', ru: 'Апартаменты', class: 'apartment' } + }; + + container.empty(); + + similarProps.forEach((property, index) => { + const typeInfo = typeLabels[property.type] || typeLabels.urban; + const typeLabel = typeInfo[currentLang]; + const images = JSON.parse(property.images || '[]'); + const mainImage = images[0] || 'https://images.unsplash.com/photo-1564013799919-ab600027ffc6?w=600&q=80'; + const priceFormatted = new Intl.NumberFormat('es-ES').format(property.price); + const areaFormatted = new Intl.NumberFormat('es-ES').format(property.area); + const title = property[`title_${currentLang}`] || property.title_es; + + const card = ` +
+
+ + ${title} + ${typeLabel} + +
+ ${title} +

+ ${property.city} +

+ +
+
+
+ `; + container.append(card); + }); + } catch (error) { + console.error('Error loading similar properties:', error); + container.html('
Error al cargar propiedades
'); + } + } diff --git a/src/server/index.ts b/src/server/index.ts index 7ea47b2..63b90e8 100644 --- a/src/server/index.ts +++ b/src/server/index.ts @@ -479,9 +479,9 @@ function seedData() { [s.id, s.icon, s.title_es, s.title_ru, s.desc_es, s.desc_ru]) }) - // Admin user + // Admin user (password: admin123) db.run('INSERT INTO users (id, email, password_hash, name, role) VALUES (?, ?, ?, ?, ?)', - ['user-001', 'admin@tenerifeprop.com', '$2b$10$dummyHashForDemo', 'Admin', 'admin']) + ['user-001', 'admin@tenerifeprop.com', '$2b$10$wlW1hhV6tgq8gKFtnmTBXOO8yNEv3d2UyUvwbnbX84iW3JbB3h07O', 'Admin', 'admin']) console.log('✅ Database seeded successfully') }