feat: add dates_text to EventConfig and update formattedDates method in HeroBannerComponent

This commit is contained in:
2026-07-30 16:32:37 -03:00
parent 934bd07105
commit 941cb5c73c
3 changed files with 7 additions and 15 deletions

View File

@@ -25,6 +25,7 @@ export interface HeroConfig {
export interface EventConfig {
title?: string | null;
location?: string | null;
dates_text?: string | null;
dates?: string[] | null;
}

View File

@@ -187,6 +187,7 @@ describe('StoreHomePageComponent', () => {
eventConfig: {
title: 'Fiesta Fútbol Infantil',
location: 'Rosario, Santa Fe',
dates_text: '5 y 6 de diciembre de 2026',
dates: ['2026-12-05'],
},
});
@@ -219,6 +220,7 @@ describe('StoreHomePageComponent', () => {
expect(hero.style.backgroundImage).toContain('https://example.com/hero.jpg');
expect(hero.textContent).toContain('Fiesta Fútbol Infantil');
expect(hero.textContent).toContain('Rosario, Santa Fe');
expect(hero.textContent).toContain('5 y 6 de diciembre de 2026');
});
it('requests another page for the selected featured group', async () => {

View File

@@ -17,25 +17,14 @@ export class HeroBannerComponent {
@Input() eventConfig?: EventConfig | null;
get formattedDates(): string {
if (this.eventConfig?.dates_text) {
return this.eventConfig.dates_text;
}
if (!this.eventConfig?.dates || this.eventConfig.dates.length === 0) {
return '';
}
// Si ya viene formateado o es un string libre largo, lo devolvemos
if (this.eventConfig.dates.length === 1 && this.eventConfig.dates[0].length > 10) {
return this.eventConfig.dates[0];
}
// Si viene como array de fechas ISO, intentamos formatearlo bonito
// Pero por simplicidad ahora, los unimos.
// Idealmente el backend manda el texto formateado o se usa un DatePipe avanzado
const hasIsoDates = this.eventConfig.dates.some((d) => d.includes('-'));
if (hasIsoDates) {
// Un simple join por si acaso, aunque lo ideal es que el admin ponga el texto tal cual
return '9, 10, 11 y 12 de Octubre 2026'; // Placeholder basado en los requerimientos, si no se envía como string formateado
}
return this.eventConfig.dates.join(', ');
}
}