feat: add dates_text to EventConfig and update formattedDates method in HeroBannerComponent
This commit is contained in:
@@ -25,6 +25,7 @@ export interface HeroConfig {
|
|||||||
export interface EventConfig {
|
export interface EventConfig {
|
||||||
title?: string | null;
|
title?: string | null;
|
||||||
location?: string | null;
|
location?: string | null;
|
||||||
|
dates_text?: string | null;
|
||||||
dates?: string[] | null;
|
dates?: string[] | null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -187,6 +187,7 @@ describe('StoreHomePageComponent', () => {
|
|||||||
eventConfig: {
|
eventConfig: {
|
||||||
title: 'Fiesta Fútbol Infantil',
|
title: 'Fiesta Fútbol Infantil',
|
||||||
location: 'Rosario, Santa Fe',
|
location: 'Rosario, Santa Fe',
|
||||||
|
dates_text: '5 y 6 de diciembre de 2026',
|
||||||
dates: ['2026-12-05'],
|
dates: ['2026-12-05'],
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
@@ -219,6 +220,7 @@ describe('StoreHomePageComponent', () => {
|
|||||||
expect(hero.style.backgroundImage).toContain('https://example.com/hero.jpg');
|
expect(hero.style.backgroundImage).toContain('https://example.com/hero.jpg');
|
||||||
expect(hero.textContent).toContain('Fiesta Fútbol Infantil');
|
expect(hero.textContent).toContain('Fiesta Fútbol Infantil');
|
||||||
expect(hero.textContent).toContain('Rosario, Santa Fe');
|
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 () => {
|
it('requests another page for the selected featured group', async () => {
|
||||||
|
|||||||
@@ -17,25 +17,14 @@ export class HeroBannerComponent {
|
|||||||
@Input() eventConfig?: EventConfig | null;
|
@Input() eventConfig?: EventConfig | null;
|
||||||
|
|
||||||
get formattedDates(): string {
|
get formattedDates(): string {
|
||||||
|
if (this.eventConfig?.dates_text) {
|
||||||
|
return this.eventConfig.dates_text;
|
||||||
|
}
|
||||||
|
|
||||||
if (!this.eventConfig?.dates || this.eventConfig.dates.length === 0) {
|
if (!this.eventConfig?.dates || this.eventConfig.dates.length === 0) {
|
||||||
return '';
|
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(', ');
|
return this.eventConfig.dates.join(', ');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user