Compare commits
41 Commits
e7d24607a6
...
feature/sh
| Author | SHA1 | Date | |
|---|---|---|---|
| 1edbd84be6 | |||
| b6ab36437b | |||
| d9bf729a96 | |||
| c851272ebe | |||
| f70b93922e | |||
| d49c78b993 | |||
| 8ef00054c9 | |||
| 4b9343a867 | |||
| 114a986205 | |||
| b320501650 | |||
| 2162ae3963 | |||
| 92cc1c0275 | |||
| ed806abb9f | |||
| 321f2c08cd | |||
| 9ba3b24b7e | |||
| b8b5292200 | |||
| e8602cca13 | |||
| 36fda9f7ea | |||
| 230e5b01ac | |||
| 85f1b820b4 | |||
| 0fffdc5c5a | |||
| 0e6c949513 | |||
| fc04992ebb | |||
| 7d27d77629 | |||
| b2ffa7bb6b | |||
| 3465352218 | |||
| 8adbfecc35 | |||
| 1f35a6d709 | |||
| 32f86d14d6 | |||
| 49eaf0ad65 | |||
| db97de6711 | |||
| c876b2b171 | |||
| f6ff91ff3b | |||
| acac2858c3 | |||
| cd1c99f487 | |||
| 607892173d | |||
| 52f7b98162 | |||
| a06f8146e5 | |||
| fd60880812 | |||
| e0b1f27b97 | |||
| 7247e8e694 |
@@ -90,6 +90,11 @@ describe('App', () => {
|
||||
expect(
|
||||
document.head.querySelector<HTMLLinkElement>('link[rel~="icon"]')?.getAttribute('href'),
|
||||
).toBe(tenant.favicon);
|
||||
expect(
|
||||
document.head
|
||||
.querySelector<HTMLLinkElement>('link[rel~="icon"]')
|
||||
?.getAttribute('fetchpriority'),
|
||||
).toBe('high');
|
||||
});
|
||||
|
||||
it('renders the tenant not found screen when the tenant is missing', async () => {
|
||||
@@ -114,6 +119,10 @@ describe('App', () => {
|
||||
expect(
|
||||
document.head.querySelector<HTMLLinkElement>('link[rel~="icon"]')?.getAttribute('href'),
|
||||
).toBe("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg'/%3E");
|
||||
expect(
|
||||
document.head
|
||||
.querySelector<HTMLLinkElement>('link[rel~="icon"]')
|
||||
?.getAttribute('fetchpriority'),
|
||||
).toBe('high');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -78,6 +78,7 @@ export class App {
|
||||
}
|
||||
|
||||
favicon.setAttribute('href', faviconHref);
|
||||
favicon.setAttribute('fetchpriority', 'high');
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -22,8 +22,9 @@
|
||||
|
||||
.store-layout__brand-logo {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
width: auto;
|
||||
height: auto;
|
||||
max-width: 130px;
|
||||
max-height: 65px;
|
||||
object-fit: contain;
|
||||
object-position: left center;
|
||||
|
||||
@@ -1,48 +1,84 @@
|
||||
<header
|
||||
class="immersive-header"
|
||||
[class.immersive-header--compact]="!showHero()"
|
||||
>
|
||||
<div
|
||||
class="immersive-header__backdrop"
|
||||
[style.background-image]="backgroundImageUrl() ? 'url(' + backgroundImageUrl() + ')' : null"
|
||||
></div>
|
||||
<header class="immersive-header" [class.immersive-header--compact]="!showHero()">
|
||||
<div class="ih-backdrop">
|
||||
@if (showHero() && backgroundImageUrl(); as backgroundImage) {
|
||||
<img
|
||||
class="ih-backdrop-image"
|
||||
[src]="backgroundImage"
|
||||
alt=""
|
||||
loading="eager"
|
||||
fetchpriority="high"
|
||||
decoding="async"
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
|
||||
<div class="immersive-header__content">
|
||||
<nav class="immersive-header__nav container-xl px-3 px-md-4" aria-label="Navegación de la tienda">
|
||||
<a routerLink="/" class="immersive-header__brand" aria-label="Ir al inicio">
|
||||
<div class="ih-content">
|
||||
<nav
|
||||
class="ih-nav container-xl px-3 px-md-4"
|
||||
aria-label="Navegación de la tienda"
|
||||
>
|
||||
<a routerLink="/" class="ih-brand" aria-label="Ir al inicio">
|
||||
@if (logoUrl()) {
|
||||
<img [src]="logoUrl()" alt="Logo del comercio" />
|
||||
<img
|
||||
[src]="logoUrl()"
|
||||
alt="Logo del comercio"
|
||||
loading="eager"
|
||||
fetchpriority="high"
|
||||
decoding="async"
|
||||
/>
|
||||
}
|
||||
</a>
|
||||
|
||||
<div class="immersive-header__actions">
|
||||
<div class="ih-actions">
|
||||
@if (displaySearchBar()) {
|
||||
<form class="immersive-header__search" role="search" (submit)="submitSearch($event)">
|
||||
<form
|
||||
id="immersive-search"
|
||||
class="ih-search"
|
||||
[class.ih-search--open]="isSearchOpen()"
|
||||
role="search"
|
||||
(submit)="submitSearch($event)"
|
||||
>
|
||||
<label class="visually-hidden" for="immersive-search-input">Buscar productos</label>
|
||||
<input
|
||||
<app-input
|
||||
id="immersive-search-input"
|
||||
type="search"
|
||||
placeholder="Buscar"
|
||||
autocomplete="off"
|
||||
[formControl]="searchControl"
|
||||
[attr.aria-invalid]="showSearchError()"
|
||||
[attr.aria-describedby]="showSearchError() ? 'immersive-search-error' : null"
|
||||
(input)="showSearchError.set(false)"
|
||||
type="search"
|
||||
[(value)]="searchTerm"
|
||||
[invalid]="showSearchError()"
|
||||
(valueChange)="showSearchError.set(false)"
|
||||
/>
|
||||
<button type="submit" aria-label="Buscar">
|
||||
<i class="fa-solid fa-magnifying-glass" aria-hidden="true"></i>
|
||||
</button>
|
||||
@if (showSearchError()) {
|
||||
<span id="immersive-search-error" class="immersive-header__search-error" role="alert"
|
||||
<span id="immersive-search-error" class="ih-search-error" role="alert"
|
||||
>Ingresá al menos 3 caracteres.</span
|
||||
>
|
||||
}
|
||||
</form>
|
||||
}
|
||||
|
||||
@if (ticketsMenu(); as menu) {
|
||||
<button class="immersive-header__tickets" type="button" (click)="ticketsClick.emit()">
|
||||
{{ menu.label }}
|
||||
@if (!showHero()) {
|
||||
@if (ticketsMenu(); as menu) {
|
||||
<app-button
|
||||
variant="primary"
|
||||
hostClass="ih-tickets"
|
||||
data-testid="store-header-tickets"
|
||||
(click)="ticketsClick.emit()"
|
||||
>
|
||||
{{ menu.label }}
|
||||
</app-button>
|
||||
}
|
||||
}
|
||||
|
||||
@if (!showHero() && displaySearchBar()) {
|
||||
<button
|
||||
#searchToggle
|
||||
type="button"
|
||||
class="ih-search-toggle"
|
||||
aria-label="Buscar productos"
|
||||
aria-controls="immersive-search"
|
||||
[attr.aria-expanded]="isSearchOpen()"
|
||||
(click)="toggleSearch()"
|
||||
>
|
||||
<i class="fa-solid fa-magnifying-glass" aria-hidden="true"></i>
|
||||
</button>
|
||||
}
|
||||
|
||||
@@ -57,7 +93,7 @@
|
||||
/>
|
||||
}
|
||||
|
||||
<div class="immersive-header__account">
|
||||
<div class="ih-account">
|
||||
<app-icon-button
|
||||
variant="user"
|
||||
ariaLabel="Mi cuenta"
|
||||
@@ -65,30 +101,40 @@
|
||||
[ariaExpanded]="isUserDropdownOpen()"
|
||||
(clicked)="toggleUserDropdown()"
|
||||
/>
|
||||
@if (isUserDropdownOpen()) {
|
||||
@if (isUserDropdownOpen() && isAuthenticated()) {
|
||||
<app-user-dropdown
|
||||
id="immersive-user-dropdown"
|
||||
[user]="user()"
|
||||
[accountNavigationMenus]="accountNavigationMenus()"
|
||||
(logoutClick)="onLogoutClick()"
|
||||
/>
|
||||
} @else if (isUserDropdownOpen()) {
|
||||
<div id="immersive-user-dropdown" class="ih-guest-menu">
|
||||
<button type="button" (click)="isUserDropdownOpen.set(false); loginClick.emit()">
|
||||
Iniciar sesión
|
||||
</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
@if (checkoutRemainingTime(); as remainingTime) {
|
||||
<div class="immersive-header__timer container-xl px-3 px-md-4" role="timer" aria-label="Tiempo restante de compra">
|
||||
<div
|
||||
class="ih-timer container-xl px-3 px-md-4"
|
||||
role="timer"
|
||||
aria-label="Tiempo restante de compra"
|
||||
>
|
||||
Tiempo restante de compra: <strong>{{ remainingTime }}</strong>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (showHero()) {
|
||||
@if (heroContent(); as content) {
|
||||
<div class="immersive-header__copy">
|
||||
<p class="immersive-header__eyebrow">{{ content.eyebrow }}</p>
|
||||
<h1 class="immersive-header__title">{{ content.title }}</h1>
|
||||
<p class="immersive-header__description">{{ content.description }}</p>
|
||||
<div class="ih-copy">
|
||||
<p class="ih-eyebrow">{{ content.eyebrow }}</p>
|
||||
<h1 class="ih-title">{{ content.title }}</h1>
|
||||
<p class="ih-description">{{ content.description }}</p>
|
||||
</div>
|
||||
}
|
||||
|
||||
@@ -99,5 +145,7 @@
|
||||
/>
|
||||
}
|
||||
}
|
||||
|
||||
<ng-content />
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -7,44 +7,61 @@
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr);
|
||||
isolation: isolate;
|
||||
min-height: 640px;
|
||||
color: #fff;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.immersive-header__content {
|
||||
.ih-content {
|
||||
grid-area: 1 / 1;
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
min-width: 0;
|
||||
padding-top: clamp(1.75rem, 4vw, 2.5rem);
|
||||
padding-bottom: 0.5rem;
|
||||
padding-bottom: clamp(1rem, 2vw, 1.5rem);
|
||||
}
|
||||
|
||||
.immersive-header__backdrop {
|
||||
.ih-backdrop {
|
||||
grid-area: 1 / 1;
|
||||
position: relative;
|
||||
z-index: 0;
|
||||
overflow: hidden;
|
||||
background-color: #101010;
|
||||
background-position: center 42%;
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
.immersive-header__backdrop::after {
|
||||
.ih-backdrop-image {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
z-index: 0;
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
object-position: center 42%;
|
||||
}
|
||||
|
||||
.ih-backdrop::before,
|
||||
.ih-backdrop::after {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
background: linear-gradient(
|
||||
180deg,
|
||||
rgba(0, 0, 0, 0.48) 0%,
|
||||
rgba(0, 0, 0, 0.4) 47%,
|
||||
#f5f5f5 100%
|
||||
);
|
||||
z-index: 1;
|
||||
pointer-events: none;
|
||||
}
|
||||
|
||||
.immersive-header__nav {
|
||||
.ih-backdrop::before {
|
||||
background: rgba(0, 0, 0, 0.7);
|
||||
}
|
||||
|
||||
.ih-backdrop::after {
|
||||
background: linear-gradient(180deg, rgba(0, 0, 0, 0.48) 0%, rgba(0, 0, 0, 0.4) 47%, #f5f5f5 100%);
|
||||
}
|
||||
|
||||
.ih-nav {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
// Keep the whole navigation stacking context above the hero copy and carousel.
|
||||
// Otherwise those later siblings can sit on top of the dropdown and capture
|
||||
// pointer events even though the dropdown itself has a high z-index.
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
@@ -52,122 +69,82 @@
|
||||
min-height: 2.25rem;
|
||||
}
|
||||
|
||||
.immersive-header__brand {
|
||||
.ih-brand {
|
||||
display: inline-flex;
|
||||
flex: none;
|
||||
align-items: center;
|
||||
}
|
||||
.immersive-header__brand img {
|
||||
.ih-brand img {
|
||||
display: block;
|
||||
width: clamp(105px, 13vw, 145px);
|
||||
max-height: 2.25rem;
|
||||
object-fit: contain;
|
||||
}
|
||||
.immersive-header__actions {
|
||||
.ih-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: clamp(0.35rem, 1vw, 1rem);
|
||||
}
|
||||
|
||||
.immersive-header__search {
|
||||
.ih-search {
|
||||
position: relative;
|
||||
display: flex;
|
||||
width: clamp(115px, 17vw, 205px);
|
||||
height: 2rem;
|
||||
border: 1px solid var(--tenant-primary, #ff7006);
|
||||
border-radius: 3px;
|
||||
background: rgba(0, 0, 0, 0.1);
|
||||
}
|
||||
.immersive-header__search input {
|
||||
width: 100%;
|
||||
min-width: 0;
|
||||
padding: 0 0.5rem;
|
||||
border: 0;
|
||||
outline: 0;
|
||||
color: #fff;
|
||||
background: transparent;
|
||||
font-size: 0.75rem;
|
||||
}
|
||||
.immersive-header__search input::placeholder {
|
||||
color: rgba(255, 255, 255, 0.78);
|
||||
}
|
||||
.immersive-header__search input::-webkit-search-cancel-button {
|
||||
filter: invert(1);
|
||||
}
|
||||
.immersive-header__search button {
|
||||
border: 0;
|
||||
padding-inline: 0.55rem;
|
||||
color: var(--tenant-primary, #ff7006);
|
||||
background: transparent;
|
||||
}
|
||||
.immersive-header__search:focus-within {
|
||||
outline: 2px solid var(--tenant-primary, #ff7006);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
.immersive-header__search-error {
|
||||
.ih-search-error {
|
||||
position: absolute;
|
||||
top: calc(100% + 0.25rem);
|
||||
right: 0;
|
||||
width: max-content;
|
||||
color: #fff;
|
||||
color: var(--tenant-danger, #dc3545);
|
||||
font-size: 0.7rem;
|
||||
}
|
||||
.immersive-header__tickets {
|
||||
border: 1px solid var(--tenant-primary, #ff7006);
|
||||
border-radius: 3px;
|
||||
padding: 0.25rem 0.6rem;
|
||||
color: #fff;
|
||||
background: rgba(0, 0, 0, 0.2);
|
||||
font-size: 0.75rem;
|
||||
|
||||
:host ::ng-deep .ih-tickets {
|
||||
width: auto;
|
||||
}
|
||||
.immersive-header__tickets:hover {
|
||||
background: var(--tenant-primary, #ff7006);
|
||||
}
|
||||
.immersive-header__account {
|
||||
.ih-account {
|
||||
position: relative;
|
||||
// The nav becomes display: contents on mobile, so it cannot provide the
|
||||
// stacking context there. Keep the dropdown trigger above following rows.
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
}
|
||||
.immersive-header__account app-user-dropdown {
|
||||
position: absolute;
|
||||
top: 100%;
|
||||
right: 0;
|
||||
z-index: 20;
|
||||
color: #222;
|
||||
}
|
||||
:host ::ng-deep .immersive-header__actions .icon-btn,
|
||||
:host ::ng-deep .immersive-header__actions .cart-icon {
|
||||
:host ::ng-deep .ih-actions .icon-btn,
|
||||
:host ::ng-deep .ih-actions .cart-icon {
|
||||
color: var(--tenant-primary, #ff7006);
|
||||
}
|
||||
|
||||
.immersive-header__copy {
|
||||
.ih-copy {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
margin: clamp(2.1rem, 5vw, 3.25rem) auto 0;
|
||||
padding-inline: 1rem;
|
||||
text-align: center;
|
||||
}
|
||||
.immersive-header__eyebrow,
|
||||
.immersive-header__title {
|
||||
.ih-eyebrow,
|
||||
.ih-title {
|
||||
font-family: 'Smooch', cursive;
|
||||
font-weight: 400;
|
||||
text-shadow: 0 2px 12px rgba(0, 0, 0, 0.55);
|
||||
}
|
||||
.immersive-header__eyebrow {
|
||||
.ih-eyebrow {
|
||||
margin: 0;
|
||||
font-size: 50px;
|
||||
line-height: 1;
|
||||
}
|
||||
.immersive-header__title {
|
||||
.ih-title {
|
||||
margin: -0.15rem 0 0;
|
||||
font-size: 140px;
|
||||
line-height: 1.05;
|
||||
line-height: 0.7;
|
||||
}
|
||||
.immersive-header__description {
|
||||
margin: 1.15rem 0 0;
|
||||
font-size: clamp(0.75rem, 1.4vw, 0.95rem);
|
||||
.ih-description {
|
||||
margin: 30px 0 0;
|
||||
font-family: 'Gotham Book', sans-serif;
|
||||
font-size: 18px;
|
||||
font-weight: 300;
|
||||
text-shadow: 0 1px 5px rgba(0, 0, 0, 0.6);
|
||||
}
|
||||
.immersive-header__timer {
|
||||
.ih-timer {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
margin-top: 0.75rem;
|
||||
@@ -182,43 +159,298 @@
|
||||
}
|
||||
|
||||
.immersive-header--compact {
|
||||
min-height: 0;
|
||||
padding-bottom: 1.5rem;
|
||||
background: #171717;
|
||||
min-height: 115px;
|
||||
color: #666666;
|
||||
background: transparent;
|
||||
|
||||
.ih-content {
|
||||
padding: 35px 0 36px;
|
||||
}
|
||||
|
||||
.ih-nav {
|
||||
flex-wrap: nowrap;
|
||||
gap: 0.75rem;
|
||||
min-height: 44px;
|
||||
}
|
||||
|
||||
.ih-brand img {
|
||||
width: clamp(92px, 24vw, 145px);
|
||||
}
|
||||
|
||||
.ih-actions {
|
||||
flex: 0 1 auto;
|
||||
gap: 0.375rem;
|
||||
}
|
||||
}
|
||||
.immersive-header--compact .immersive-header__backdrop {
|
||||
|
||||
.ih-search-toggle {
|
||||
display: none;
|
||||
flex: none;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 32px;
|
||||
height: 44px;
|
||||
padding: 0;
|
||||
border: 0;
|
||||
border-radius: 4px;
|
||||
background: transparent;
|
||||
color: #888;
|
||||
font-size: 20px;
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid var(--tenant-primary);
|
||||
outline-offset: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.ih-guest-menu {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
top: calc(100% + 0.5rem);
|
||||
right: 0;
|
||||
min-width: 180px;
|
||||
padding: 0.5rem;
|
||||
border-radius: 6px;
|
||||
background: #fff;
|
||||
box-shadow: 0 4px 16px #0002;
|
||||
|
||||
button {
|
||||
width: 100%;
|
||||
padding: 0.75rem;
|
||||
border: 0;
|
||||
background: transparent;
|
||||
color: #666;
|
||||
text-align: left;
|
||||
}
|
||||
}
|
||||
.immersive-header--compact .immersive-header__backdrop::after {
|
||||
background: rgba(0, 0, 0, 0.65);
|
||||
|
||||
:host ::ng-deep .immersive-header--compact {
|
||||
.ih-tickets {
|
||||
flex: none;
|
||||
width: auto;
|
||||
|
||||
.btn {
|
||||
min-width: 120px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
}
|
||||
|
||||
.ih-account .icon-btn {
|
||||
width: 32px;
|
||||
height: 44px;
|
||||
color: #888;
|
||||
}
|
||||
}
|
||||
.immersive-header--compact .ih-backdrop {
|
||||
display: none;
|
||||
}
|
||||
|
||||
:host ::ng-deep .immersive-header--compact .ih-actions .icon-btn,
|
||||
:host ::ng-deep .immersive-header--compact .ih-actions .cart-icon {
|
||||
color: #888;
|
||||
}
|
||||
|
||||
@media (max-width: 359.98px) {
|
||||
.immersive-header--compact .ih-nav {
|
||||
padding-inline: 1rem !important;
|
||||
gap: 0.375rem;
|
||||
}
|
||||
|
||||
.immersive-header--compact .ih-actions {
|
||||
gap: 0.125rem;
|
||||
}
|
||||
}
|
||||
|
||||
@media (max-width: 600px) {
|
||||
.immersive-header__nav {
|
||||
.ih-nav {
|
||||
flex-wrap: wrap;
|
||||
gap: 0.5rem;
|
||||
}
|
||||
.immersive-header__actions {
|
||||
.ih-actions {
|
||||
flex: 1;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
.immersive-header__search {
|
||||
.ih-search {
|
||||
width: clamp(105px, 38vw, 180px);
|
||||
}
|
||||
.immersive-header__copy {
|
||||
.ih-copy {
|
||||
margin-top: 3rem;
|
||||
}
|
||||
.immersive-header__eyebrow {
|
||||
.ih-eyebrow {
|
||||
font-size: clamp(2rem, 8vw, 50px);
|
||||
}
|
||||
.immersive-header__title {
|
||||
.ih-title {
|
||||
font-size: clamp(3rem, 12vw, 5rem);
|
||||
}
|
||||
}
|
||||
|
||||
@media (prefers-reduced-motion: reduce) {
|
||||
.immersive-header__tickets {
|
||||
transition: none;
|
||||
@media (max-width: 767.98px) {
|
||||
.immersive-header--compact {
|
||||
.ih-search {
|
||||
position: absolute;
|
||||
top: calc(100% + 0.5rem);
|
||||
right: 8vw;
|
||||
display: none;
|
||||
width: min(320px, 84vw);
|
||||
padding: 0.75rem;
|
||||
border-radius: 6px;
|
||||
background: #f5f5f5;
|
||||
box-shadow: 0 4px 16px #0002;
|
||||
}
|
||||
|
||||
.ih-search--open {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.ih-search-error {
|
||||
position: static;
|
||||
display: block;
|
||||
margin-top: 0.25rem;
|
||||
}
|
||||
|
||||
.ih-search-toggle {
|
||||
display: inline-flex;
|
||||
}
|
||||
}
|
||||
|
||||
.immersive-header:not(.immersive-header--compact) {
|
||||
min-height: 0;
|
||||
|
||||
.ih-content {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) auto auto;
|
||||
align-items: center;
|
||||
align-content: start;
|
||||
padding: 1.875rem 0 1.5rem;
|
||||
}
|
||||
|
||||
// Keep one search form while placing it below the hero copy on mobile.
|
||||
.ih-nav,
|
||||
.ih-actions {
|
||||
display: contents;
|
||||
}
|
||||
|
||||
.ih-brand {
|
||||
grid-area: 1 / 1;
|
||||
margin-left: 8vw;
|
||||
}
|
||||
|
||||
.ih-brand img {
|
||||
width: clamp(105px, 34vw, 145px);
|
||||
}
|
||||
|
||||
app-cart-icon {
|
||||
grid-area: 1 / 2;
|
||||
}
|
||||
|
||||
.ih-account {
|
||||
grid-area: 1 / 3;
|
||||
margin-right: calc(8vw - 0.75rem);
|
||||
}
|
||||
|
||||
.ih-timer {
|
||||
grid-area: 2 / 1 / auto / -1;
|
||||
}
|
||||
|
||||
.ih-copy {
|
||||
grid-area: 3 / 1 / auto / -1;
|
||||
margin: 1.25rem 0 0;
|
||||
}
|
||||
|
||||
.ih-eyebrow {
|
||||
font-size: clamp(18px, 5.5vw, 24px);
|
||||
}
|
||||
|
||||
.ih-title {
|
||||
font-size: clamp(40px, 12vw, 56px);
|
||||
line-height: 0.7;
|
||||
}
|
||||
|
||||
.ih-description {
|
||||
margin-top: 30px;
|
||||
font-size: clamp(11px, 3vw, 14px);
|
||||
line-height: 1.5;
|
||||
color: #666;
|
||||
text-shadow: none;
|
||||
}
|
||||
|
||||
.ih-search {
|
||||
grid-area: 4 / 1 / auto / -1;
|
||||
width: 74%;
|
||||
max-width: 28rem;
|
||||
margin: 0.5rem auto 0;
|
||||
}
|
||||
|
||||
.ih-search-error {
|
||||
right: auto;
|
||||
left: 0;
|
||||
width: 100%;
|
||||
color: var(--tenant-danger, #dc3545);
|
||||
}
|
||||
|
||||
app-continuous-image-carousel {
|
||||
grid-area: 6 / 1 / auto / -1;
|
||||
margin-top: 1.5rem;
|
||||
--carousel-card-width: 27vw;
|
||||
--carousel-gap: 3.3vw;
|
||||
--carousel-offset: -9vw;
|
||||
}
|
||||
|
||||
.ih-backdrop-image {
|
||||
object-position: center 42%;
|
||||
}
|
||||
|
||||
.ih-backdrop {
|
||||
// Keep the fade tied to the hero, independent of the content below it.
|
||||
align-self: start;
|
||||
height: 12.5rem;
|
||||
// Fade the entire layer so its dark base cannot leave a subpixel seam.
|
||||
mask-image: linear-gradient(#000 calc(100% - 8px), transparent 100%);
|
||||
}
|
||||
|
||||
.ih-backdrop::after {
|
||||
background: linear-gradient(
|
||||
180deg,
|
||||
rgba(0, 0, 0, 0.25) 0%,
|
||||
rgba(245, 245, 245, 0.1) 30%,
|
||||
rgba(245, 245, 245, 0.65) 65%,
|
||||
#f5f5f5 98%,
|
||||
#f5f5f5 100%
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
:host ::ng-deep .immersive-header:not(.immersive-header--compact) {
|
||||
.ih-search .form-control {
|
||||
min-height: 36px;
|
||||
padding: 0.25rem 2.5rem 0.25rem 0.75rem;
|
||||
border: 1px solid #888;
|
||||
border-radius: 3px;
|
||||
background: transparent;
|
||||
color: #666;
|
||||
font-size: 16px;
|
||||
|
||||
&::placeholder {
|
||||
color: transparent;
|
||||
}
|
||||
|
||||
&:focus-visible {
|
||||
outline: 2px solid #666;
|
||||
outline-offset: 2px;
|
||||
}
|
||||
}
|
||||
|
||||
.ih-search .input-search-icon {
|
||||
color: #666;
|
||||
right: 0.75rem;
|
||||
}
|
||||
|
||||
.ih-account .icon-btn {
|
||||
min-width: 44px;
|
||||
min-height: 44px;
|
||||
|
||||
i {
|
||||
font-size: 18px;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,13 +7,16 @@ import {
|
||||
input,
|
||||
output,
|
||||
signal,
|
||||
afterRenderEffect,
|
||||
viewChild,
|
||||
} from '@angular/core';
|
||||
import { FormControl, ReactiveFormsModule } from '@angular/forms';
|
||||
import { RouterLink } from '@angular/router';
|
||||
import { AuthUser } from '../../../services/auth/auth.interfaces';
|
||||
import { Menu, WebsiteExtras } from '../../../services/tenant.interface';
|
||||
import { ButtonComponent } from '../../../../shared/components/button/button.component';
|
||||
import { CartIconComponent } from '../../../../shared/components/cart-icon/cart-icon.component';
|
||||
import { IconButtonComponent } from '../../../../shared/components/icon-button/icon-button.component';
|
||||
import { InputComponent } from '../../../../shared/components/input/input.component';
|
||||
import { ContinuousImageCarouselComponent } from '../../../../shared/components/continuous-image-carousel/continuous-image-carousel.component';
|
||||
import { UserDropdownComponent } from './user-dropdown/user-dropdown.component';
|
||||
|
||||
@@ -21,9 +24,10 @@ import { UserDropdownComponent } from './user-dropdown/user-dropdown.component';
|
||||
selector: 'app-immersive-store-header',
|
||||
imports: [
|
||||
RouterLink,
|
||||
ReactiveFormsModule,
|
||||
ButtonComponent,
|
||||
CartIconComponent,
|
||||
IconButtonComponent,
|
||||
InputComponent,
|
||||
ContinuousImageCarouselComponent,
|
||||
UserDropdownComponent,
|
||||
],
|
||||
@@ -54,9 +58,23 @@ export class ImmersiveStoreHeaderComponent {
|
||||
readonly logoutClick = output<void>();
|
||||
readonly searchSubmit = output<string>();
|
||||
|
||||
protected readonly searchControl = new FormControl('', { nonNullable: true });
|
||||
protected searchTerm = '';
|
||||
protected readonly showSearchError = signal(false);
|
||||
protected readonly isUserDropdownOpen = signal(false);
|
||||
protected readonly isSearchOpen = signal(false);
|
||||
private readonly searchInput = viewChild(InputComponent);
|
||||
private readonly searchToggle = viewChild<ElementRef<HTMLButtonElement>>('searchToggle');
|
||||
|
||||
constructor() {
|
||||
afterRenderEffect(() => {
|
||||
if (this.isSearchOpen()) this.searchInput()?.focus();
|
||||
});
|
||||
}
|
||||
|
||||
protected toggleSearch(): void {
|
||||
this.isUserDropdownOpen.set(false);
|
||||
this.isSearchOpen.update((open) => !open);
|
||||
}
|
||||
protected readonly checkoutRemainingTime = computed(() => {
|
||||
const seconds = this.checkoutRemainingSeconds();
|
||||
if (seconds === null) return null;
|
||||
@@ -68,17 +86,19 @@ export class ImmersiveStoreHeaderComponent {
|
||||
|
||||
protected submitSearch(event?: Event): void {
|
||||
event?.preventDefault();
|
||||
const term = this.searchControl.value.trim();
|
||||
const term = this.searchTerm.trim();
|
||||
if (term.length < 3) {
|
||||
this.showSearchError.set(true);
|
||||
return;
|
||||
}
|
||||
this.showSearchError.set(false);
|
||||
this.isSearchOpen.set(false);
|
||||
this.searchSubmit.emit(term);
|
||||
}
|
||||
|
||||
protected toggleUserDropdown(): void {
|
||||
if (!this.isAuthenticated()) {
|
||||
this.isSearchOpen.set(false);
|
||||
if (this.showHero() && !this.isAuthenticated()) {
|
||||
this.loginClick.emit();
|
||||
return;
|
||||
}
|
||||
@@ -98,11 +118,14 @@ export class ImmersiveStoreHeaderComponent {
|
||||
protected onDocumentClick(event: MouseEvent): void {
|
||||
if (event.target instanceof Node && !this.host.nativeElement.contains(event.target)) {
|
||||
this.isUserDropdownOpen.set(false);
|
||||
this.isSearchOpen.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
@HostListener('document:keydown.escape')
|
||||
protected onEscapeKey(): void {
|
||||
if (this.isSearchOpen()) this.searchToggle()?.nativeElement.focus();
|
||||
this.isSearchOpen.set(false);
|
||||
this.isUserDropdownOpen.set(false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,7 +13,14 @@
|
||||
aria-label="Logo del comercio"
|
||||
>
|
||||
@if (logoUrl()) {
|
||||
<img class="store-layout__brand-logo" [src]="logoUrl()" alt="Logo del comercio" />
|
||||
<img
|
||||
class="store-layout__brand-logo"
|
||||
[src]="logoUrl()"
|
||||
alt="Logo del comercio"
|
||||
loading="eager"
|
||||
fetchpriority="high"
|
||||
decoding="async"
|
||||
/>
|
||||
} @else {
|
||||
<div class="store-layout__brand-logo-shell" aria-hidden="true">
|
||||
<span class="store-layout__brand-logo-skeleton"></span>
|
||||
|
||||
@@ -6,10 +6,6 @@
|
||||
background-size: cover;
|
||||
}
|
||||
|
||||
.store-layout__header-main {
|
||||
border-bottom: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.store-layout__categories {
|
||||
height: 3.5rem;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,17 @@
|
||||
(loginClick)="loginClick.emit()"
|
||||
(logoutClick)="logoutClick.emit()"
|
||||
(searchSubmit)="searchSubmit.emit($event)"
|
||||
/>
|
||||
>
|
||||
@if (showHero() && displayCategories() && categories().length) {
|
||||
<nav class="immersive-categories" aria-label="Categorías">
|
||||
<app-horizontal-carousel
|
||||
[items]="categoryItems()"
|
||||
ariaLabel="Categorías"
|
||||
(itemSelect)="onCategoryItemSelect($event)"
|
||||
/>
|
||||
</nav>
|
||||
}
|
||||
</app-immersive-store-header>
|
||||
}
|
||||
@default {
|
||||
<ng-container *ngTemplateOutlet="standardHeader" />
|
||||
@@ -50,19 +60,3 @@
|
||||
(categorySelect)="categorySelect.emit($event)"
|
||||
/>
|
||||
</ng-template>
|
||||
|
||||
@if (headerType() === 'immersive' && displayCategories() && categories().length) {
|
||||
<nav class="immersive-categories" aria-label="Categorías">
|
||||
<div class="immersive-categories__list">
|
||||
@for (category of categories(); track category.id) {
|
||||
<button
|
||||
type="button"
|
||||
class="immersive-categories__item"
|
||||
(click)="categorySelect.emit(category)"
|
||||
>
|
||||
{{ category.nombre | uppercase }}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
</nav>
|
||||
}
|
||||
|
||||
@@ -2,36 +2,54 @@
|
||||
display: block;
|
||||
}
|
||||
|
||||
app-immersive-store-header {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
:host(.immersive-shell--compact) {
|
||||
position: relative;
|
||||
background-color: #f5f5f5;
|
||||
background-image: none !important;
|
||||
|
||||
&::before {
|
||||
content: '';
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
pointer-events: none;
|
||||
background-image: var(--compact-header-background);
|
||||
background-position: left top, center 42%;
|
||||
background-size: 100% 100%, cover;
|
||||
background-repeat: no-repeat;
|
||||
mask-image: linear-gradient(#000 calc(100% - 12px), transparent calc(100% - 4px));
|
||||
}
|
||||
}
|
||||
|
||||
.immersive-categories {
|
||||
position: relative;
|
||||
z-index: 1;
|
||||
width: 100%;
|
||||
overflow-x: auto;
|
||||
background: #f5f5f5;
|
||||
}
|
||||
|
||||
.immersive-categories__list {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
gap: clamp(1rem, 3vw, 2.5rem);
|
||||
width: max-content;
|
||||
min-width: 100%;
|
||||
min-height: 3.5rem;
|
||||
padding: 0.75rem 1rem;
|
||||
}
|
||||
|
||||
.immersive-categories__item {
|
||||
flex: none;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
margin-top: clamp(5rem, 11vw, 9rem);
|
||||
padding: 0.375rem 1rem;
|
||||
background: transparent;
|
||||
color: #666666;
|
||||
color: #666;
|
||||
font-size: 15px;
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
cursor: pointer;
|
||||
--horizontal-carousel-gap: 90px;
|
||||
--horizontal-carousel-text-transform: uppercase;
|
||||
}
|
||||
|
||||
.immersive-categories__item:hover,
|
||||
.immersive-categories__item:focus-visible {
|
||||
text-decoration: underline;
|
||||
@media (max-width: 767.98px) {
|
||||
.immersive-categories {
|
||||
grid-area: 5 / 1 / auto / -1;
|
||||
min-width: 0;
|
||||
margin-top: 1.5rem;
|
||||
padding: 0 1rem;
|
||||
font-size: clamp(10px, 2.8vw, 12px);
|
||||
--horizontal-carousel-visible-items: 3;
|
||||
--horizontal-carousel-gap: 0.5rem;
|
||||
--horizontal-carousel-item-width: calc((100cqw - 2 * var(--horizontal-carousel-gap)) / 3);
|
||||
--horizontal-carousel-white-space: normal;
|
||||
--horizontal-carousel-snap: x mandatory;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,17 +1,32 @@
|
||||
import { NgTemplateOutlet, UpperCasePipe } from '@angular/common';
|
||||
import { Component, input, output } from '@angular/core';
|
||||
import { NgTemplateOutlet } from '@angular/common';
|
||||
import { Component, computed, input, output } from '@angular/core';
|
||||
import { AuthUser } from '../../../services/auth/auth.interfaces';
|
||||
import { Category, Menu, WebsiteExtras } from '../../../services/tenant.interface';
|
||||
import { ImmersiveStoreHeaderComponent } from './immersive-store-header.component';
|
||||
import { StandardStoreHeaderComponent } from './standard-store-header.component';
|
||||
|
||||
import {
|
||||
HorizontalCarouselComponent,
|
||||
HorizontalCarouselItem,
|
||||
} from '../../../../shared/components/horizontal-carousel/horizontal-carousel.component';
|
||||
|
||||
export type StoreHeaderType = 'standard' | 'immersive';
|
||||
|
||||
@Component({
|
||||
selector: 'app-store-header',
|
||||
imports: [NgTemplateOutlet, UpperCasePipe, StandardStoreHeaderComponent, ImmersiveStoreHeaderComponent],
|
||||
imports: [
|
||||
NgTemplateOutlet,
|
||||
HorizontalCarouselComponent,
|
||||
StandardStoreHeaderComponent,
|
||||
ImmersiveStoreHeaderComponent,
|
||||
],
|
||||
templateUrl: './store-header.component.html',
|
||||
styleUrl: './store-header.component.scss',
|
||||
host: {
|
||||
'[class.immersive-shell--compact]': 'isCompactImmersive()',
|
||||
'[style.background-image]': 'null',
|
||||
'[style.--compact-header-background]': 'compactBackground()',
|
||||
},
|
||||
})
|
||||
export class StoreHeaderComponent {
|
||||
readonly headerType = input<StoreHeaderType>('standard');
|
||||
@@ -20,6 +35,17 @@ export class StoreHeaderComponent {
|
||||
readonly heroContent = input<WebsiteExtras['immersiveHero']>(undefined);
|
||||
readonly carouselImages = input<readonly string[]>([]);
|
||||
readonly showHero = input(true);
|
||||
protected readonly isCompactImmersive = computed(
|
||||
() => this.headerType() === 'immersive' && !this.showHero(),
|
||||
);
|
||||
protected readonly compactBackground = computed(() => {
|
||||
if (!this.isCompactImmersive()) return null;
|
||||
|
||||
const gradient =
|
||||
'linear-gradient(180deg, rgba(245, 245, 245, 0.72) 0%, rgba(245, 245, 245, 0.88) 58%, #f5f5f5 calc(100% - 4px), #f5f5f5 100%)';
|
||||
const image = this.backgroundImageUrl();
|
||||
return image ? `${gradient}, url(${JSON.stringify(image)})` : gradient;
|
||||
});
|
||||
readonly cartQuantity = input<number>(0);
|
||||
readonly user = input<AuthUser | null>(null);
|
||||
readonly isAuthenticated = input<boolean>(false);
|
||||
@@ -38,4 +64,13 @@ export class StoreHeaderComponent {
|
||||
readonly logoutClick = output<void>();
|
||||
readonly searchSubmit = output<string>();
|
||||
readonly categorySelect = output<Category>();
|
||||
|
||||
protected readonly categoryItems = computed(() =>
|
||||
this.categories().map((category) => ({ value: category.id, label: category.nombre })),
|
||||
);
|
||||
|
||||
protected onCategoryItemSelect(item: HorizontalCarouselItem): void {
|
||||
const category = this.categories().find((candidate) => candidate.id === item.value);
|
||||
if (category) this.categorySelect.emit(category);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -71,6 +71,7 @@
|
||||
|
||||
@media (max-width: 575.98px) {
|
||||
:host {
|
||||
right: -0.5rem;
|
||||
right: 0;
|
||||
width: min(18rem, calc(100vw - 1rem));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,12 +12,12 @@
|
||||
[isAuthenticated]="isAuthenticated()"
|
||||
[accountNavigationMenus]="accountNavigationMenus()"
|
||||
[ticketsMenu]="ticketsMenu() ?? null"
|
||||
[categories]="tenant()?.categories ?? []"
|
||||
[displayCategories]="tenant()?.display_categories ?? true"
|
||||
[categories]="navigationCategories()"
|
||||
[displayCategories]="displayCategories()"
|
||||
[displaySeachBar]="tenant()?.display_seach_bar ?? true"
|
||||
[displayCart]="displayCart()"
|
||||
[cartDisabled]="isCheckoutRoute()"
|
||||
[checkoutRemainingSeconds]="checkoutRemainingSeconds()"
|
||||
[checkoutRemainingSeconds]="headerCheckoutRemainingSeconds()"
|
||||
(cartClick)="onCartClick()"
|
||||
(ticketsClick)="onTicketsClick()"
|
||||
(loginClick)="onLoginClick()"
|
||||
@@ -73,8 +73,8 @@
|
||||
[logoUrl]="tenant()?.footer_logo ?? null"
|
||||
[backgroundImageUrl]="tenant()?.footer_bg_image ?? null"
|
||||
[storeName]="tenant()?.nombre ?? null"
|
||||
[address]="tenant()?.address ?? null"
|
||||
[phone]="tenant()?.phone ?? null"
|
||||
[address]="tenant()?.main_address?.address_text ?? null"
|
||||
[phone]="tenant()?.main_phone_number?.number ?? null"
|
||||
(logoutClick)="onLogoutClick()"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -35,7 +35,9 @@ const tenant: Tenant = {
|
||||
nombre: 'Test Tenant',
|
||||
dominio: 'localhost',
|
||||
address: 'Calle Test 123, Rosario',
|
||||
main_address: { id: 1, label: 'Principal', address_text: 'Calle Test 123, Rosario', latitude: null, longitude: null },
|
||||
phone: '+54 341 555 1234',
|
||||
main_phone_number: { id: 1, label: 'Principal', number: '+54 341 555 1234', tel_url: 'tel:+543415551234' },
|
||||
primary_color: '#6376F3',
|
||||
secondary_color: '#A0A0A0',
|
||||
danger_color: '#FF8888',
|
||||
@@ -274,26 +276,82 @@ describe('StoreLayoutComponent', () => {
|
||||
expect(header.componentInstance.headerType()).toBe('immersive');
|
||||
expect(element.querySelector('app-standard-store-header')).toBeNull();
|
||||
expect(element.querySelector('app-immersive-store-header')).not.toBeNull();
|
||||
expect(element.querySelector('.immersive-header__eyebrow')?.textContent).toContain(
|
||||
expect(element.querySelector('.ih-eyebrow')?.textContent).toContain(
|
||||
'Encendé tu',
|
||||
);
|
||||
expect(element.querySelector('.immersive-header__title')?.textContent).toContain('experiencia');
|
||||
expect(element.querySelector('.immersive-header__description')?.textContent).toContain(
|
||||
expect(element.querySelector('.ih-title')?.textContent).toContain('experiencia');
|
||||
expect(element.querySelector('.ih-description')?.textContent).toContain(
|
||||
'Reservá tu entrada',
|
||||
);
|
||||
expect(element.querySelectorAll('.continuous-carousel__set')).toHaveLength(2);
|
||||
expect(element.querySelector('.continuous-carousel__image')?.getAttribute('src')).toBe(
|
||||
'/first.jpg',
|
||||
const backdropImage = element.querySelector<HTMLImageElement>(
|
||||
'.ih-backdrop-image',
|
||||
);
|
||||
expect(backdropImage?.getAttribute('src')).toBe(tenant.header_bg_image);
|
||||
expect(backdropImage?.getAttribute('loading')).toBe('eager');
|
||||
expect(backdropImage?.getAttribute('fetchpriority')).toBe('high');
|
||||
expect(backdropImage?.getAttribute('decoding')).toBe('async');
|
||||
const headerLogo = element.querySelector<HTMLImageElement>('.ih-brand img');
|
||||
expect(headerLogo?.getAttribute('loading')).toBe('eager');
|
||||
expect(headerLogo?.getAttribute('fetchpriority')).toBe('high');
|
||||
expect(headerLogo?.getAttribute('decoding')).toBe('async');
|
||||
expect(element.querySelectorAll('.continuous-carousel__set')).toHaveLength(2);
|
||||
const carouselImages = element.querySelectorAll<HTMLImageElement>(
|
||||
'.continuous-carousel__image',
|
||||
);
|
||||
expect(carouselImages[0]?.getAttribute('src')).toBe('/first.jpg');
|
||||
expect(carouselImages[0]?.getAttribute('loading')).toBe('eager');
|
||||
expect(carouselImages[0]?.getAttribute('fetchpriority')).toBe('low');
|
||||
expect(carouselImages[1]?.getAttribute('fetchpriority')).toBe('low');
|
||||
expect(carouselImages[5]?.getAttribute('loading')).toBe('lazy');
|
||||
expect(carouselImages[5]?.getAttribute('fetchpriority')).toBe('low');
|
||||
expect(element.querySelector('app-cart-icon')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('shows immersive categories below the header and navigates on selection', () => {
|
||||
it('keeps tickets in the immersive account dropdown while hiding its root action', () => {
|
||||
const authService = TestBed.inject(AuthService);
|
||||
(authService.isAuthenticated as any).set(true);
|
||||
(authService.user as any).set({
|
||||
id: 1,
|
||||
nombre_apellido: 'Ada Lovelace',
|
||||
email: 'ada@example.com',
|
||||
});
|
||||
tenantState.set({ ...tenant, header_type: 'immersive' });
|
||||
|
||||
const fixture = TestBed.createComponent(StoreLayoutComponent);
|
||||
fixture.detectChanges();
|
||||
|
||||
const element = fixture.nativeElement as HTMLElement;
|
||||
expect(element.querySelector('[data-testid="store-header-tickets"]')).toBeNull();
|
||||
|
||||
element.querySelector<HTMLButtonElement>('app-icon-button[variant="user"] button')?.click();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(element.querySelector('[data-testid="user-dropdown-account.tickets"]')).not.toBeNull();
|
||||
|
||||
(fixture.componentInstance as any).isHomeRoute.set(false);
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(element.querySelector('[data-testid="store-header-tickets"]')).not.toBeNull();
|
||||
});
|
||||
|
||||
it('shows immersive categories inside the header and navigates on selection', () => {
|
||||
tenantState.set({
|
||||
...tenant,
|
||||
header_type: 'immersive',
|
||||
display_categories: true,
|
||||
categories: [{ id: 11, nombre: 'Música', subcategories: [] }],
|
||||
menues: [
|
||||
...(tenant.menues ?? []),
|
||||
{
|
||||
id: 20,
|
||||
code: 'product.category',
|
||||
label: 'Categoría de productos',
|
||||
parent_menu_code: null,
|
||||
content_type: 'dynamic',
|
||||
route: '/categoria/:id',
|
||||
submenues: [],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const fixture = TestBed.createComponent(StoreLayoutComponent);
|
||||
@@ -306,7 +364,7 @@ describe('StoreLayoutComponent', () => {
|
||||
|
||||
expect(header).not.toBeNull();
|
||||
expect(categories).not.toBeNull();
|
||||
expect(header?.contains(categories)).toBe(false);
|
||||
expect(header?.contains(categories)).toBe(true);
|
||||
expect(categoryButton?.textContent?.trim()).toBe('MÚSICA');
|
||||
|
||||
const navigate = vi.spyOn(TestBed.inject(Router), 'navigate');
|
||||
@@ -323,6 +381,43 @@ describe('StoreLayoutComponent', () => {
|
||||
expect(element.querySelector('.immersive-categories')).toBeNull();
|
||||
});
|
||||
|
||||
it('uses event categories and their dedicated route for multi-event storefronts', () => {
|
||||
tenantState.set({
|
||||
...tenant,
|
||||
storefront_website_type_code: 'onticket_multi_event',
|
||||
header_type: 'immersive',
|
||||
display_categories: true,
|
||||
categories: [],
|
||||
event_categories: [{ id: 12, nombre: 'Teatro', subcategories: [] }],
|
||||
menues: [
|
||||
...(tenant.menues ?? []),
|
||||
{
|
||||
id: 21,
|
||||
code: 'event.category',
|
||||
label: 'Categoría de eventos',
|
||||
parent_menu_code: null,
|
||||
content_type: 'dynamic',
|
||||
route: '/eventos/categoria/:id',
|
||||
submenues: [],
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
const fixture = TestBed.createComponent(StoreLayoutComponent);
|
||||
fixture.detectChanges();
|
||||
|
||||
const categoryButton = (fixture.nativeElement as HTMLElement).querySelector<HTMLButtonElement>(
|
||||
'.immersive-categories button',
|
||||
);
|
||||
const navigate = vi.spyOn(TestBed.inject(Router), 'navigate');
|
||||
|
||||
expect(categoryButton?.textContent?.trim()).toBe('TEATRO');
|
||||
categoryButton?.click();
|
||||
expect(navigate).toHaveBeenCalledWith(['/eventos/categoria', 12], {
|
||||
queryParams: { page: 1 },
|
||||
});
|
||||
});
|
||||
|
||||
it('opens the cart when requested through the openCart query parameter', () => {
|
||||
const fixture = TestBed.createComponent(StoreLayoutComponent);
|
||||
fixture.detectChanges();
|
||||
@@ -379,6 +474,26 @@ describe('StoreLayoutComponent', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('moves the countdown out of the header on multi-event checkout', () => {
|
||||
tenantState.set({
|
||||
...tenant,
|
||||
storefront_website_type_code: 'onticket_multi_event',
|
||||
checkout_summary_type: 'event',
|
||||
});
|
||||
checkoutRemainingSecondsState.set(587);
|
||||
const router = TestBed.inject(Router);
|
||||
vi.spyOn(router, 'url', 'get').mockReturnValue('/checkout/25');
|
||||
|
||||
const fixture = TestBed.createComponent(StoreLayoutComponent);
|
||||
fixture.detectChanges();
|
||||
|
||||
const element = fixture.nativeElement as HTMLElement;
|
||||
const header = fixture.debugElement.query(By.directive(StoreHeaderComponent));
|
||||
|
||||
expect(header.componentInstance.checkoutRemainingSeconds()).toBeNull();
|
||||
expect(element.querySelector('.store-layout__checkout-timer')).toBeNull();
|
||||
});
|
||||
|
||||
it('hides the configured header elements when the tenant disables them', () => {
|
||||
tenantState.set({
|
||||
...tenant,
|
||||
@@ -418,11 +533,13 @@ describe('StoreLayoutComponent', () => {
|
||||
|
||||
expect(compiled.querySelector('[data-testid="store-header-brand-slot"]')).not.toBeNull();
|
||||
expect(compiled.querySelector('[data-testid="store-footer-brand-slot"]')).not.toBeNull();
|
||||
expect(
|
||||
compiled.querySelector(
|
||||
`app-store-header img.store-layout__brand-logo[src="${tenant.header_logo}"]`,
|
||||
),
|
||||
).not.toBeNull();
|
||||
const headerLogo = compiled.querySelector<HTMLImageElement>(
|
||||
`app-store-header img.store-layout__brand-logo[src="${tenant.header_logo}"]`,
|
||||
);
|
||||
expect(headerLogo).not.toBeNull();
|
||||
expect(headerLogo?.getAttribute('loading')).toBe('eager');
|
||||
expect(headerLogo?.getAttribute('fetchpriority')).toBe('high');
|
||||
expect(headerLogo?.getAttribute('decoding')).toBe('async');
|
||||
expect(
|
||||
compiled.querySelector(
|
||||
`app-store-footer img.store-layout__brand-logo[src="${tenant.footer_logo}"]`,
|
||||
@@ -448,6 +565,36 @@ describe('StoreLayoutComponent', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('uses only the main address in the footer', () => {
|
||||
tenantState.set({ ...tenant, main_address: {
|
||||
id: 10, label: 'Principal', address_text: 'Sede principal 456', latitude: null, longitude: null,
|
||||
} });
|
||||
const fixture = TestBed.createComponent(StoreLayoutComponent);
|
||||
fixture.detectChanges();
|
||||
const footer = fixture.nativeElement.querySelector('app-store-footer') as HTMLElement;
|
||||
expect(footer.textContent).toContain('Sede principal 456');
|
||||
expect(footer.textContent).not.toContain(tenant.address);
|
||||
tenantState.set({ ...tenant, main_address: null });
|
||||
fixture.detectChanges();
|
||||
expect(footer.textContent).not.toContain('Sede principal 456');
|
||||
expect(footer.textContent).not.toContain(tenant.address);
|
||||
});
|
||||
|
||||
it('uses only the main phone number in the footer', () => {
|
||||
tenantState.set({ ...tenant, main_phone_number: {
|
||||
id: 10, label: 'Principal', number: '3411234567', tel_url: 'tel:3411234567',
|
||||
} });
|
||||
const fixture = TestBed.createComponent(StoreLayoutComponent);
|
||||
fixture.detectChanges();
|
||||
const footer = fixture.nativeElement.querySelector('app-store-footer') as HTMLElement;
|
||||
expect(footer.textContent).toContain('3411234567');
|
||||
expect(footer.textContent).not.toContain(tenant.phone);
|
||||
tenantState.set({ ...tenant, main_phone_number: null });
|
||||
fixture.detectChanges();
|
||||
expect(footer.textContent).not.toContain('3411234567');
|
||||
expect(footer.textContent).not.toContain(tenant.phone);
|
||||
});
|
||||
|
||||
it('navigates to search results when the search button is clicked', () => {
|
||||
const router = TestBed.inject(Router);
|
||||
vi.spyOn(router, 'navigate');
|
||||
@@ -620,7 +767,7 @@ describe('StoreLayoutComponent', () => {
|
||||
expect(
|
||||
compiled.querySelector('[data-testid="user-dropdown-account.purchases"]'),
|
||||
).not.toBeNull();
|
||||
expect(compiled.querySelector('[data-testid="user-dropdown-account.tickets"]')).toBeNull();
|
||||
expect(compiled.querySelector('[data-testid="user-dropdown-account.tickets"]')).not.toBeNull();
|
||||
expect(router.navigate).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
@@ -695,7 +842,7 @@ describe('StoreLayoutComponent', () => {
|
||||
|
||||
expect(profileLink?.getAttribute('href')).toBe('/mi-cuenta/datos-personales');
|
||||
expect(purchasesLink?.getAttribute('href')).toBe('/mi-cuenta/compras');
|
||||
expect(ticketsLink).toBeUndefined();
|
||||
expect(ticketsLink?.getAttribute('href')).toBe('/mi-cuenta/tickets');
|
||||
expect(logoutButton).toBeDefined();
|
||||
|
||||
logoutButton!.click();
|
||||
|
||||
@@ -71,6 +71,28 @@ export class StoreLayoutComponent implements OnInit {
|
||||
protected readonly isHomeRoute = signal(this.isHomeUrl(this.router.url));
|
||||
protected readonly checkoutRemainingSeconds = this.checkoutCountdownService.remainingSeconds;
|
||||
protected readonly isCreatingPurchase = signal(false);
|
||||
private readonly isMultiEventStorefront = computed(
|
||||
() => this.tenant()?.storefront_website_type_code === 'onticket_multi_event',
|
||||
);
|
||||
protected readonly headerCheckoutRemainingSeconds = computed(() =>
|
||||
this.isCheckoutRoute() && this.tenant()?.checkout_summary_type === 'event'
|
||||
? null
|
||||
: this.checkoutRemainingSeconds(),
|
||||
);
|
||||
protected readonly navigationCategories = computed(() =>
|
||||
this.isMultiEventStorefront()
|
||||
? (this.tenant()?.event_categories ?? [])
|
||||
: (this.tenant()?.categories ?? []),
|
||||
);
|
||||
private readonly categoryMenu = computed(() =>
|
||||
findMenu(
|
||||
this.tenant()?.menues ?? [],
|
||||
this.isMultiEventStorefront() ? 'event.category' : 'product.category',
|
||||
),
|
||||
);
|
||||
protected readonly displayCategories = computed(
|
||||
() => (this.tenant()?.display_categories ?? true) && this.categoryMenu() !== undefined,
|
||||
);
|
||||
protected readonly displayCart = computed(() => this.tenant()?.display_cart ?? true);
|
||||
protected readonly cartEditingPolicy = computed(() => this.tenant()?.cart_editing_policy ?? null);
|
||||
protected readonly canModifyCart = computed(
|
||||
@@ -189,10 +211,12 @@ export class StoreLayoutComponent implements OnInit {
|
||||
|
||||
const profile = accountMenu.submenues.find((menu) => menu.code === 'account.profile');
|
||||
const purchases = accountMenu.submenues.find((menu) => menu.code === 'account.purchases');
|
||||
const tickets = accountMenu.submenues.find((menu) => menu.code === 'account.tickets');
|
||||
|
||||
return [
|
||||
...(profile ? [{ ...accountMenu, route: profile.route }] : []),
|
||||
...(purchases ? [purchases] : []),
|
||||
...(tickets ? [tickets] : []),
|
||||
];
|
||||
});
|
||||
|
||||
@@ -281,7 +305,9 @@ export class StoreLayoutComponent implements OnInit {
|
||||
}
|
||||
|
||||
protected onCategorySelect(category: Category): void {
|
||||
void this.router.navigate(['/categoria', category.id], {
|
||||
const route = this.isMultiEventStorefront() ? '/eventos/categoria' : '/categoria';
|
||||
|
||||
void this.router.navigate([route, category.id], {
|
||||
queryParams: { page: 1 },
|
||||
});
|
||||
}
|
||||
|
||||
11
src/app/core/services/address.interface.ts
Normal file
11
src/app/core/services/address.interface.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
export interface Address {
|
||||
id: number;
|
||||
label: string;
|
||||
address_text: string;
|
||||
latitude: number | null;
|
||||
longitude: number | null;
|
||||
}
|
||||
|
||||
export interface TenantAddress extends Address {
|
||||
is_main: boolean;
|
||||
}
|
||||
@@ -121,11 +121,17 @@ export interface PurchaseDetailItemResponse {
|
||||
nombre: string;
|
||||
descripcion: string | null;
|
||||
slug: string;
|
||||
imagen: string | null;
|
||||
imagen?: string | null;
|
||||
attributes: PurchaseDetailAttributeResponse[];
|
||||
};
|
||||
}
|
||||
|
||||
export interface PurchaseCheckoutEventResponse {
|
||||
id: number;
|
||||
title: string;
|
||||
image: string | null;
|
||||
}
|
||||
|
||||
export interface PurchaseDetailResponse extends PurchaseStatusResponse {
|
||||
id: number;
|
||||
cart_id: number | null;
|
||||
@@ -140,6 +146,7 @@ export interface PurchaseDetailResponse extends PurchaseStatusResponse {
|
||||
email: string | null;
|
||||
items_source: 'purchase';
|
||||
items: PurchaseDetailItemResponse[];
|
||||
event?: PurchaseCheckoutEventResponse | null;
|
||||
tickets_count?: number;
|
||||
has_generated_tickets?: boolean;
|
||||
subtotal: string;
|
||||
|
||||
@@ -1,12 +1,15 @@
|
||||
import { ApiPaginatedResponse } from '../api-paginated-response.interface';
|
||||
import { Address } from '../address.interface';
|
||||
|
||||
export interface StoreEvent {
|
||||
id: number;
|
||||
slug: string;
|
||||
event_category_id: number | null;
|
||||
title: string;
|
||||
subtitle: string | null;
|
||||
description: string | null;
|
||||
location: string | null;
|
||||
address?: Address | null;
|
||||
exact_location: { latitude: number; longitude: number } | null;
|
||||
date_text: string | null;
|
||||
start_time?: string | null;
|
||||
|
||||
@@ -16,9 +16,9 @@ export class EventService extends BaseApiService {
|
||||
});
|
||||
}
|
||||
|
||||
get(id: number): Observable<ApiResponse<StoreEvent>> {
|
||||
get(slug: string): Observable<ApiResponse<StoreEvent>> {
|
||||
return this.http.get<ApiResponse<StoreEvent>>(
|
||||
`${this.tenantService.getTenantApiUrl()}/events/${id}`,
|
||||
`${this.tenantService.getTenantApiUrl()}/events/${slug}`,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
10
src/app/core/services/phone-number.interface.ts
Normal file
10
src/app/core/services/phone-number.interface.ts
Normal file
@@ -0,0 +1,10 @@
|
||||
export interface PhoneNumber {
|
||||
id: number;
|
||||
label: string;
|
||||
number: string;
|
||||
tel_url: string;
|
||||
}
|
||||
|
||||
export interface TenantPhoneNumber extends PhoneNumber {
|
||||
is_main: boolean;
|
||||
}
|
||||
@@ -1,4 +1,6 @@
|
||||
import { ApiResponse } from './api-response.interface';
|
||||
import { Address, TenantAddress } from './address.interface';
|
||||
import { PhoneNumber, TenantPhoneNumber } from './phone-number.interface';
|
||||
|
||||
export type CartEditingPolicyCode = 'disabled' | 'quantity_and_remove' | 'full';
|
||||
|
||||
@@ -69,13 +71,14 @@ export interface TenantEvent {
|
||||
subtitle: string | null;
|
||||
description: string | null;
|
||||
location: string | null;
|
||||
address?: Address | null;
|
||||
date_text: string | null;
|
||||
dates: ActiveEventDate[];
|
||||
social_media: SocialMedia[];
|
||||
}
|
||||
|
||||
export interface WebsiteExtras {
|
||||
carousel?: string[];
|
||||
carousel?: (string | { desktop: string; mobile: string })[];
|
||||
immersiveHeroCarousel?: string[];
|
||||
immersiveHero?: {
|
||||
eyebrow: string;
|
||||
@@ -117,10 +120,15 @@ export interface Tenant {
|
||||
nombre: string;
|
||||
dominio: string;
|
||||
base_path?: string;
|
||||
timezone?: string;
|
||||
site_title?: string | null;
|
||||
asset_url?: string | null;
|
||||
address?: string | null;
|
||||
addresses?: TenantAddress[];
|
||||
main_address?: Address | null;
|
||||
phone?: string | null;
|
||||
phone_numbers?: TenantPhoneNumber[];
|
||||
main_phone_number?: PhoneNumber | null;
|
||||
favicon?: string | null;
|
||||
primary_color: string;
|
||||
secondary_color: string;
|
||||
@@ -134,6 +142,7 @@ export interface Tenant {
|
||||
footer_bg_image?: string | null;
|
||||
storefront_website_type_code?: string | null;
|
||||
header_type?: 'standard' | 'immersive';
|
||||
checkout_summary_type?: 'default' | 'event';
|
||||
extras?: WebsiteExtras;
|
||||
event?: TenantEvent | null;
|
||||
selected_bank_account_id?: number | null;
|
||||
@@ -153,7 +162,8 @@ export interface Tenant {
|
||||
ticket_partial_refund_percentage?: string;
|
||||
social_media?: SocialMedia[];
|
||||
menues?: Menu[];
|
||||
categories: Category[];
|
||||
categories?: Category[];
|
||||
event_categories?: Category[];
|
||||
}
|
||||
|
||||
export type TenantBootstrapResponse = ApiResponse<Tenant>;
|
||||
|
||||
@@ -706,7 +706,7 @@
|
||||
<app-location-map
|
||||
[locations]="mapLocations"
|
||||
[markerColor]="tenant()?.primary_color ?? '#24a9e0'"
|
||||
mapStyle="minimal-light"
|
||||
mapStyle="standard"
|
||||
ariaLabel="Mapa de puntos de atención en Rosario"
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<a class="event-card" [routerLink]="['/evento', event().id]">
|
||||
<a class="event-card" [routerLink]="['/evento', event().slug]">
|
||||
<div class="event-card__image">
|
||||
@if (event().image) {
|
||||
<img [src]="event().image" [alt]="event().title" />
|
||||
@@ -12,8 +12,8 @@
|
||||
@if (event().date_text) {
|
||||
<p class="event-card__meta"><i class="fa-regular fa-calendar" aria-hidden="true"></i>{{ event().date_text }}</p>
|
||||
}
|
||||
@if (event().location) {
|
||||
<p class="event-card__meta"><i class="fa-solid fa-location-dot" aria-hidden="true"></i>{{ event().location }}</p>
|
||||
@if (event().address?.address_text; as location) {
|
||||
<p class="event-card__meta"><i class="fa-solid fa-location-dot" aria-hidden="true"></i>{{ location }}</p>
|
||||
}
|
||||
</div>
|
||||
</a>
|
||||
|
||||
@@ -14,6 +14,12 @@
|
||||
</a>
|
||||
}
|
||||
</nav>
|
||||
|
||||
@if (sidebarContent.template(); as sidebarTemplate) {
|
||||
<div class="menu-page-layout__context">
|
||||
<ng-container [ngTemplateOutlet]="sidebarTemplate" />
|
||||
</div>
|
||||
}
|
||||
</aside>
|
||||
|
||||
<main class="menu-page-layout__content">
|
||||
|
||||
@@ -40,6 +40,10 @@
|
||||
gap: 1rem;
|
||||
}
|
||||
|
||||
&__context {
|
||||
margin-top: 2rem;
|
||||
}
|
||||
|
||||
&__link {
|
||||
color: #888888;
|
||||
font-size: 0.875rem;
|
||||
|
||||
@@ -1,11 +1,34 @@
|
||||
import { signal } from '@angular/core';
|
||||
import { Component, signal } from '@angular/core';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { ActivatedRoute, provideRouter } from '@angular/router';
|
||||
import { RouterTestingHarness } from '@angular/router/testing';
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { Tenant } from '../../../../core/services/tenant.interface';
|
||||
import { TenantService } from '../../../../core/services/tenant.service';
|
||||
import { MenuPageLayoutComponent } from './menu-page-layout.component';
|
||||
import { MenuPageSidebarContentDirective } from './menu-page-sidebar-content.directive';
|
||||
|
||||
@Component({
|
||||
selector: 'app-sidebar-test-badge',
|
||||
template: '<strong class="sidebar-test-badge">Componente contextual</strong>',
|
||||
})
|
||||
class SidebarTestBadgeComponent {}
|
||||
|
||||
@Component({
|
||||
imports: [MenuPageSidebarContentDirective, SidebarTestBadgeComponent],
|
||||
template: `
|
||||
<p class="routed-page-content">Contenido principal</p>
|
||||
|
||||
<ng-template menuPageSidebarContent>
|
||||
<p class="sidebar-context-copy">{{ contextualCopy }}</p>
|
||||
<app-sidebar-test-badge />
|
||||
</ng-template>
|
||||
`,
|
||||
})
|
||||
class SidebarTestPageComponent {
|
||||
protected readonly contextualCopy = 'HTML declarado por la página';
|
||||
}
|
||||
|
||||
function createTenant(): Tenant {
|
||||
return {
|
||||
@@ -133,4 +156,44 @@ describe('MenuPageLayoutComponent', () => {
|
||||
'Consultas habituales',
|
||||
);
|
||||
});
|
||||
|
||||
it('renders page-owned HTML and components below the sidebar navigation', async () => {
|
||||
const tenant = signal(createTenant());
|
||||
|
||||
await TestBed.configureTestingModule({
|
||||
providers: [
|
||||
provideRouter([
|
||||
{
|
||||
path: 'mi-cuenta',
|
||||
component: MenuPageLayoutComponent,
|
||||
data: {
|
||||
menuCode: 'account',
|
||||
navigationLabel: 'Secciones de mi cuenta',
|
||||
},
|
||||
children: [{ path: 'tickets', component: SidebarTestPageComponent }],
|
||||
},
|
||||
]),
|
||||
{
|
||||
provide: TenantService,
|
||||
useValue: { tenant: tenant.asReadonly() },
|
||||
},
|
||||
],
|
||||
}).compileComponents();
|
||||
|
||||
const harness = await RouterTestingHarness.create('/mi-cuenta/tickets');
|
||||
const element = harness.routeNativeElement as HTMLElement;
|
||||
const navigation = element.querySelector('.menu-page-layout__nav');
|
||||
const context = element.querySelector('.menu-page-layout__context');
|
||||
|
||||
expect(context?.previousElementSibling).toBe(navigation);
|
||||
expect(context?.querySelector('.sidebar-context-copy')?.textContent?.trim()).toBe(
|
||||
'HTML declarado por la página',
|
||||
);
|
||||
expect(context?.querySelector('.sidebar-test-badge')?.textContent?.trim()).toBe(
|
||||
'Componente contextual',
|
||||
);
|
||||
expect(element.querySelector('.routed-page-content')?.textContent?.trim()).toBe(
|
||||
'Contenido principal',
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,18 +1,22 @@
|
||||
import { NgTemplateOutlet } from '@angular/common';
|
||||
import { Component, computed, inject } from '@angular/core';
|
||||
import { ActivatedRoute, RouterLink, RouterLinkActive, RouterOutlet } from '@angular/router';
|
||||
|
||||
import { findMenu } from '../../../../core/services/menu.utils';
|
||||
import { TenantService } from '../../../../core/services/tenant.service';
|
||||
import { MenuPageSidebarContentService } from './menu-page-sidebar-content.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-menu-page-layout',
|
||||
imports: [RouterLink, RouterLinkActive, RouterOutlet],
|
||||
imports: [NgTemplateOutlet, RouterLink, RouterLinkActive, RouterOutlet],
|
||||
providers: [MenuPageSidebarContentService],
|
||||
templateUrl: './menu-page-layout.component.html',
|
||||
styleUrl: './menu-page-layout.component.scss',
|
||||
})
|
||||
export class MenuPageLayoutComponent {
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly tenantService = inject(TenantService);
|
||||
protected readonly sidebarContent = inject(MenuPageSidebarContentService);
|
||||
|
||||
protected readonly navigationLabel =
|
||||
(this.route.snapshot.data['navigationLabel'] as string | undefined) ?? 'Secciones';
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
import { Directive, inject, OnDestroy, OnInit, TemplateRef } from '@angular/core';
|
||||
|
||||
import { MenuPageSidebarContentService } from './menu-page-sidebar-content.service';
|
||||
|
||||
/**
|
||||
* Projects page-owned content into the sidebar of the closest menu page layout.
|
||||
* The template keeps the declaration context of the routed page, so it can use
|
||||
* that page's fields, bindings and imported components.
|
||||
*/
|
||||
@Directive({
|
||||
selector: 'ng-template[menuPageSidebarContent]',
|
||||
})
|
||||
export class MenuPageSidebarContentDirective implements OnInit, OnDestroy {
|
||||
private readonly template = inject(TemplateRef<unknown>);
|
||||
private readonly sidebarContent = inject(MenuPageSidebarContentService);
|
||||
|
||||
ngOnInit(): void {
|
||||
this.sidebarContent.register(this.template);
|
||||
}
|
||||
|
||||
ngOnDestroy(): void {
|
||||
this.sidebarContent.unregister(this.template);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
import { Injectable, signal, TemplateRef } from '@angular/core';
|
||||
|
||||
@Injectable()
|
||||
export class MenuPageSidebarContentService {
|
||||
private readonly templateState = signal<TemplateRef<unknown> | null>(null);
|
||||
|
||||
readonly template = this.templateState.asReadonly();
|
||||
|
||||
register(template: TemplateRef<unknown>): void {
|
||||
this.templateState.set(template);
|
||||
}
|
||||
|
||||
unregister(template: TemplateRef<unknown>): void {
|
||||
if (this.templateState() === template) {
|
||||
this.templateState.set(null);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ export class PurchaseDetailPage implements OnInit {
|
||||
id: item.id,
|
||||
title: item.item_details.nombre || 'Producto sin nombre',
|
||||
description: item.item_details.descripcion,
|
||||
imageUrl: item.item_details.imagen,
|
||||
imageUrl: item.item_details.imagen ?? null,
|
||||
quantity: item.quantity,
|
||||
attributes: item.item_details.attributes.map((attribute) => ({
|
||||
label: attribute.name,
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
<a class="ticket-event row flex-nowrap align-items-center gx-3 mx-0" [routerLink]="[event().id]">
|
||||
<span class="col-4 col-sm-3">
|
||||
<span class="ticket-event__image-wrapper">
|
||||
@if (event().image; as image) {
|
||||
<img class="ticket-event__image" [src]="image" alt="" />
|
||||
}
|
||||
</span>
|
||||
</span>
|
||||
|
||||
<span class="ticket-event__title col">{{ event().title }}</span>
|
||||
|
||||
<span class="col-auto">
|
||||
<svg
|
||||
class="ticket-event__arrow"
|
||||
width="8"
|
||||
height="14"
|
||||
viewBox="0 0 8 14"
|
||||
fill="none"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<path
|
||||
d="M1 1L7 7L1 13"
|
||||
stroke="currentColor"
|
||||
stroke-width="2"
|
||||
stroke-linecap="round"
|
||||
stroke-linejoin="round"
|
||||
/>
|
||||
</svg>
|
||||
</span>
|
||||
</a>
|
||||
@@ -0,0 +1,60 @@
|
||||
:host {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ticket-event {
|
||||
min-height: 84px;
|
||||
padding: 12px 8px;
|
||||
color: #666666;
|
||||
text-decoration: none;
|
||||
transition:
|
||||
box-shadow 0.2s,
|
||||
border-radius 0.2s;
|
||||
}
|
||||
|
||||
.ticket-event:hover,
|
||||
.ticket-event:focus-visible {
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 0 30px rgba(0, 0, 0, 0.07);
|
||||
}
|
||||
|
||||
.ticket-event:focus-visible {
|
||||
outline: 2px solid var(--color-primary, var(--tenant-primary, #5b75ff));
|
||||
outline-offset: 2px;
|
||||
}
|
||||
|
||||
.ticket-event__image-wrapper {
|
||||
display: block;
|
||||
width: 100%;
|
||||
aspect-ratio: 19 / 13;
|
||||
overflow: hidden;
|
||||
border-radius: 3px;
|
||||
background: #dddddd;
|
||||
}
|
||||
|
||||
.ticket-event__image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
object-fit: cover;
|
||||
}
|
||||
|
||||
.ticket-event__title {
|
||||
overflow: hidden;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
line-height: 1.3;
|
||||
text-overflow: ellipsis;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.ticket-event__arrow {
|
||||
color: #888888;
|
||||
transition: color 0.2s;
|
||||
}
|
||||
|
||||
.ticket-event:hover .ticket-event__arrow,
|
||||
.ticket-event:focus-visible .ticket-event__arrow {
|
||||
color: var(--color-primary, var(--tenant-primary, #5b75ff));
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
import { Component, input } from '@angular/core';
|
||||
import { RouterLink } from '@angular/router';
|
||||
|
||||
import { TicketEventResponse } from '../../../tickets-page/ticket.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-ticket-event-list-item',
|
||||
imports: [RouterLink],
|
||||
templateUrl: './ticket-event-list-item.html',
|
||||
styleUrl: './ticket-event-list-item.scss',
|
||||
})
|
||||
export class TicketEventListItem {
|
||||
readonly event = input.required<TicketEventResponse>();
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
<app-menu-content-section
|
||||
class="ticket-events-page"
|
||||
menuCode="account.tickets"
|
||||
titleId="ticket-events-page-title"
|
||||
>
|
||||
<div class="ticket-events-list" [attr.aria-busy]="isLoading()">
|
||||
@if (isLoading()) {
|
||||
@for (item of [1, 2, 3, 4]; track item) {
|
||||
<div
|
||||
class="ticket-events-list__skeleton row flex-nowrap align-items-center gx-3 mx-0"
|
||||
aria-hidden="true"
|
||||
>
|
||||
<span class="col-4 col-sm-3">
|
||||
<span class="ticket-events-list__skeleton-image"></span>
|
||||
</span>
|
||||
<span class="col">
|
||||
<span class="ticket-events-list__skeleton-title"></span>
|
||||
</span>
|
||||
<span class="col-auto">
|
||||
<span class="ticket-events-list__skeleton-arrow"></span>
|
||||
</span>
|
||||
</div>
|
||||
}
|
||||
} @else if (events().length) {
|
||||
@for (event of events(); track event.id; let last = $last) {
|
||||
<app-ticket-event-list-item [event]="event" />
|
||||
@if (!last) {
|
||||
<div class="ticket-events-list__divider"></div>
|
||||
}
|
||||
}
|
||||
} @else {
|
||||
<p class="ticket-events-list__empty">Aún no tenés eventos con tickets.</p>
|
||||
}
|
||||
</div>
|
||||
</app-menu-content-section>
|
||||
@@ -0,0 +1,66 @@
|
||||
:host {
|
||||
display: block;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ticket-events-page {
|
||||
display: block;
|
||||
width: 100%;
|
||||
max-width: 600px;
|
||||
}
|
||||
|
||||
.ticket-events-list {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.ticket-events-list__divider {
|
||||
width: 100%;
|
||||
height: 1px;
|
||||
background: var(--border-color, #dddddd);
|
||||
}
|
||||
|
||||
.ticket-events-list__empty {
|
||||
margin: 0;
|
||||
padding: 2rem 0;
|
||||
color: #666666;
|
||||
font-size: 1rem;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.ticket-events-list__skeleton {
|
||||
min-height: 84px;
|
||||
padding: 12px 8px;
|
||||
border-bottom: 1px solid var(--border-color, #dddddd);
|
||||
}
|
||||
|
||||
.ticket-events-list__skeleton-image,
|
||||
.ticket-events-list__skeleton-title,
|
||||
.ticket-events-list__skeleton-arrow {
|
||||
display: block;
|
||||
border-radius: 4px;
|
||||
background: #eeeeee;
|
||||
animation: ticket-events-pulse 1.5s infinite ease-in-out;
|
||||
}
|
||||
|
||||
.ticket-events-list__skeleton-image {
|
||||
width: 100%;
|
||||
aspect-ratio: 19 / 13;
|
||||
}
|
||||
|
||||
.ticket-events-list__skeleton-title {
|
||||
width: min(250px, 80%);
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
.ticket-events-list__skeleton-arrow {
|
||||
width: 8px;
|
||||
height: 14px;
|
||||
}
|
||||
|
||||
@keyframes ticket-events-pulse {
|
||||
50% {
|
||||
background-color: #e0e0e0;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,99 @@
|
||||
import { signal } from '@angular/core';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { provideRouter } from '@angular/router';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { TenantService } from '../../../../../../core/services/tenant.service';
|
||||
import { ToastService } from '../../../../../../core/services/toast.service';
|
||||
import { TicketService } from '../tickets-page/ticket.service';
|
||||
import { TicketEventsPage } from './ticket-events-page';
|
||||
|
||||
function withCustomLoading<T extends object>(service: T): T & { withCustomLoading: () => T } {
|
||||
return Object.assign(service, { withCustomLoading: () => service });
|
||||
}
|
||||
|
||||
describe('TicketEventsPage', () => {
|
||||
beforeEach(() => {
|
||||
TestBed.configureTestingModule({
|
||||
providers: [
|
||||
provideRouter([]),
|
||||
{
|
||||
provide: TenantService,
|
||||
useValue: {
|
||||
tenant: signal({
|
||||
menues: [
|
||||
{
|
||||
id: 4,
|
||||
code: 'account.tickets',
|
||||
label: 'Tickets',
|
||||
parent_menu_code: 'account',
|
||||
content_type: 'dynamic',
|
||||
route: '/mi-cuenta/tickets',
|
||||
submenues: [],
|
||||
},
|
||||
],
|
||||
}).asReadonly(),
|
||||
},
|
||||
},
|
||||
{ provide: ToastService, useValue: { danger: vi.fn() } },
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
it('shows the users events with image, title and detail link', async () => {
|
||||
await TestBed.configureTestingModule({ imports: [TicketEventsPage] })
|
||||
.overrideComponent(TicketEventsPage, {
|
||||
set: {
|
||||
providers: [
|
||||
{
|
||||
provide: TicketService,
|
||||
useValue: withCustomLoading({
|
||||
getTicketEvents: () =>
|
||||
Promise.resolve([
|
||||
{ id: 27, title: 'Copa del mundo', image: 'https://example.com/event.jpg' },
|
||||
]),
|
||||
}),
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
const fixture = TestBed.createComponent(TicketEventsPage);
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
|
||||
const page = fixture.nativeElement as HTMLElement;
|
||||
const link = page.querySelector<HTMLAnchorElement>('.ticket-event');
|
||||
|
||||
expect(page.textContent).toContain('TICKETS');
|
||||
expect(page.textContent).toContain('Copa del mundo');
|
||||
expect(link?.getAttribute('href')).toBe('/27');
|
||||
expect(link?.querySelector('img')?.getAttribute('src')).toBe('https://example.com/event.jpg');
|
||||
});
|
||||
|
||||
it('shows the empty state when the user has no ticket events', async () => {
|
||||
await TestBed.configureTestingModule({ imports: [TicketEventsPage] })
|
||||
.overrideComponent(TicketEventsPage, {
|
||||
set: {
|
||||
providers: [
|
||||
{
|
||||
provide: TicketService,
|
||||
useValue: withCustomLoading({ getTicketEvents: () => Promise.resolve([]) }),
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
const fixture = TestBed.createComponent(TicketEventsPage);
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect((fixture.nativeElement as HTMLElement).textContent).toContain(
|
||||
'Aún no tenés eventos con tickets.',
|
||||
);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,31 @@
|
||||
import { Component, inject, OnInit, signal } from '@angular/core';
|
||||
|
||||
import { ToastService } from '../../../../../../core/services/toast.service';
|
||||
import { MenuContentSectionComponent } from '../../../../components/menu-content-section/menu-content-section.component';
|
||||
import { TicketEventResponse, TicketService } from '../tickets-page/ticket.service';
|
||||
import { TicketEventListItem } from './components/ticket-event-list-item/ticket-event-list-item';
|
||||
|
||||
@Component({
|
||||
selector: 'app-ticket-events-page',
|
||||
imports: [MenuContentSectionComponent, TicketEventListItem],
|
||||
providers: [TicketService],
|
||||
templateUrl: './ticket-events-page.html',
|
||||
styleUrl: './ticket-events-page.scss',
|
||||
})
|
||||
export class TicketEventsPage implements OnInit {
|
||||
private readonly ticketService = inject(TicketService);
|
||||
private readonly toastService = inject(ToastService);
|
||||
|
||||
protected readonly events = signal<TicketEventResponse[]>([]);
|
||||
protected readonly isLoading = signal(true);
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
try {
|
||||
this.events.set(await this.ticketService.withCustomLoading().getTicketEvents());
|
||||
} catch {
|
||||
this.toastService.danger('Hubo un error al cargar los eventos');
|
||||
} finally {
|
||||
this.isLoading.set(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
<section class="ticket-event-context" aria-labelledby="ticket-event-context-title">
|
||||
@if (event().image; as image) {
|
||||
<img class="ticket-event-context__image" [src]="image" alt="" />
|
||||
}
|
||||
|
||||
<h2 id="ticket-event-context-title" class="ticket-event-context__title">
|
||||
{{ event().title }}
|
||||
</h2>
|
||||
</section>
|
||||
@@ -0,0 +1,24 @@
|
||||
:host {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.ticket-event-context {
|
||||
padding-top: 1.5rem;
|
||||
border-top: 1px solid var(--border-color);
|
||||
}
|
||||
|
||||
.ticket-event-context__image {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
border-radius: 4px;
|
||||
}
|
||||
|
||||
.ticket-event-context__title {
|
||||
margin: 1rem 0 0;
|
||||
color: #666666;
|
||||
font-size: 13px;
|
||||
font-weight: 700;
|
||||
line-height: 1.4;
|
||||
text-transform: uppercase;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
import { Component, input } from '@angular/core';
|
||||
|
||||
export interface TicketEventContext {
|
||||
title: string;
|
||||
image: string | null;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-ticket-event-context',
|
||||
templateUrl: './ticket-event-context.component.html',
|
||||
styleUrl: './ticket-event-context.component.scss',
|
||||
})
|
||||
export class TicketEventContextComponent {
|
||||
readonly event = input.required<TicketEventContext>();
|
||||
}
|
||||
@@ -7,6 +7,7 @@ import { TenantService } from '../../../../../../core/services/tenant.service';
|
||||
export interface TicketResponse {
|
||||
id: number;
|
||||
tenant_code: string;
|
||||
event_id: number | null;
|
||||
ticket: string;
|
||||
name: string;
|
||||
description: string | null;
|
||||
@@ -22,13 +23,29 @@ export interface TicketResponse {
|
||||
is_used: boolean;
|
||||
}
|
||||
|
||||
export interface TicketEventResponse {
|
||||
id: number;
|
||||
title: string;
|
||||
image: string | null;
|
||||
}
|
||||
|
||||
@Injectable()
|
||||
export class TicketService extends BaseApiService {
|
||||
private readonly tenantService = inject(TenantService);
|
||||
|
||||
getTickets(): Promise<TicketResponse[]> {
|
||||
getTickets(eventId?: number): Promise<TicketResponse[]> {
|
||||
return firstValueFrom(
|
||||
this.http.get<{ data: TicketResponse[] }>(`${this.tenantService.getTenantApiUrl()}/tickets`),
|
||||
this.http.get<{ data: TicketResponse[] }>(`${this.tenantService.getTenantApiUrl()}/tickets`, {
|
||||
params: eventId === undefined ? {} : { event_id: eventId },
|
||||
}),
|
||||
).then((response) => response.data ?? []);
|
||||
}
|
||||
|
||||
getTicketEvents(): Promise<TicketEventResponse[]> {
|
||||
return firstValueFrom(
|
||||
this.http.get<{ data: TicketEventResponse[] }>(
|
||||
`${this.tenantService.getTenantApiUrl()}/tickets/events`,
|
||||
),
|
||||
).then((response) => response.data ?? []);
|
||||
}
|
||||
|
||||
|
||||
@@ -109,3 +109,9 @@
|
||||
}
|
||||
</div>
|
||||
</app-menu-content-section>
|
||||
|
||||
@if (eventId !== undefined) {
|
||||
<ng-template menuPageSidebarContent>
|
||||
<app-ticket-event-context [event]="eventContext()" />
|
||||
</ng-template>
|
||||
}
|
||||
|
||||
@@ -1,24 +1,29 @@
|
||||
import { signal } from '@angular/core';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
|
||||
import { TenantService } from '../../../../../../core/services/tenant.service';
|
||||
import { ToastService } from '../../../../../../core/services/toast.service';
|
||||
import { ModalService } from '../../../../../../core/services/modal.service';
|
||||
import { MenuPageSidebarContentService } from '../../../../components/menu-page-layout/menu-page-sidebar-content.service';
|
||||
import { TicketComponent } from './components/ticket/ticket.component';
|
||||
import { TicketResponse, TicketService } from './ticket.service';
|
||||
import { TicketsPage } from './tickets-page';
|
||||
|
||||
function withCustomLoading<T extends object>(service: T): T & { withCustomLoading: () => T } {
|
||||
return Object.assign(service, {
|
||||
withCustomLoading: () => service,
|
||||
const enhancedService = Object.assign({ getTicketEvents: () => Promise.resolve([]) }, service);
|
||||
|
||||
return Object.assign(enhancedService, {
|
||||
withCustomLoading: () => enhancedService,
|
||||
});
|
||||
}
|
||||
|
||||
const ticket = (overrides: Partial<TicketResponse>): TicketResponse => ({
|
||||
id: 1,
|
||||
tenant_code: 'tenant',
|
||||
event_id: null,
|
||||
ticket: 'ticket-1',
|
||||
name: 'Entrada general',
|
||||
description: null,
|
||||
@@ -299,4 +304,69 @@ describe('TicketsPage', () => {
|
||||
ticket: 'ticket-1',
|
||||
});
|
||||
});
|
||||
|
||||
it('declares contextual test data when tickets belong to an event', async () => {
|
||||
const getTickets = vi.fn().mockResolvedValue([]);
|
||||
const getTicketEvents = vi.fn().mockResolvedValue([
|
||||
{
|
||||
id: 42,
|
||||
title: 'XX Campeonato Mundial de Pelota Vasca',
|
||||
image: 'https://example.com/pelota-vasca.jpg',
|
||||
},
|
||||
]);
|
||||
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [TicketsPage],
|
||||
providers: [
|
||||
MenuPageSidebarContentService,
|
||||
{ provide: ToastService, useValue: { danger: vi.fn() } },
|
||||
{
|
||||
provide: ActivatedRoute,
|
||||
useValue: { snapshot: { paramMap: { get: () => '42' } } },
|
||||
},
|
||||
],
|
||||
})
|
||||
.overrideComponent(TicketsPage, {
|
||||
set: {
|
||||
providers: [
|
||||
{
|
||||
provide: TicketService,
|
||||
useValue: withCustomLoading({ getTickets, getTicketEvents }),
|
||||
},
|
||||
],
|
||||
},
|
||||
})
|
||||
.compileComponents();
|
||||
|
||||
const fixture = TestBed.createComponent(TicketsPage);
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
await vi.waitFor(() => expect(getTicketEvents).toHaveBeenCalledOnce());
|
||||
await vi.waitFor(() =>
|
||||
expect(
|
||||
(
|
||||
fixture.componentInstance as unknown as { eventContext: () => { image: string | null } }
|
||||
).eventContext().image,
|
||||
).toBe('https://example.com/pelota-vasca.jpg'),
|
||||
);
|
||||
|
||||
const sidebarContent = TestBed.inject(MenuPageSidebarContentService);
|
||||
const sidebarView = sidebarContent.template()?.createEmbeddedView({});
|
||||
sidebarView?.detectChanges();
|
||||
|
||||
const container = document.createElement('div');
|
||||
sidebarView?.rootNodes.forEach((node) => container.appendChild(node));
|
||||
|
||||
expect(getTickets).toHaveBeenCalledWith(42);
|
||||
expect(container.querySelector('.ticket-event-context')?.textContent).toContain(
|
||||
'XX Campeonato Mundial de Pelota Vasca',
|
||||
);
|
||||
expect(container.querySelector<HTMLImageElement>('.ticket-event-context__image')?.src).toBe(
|
||||
'https://example.com/pelota-vasca.jpg',
|
||||
);
|
||||
expect(container.querySelector('.ticket-event-context__details')).toBeNull();
|
||||
expect(container.querySelector('.ticket-event-context__recommendation')).toBeNull();
|
||||
|
||||
sidebarView?.destroy();
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,15 +1,27 @@
|
||||
import { Component, computed, inject, OnInit, signal } from '@angular/core';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
|
||||
import { ModalService } from '../../../../../../core/services/modal.service';
|
||||
import { ToastService } from '../../../../../../core/services/toast.service';
|
||||
import { IconButtonComponent } from '../../../../../../shared/components/icon-button/icon-button.component';
|
||||
import { MenuContentSectionComponent } from '../../../../components/menu-content-section/menu-content-section.component';
|
||||
import { MenuPageSidebarContentDirective } from '../../../../components/menu-page-layout/menu-page-sidebar-content.directive';
|
||||
import {
|
||||
TicketEventContext,
|
||||
TicketEventContextComponent,
|
||||
} from './components/ticket-event-context/ticket-event-context.component';
|
||||
import { TicketComponent } from './components/ticket/ticket.component';
|
||||
import { TicketResponse, TicketService } from './ticket.service';
|
||||
|
||||
@Component({
|
||||
selector: 'app-tickets-page',
|
||||
imports: [IconButtonComponent, TicketComponent, MenuContentSectionComponent],
|
||||
imports: [
|
||||
IconButtonComponent,
|
||||
TicketComponent,
|
||||
TicketEventContextComponent,
|
||||
MenuContentSectionComponent,
|
||||
MenuPageSidebarContentDirective,
|
||||
],
|
||||
providers: [TicketService],
|
||||
templateUrl: './tickets-page.html',
|
||||
styleUrl: './tickets-page.scss',
|
||||
@@ -18,7 +30,13 @@ export class TicketsPage implements OnInit {
|
||||
private readonly ticketService = inject(TicketService);
|
||||
private readonly toastService = inject(ToastService);
|
||||
private readonly modalService = inject(ModalService);
|
||||
private readonly route = inject(ActivatedRoute, { optional: true });
|
||||
|
||||
protected readonly eventId = this.eventIdFromRoute();
|
||||
protected readonly eventContext = signal<TicketEventContext>({
|
||||
title: 'XX Campeonato Mundial de Pelota Vasca',
|
||||
image: null,
|
||||
});
|
||||
protected readonly tickets = signal<TicketResponse[]>([]);
|
||||
protected readonly activeTickets = computed(() =>
|
||||
this.tickets().filter((ticket) => !this.isInactive(ticket)),
|
||||
@@ -36,7 +54,25 @@ export class TicketsPage implements OnInit {
|
||||
|
||||
async ngOnInit(): Promise<void> {
|
||||
try {
|
||||
this.tickets.set(await this.ticketService.withCustomLoading().getTickets());
|
||||
const service = this.ticketService.withCustomLoading();
|
||||
this.tickets.set(await service.getTickets(this.eventId));
|
||||
|
||||
if (this.eventId !== undefined) {
|
||||
void service
|
||||
.getTicketEvents()
|
||||
.then((events) => {
|
||||
const event = events.find((candidate) => candidate.id === this.eventId);
|
||||
|
||||
if (event) {
|
||||
this.eventContext.update((context) => ({
|
||||
...context,
|
||||
title: event.title,
|
||||
image: event.image,
|
||||
}));
|
||||
}
|
||||
})
|
||||
.catch(() => undefined);
|
||||
}
|
||||
} catch {
|
||||
this.toastService.danger('Hubo un error al cargar los tickets');
|
||||
} finally {
|
||||
@@ -44,6 +80,13 @@ export class TicketsPage implements OnInit {
|
||||
}
|
||||
}
|
||||
|
||||
private eventIdFromRoute(): number | undefined {
|
||||
const value = this.route?.snapshot.paramMap.get('eventId');
|
||||
const eventId = value === null || value === undefined ? Number.NaN : Number(value);
|
||||
|
||||
return Number.isInteger(eventId) && eventId > 0 ? eventId : undefined;
|
||||
}
|
||||
|
||||
protected toggleAll(selected: boolean): void {
|
||||
this.selectedIds.set(
|
||||
selected ? new Set(this.activeTickets().map((ticket) => ticket.id)) : new Set(),
|
||||
|
||||
@@ -47,7 +47,26 @@
|
||||
</div>
|
||||
|
||||
<div class="checkout-page__cart-col">
|
||||
@if (checkoutRemainingTime(); as remainingTime) {
|
||||
@if (usesEventCheckoutSummary()) {
|
||||
@if (checkoutRemainingTime(); as remainingTime) {
|
||||
<div
|
||||
class="checkout-page__summary-countdown d-flex align-items-baseline justify-content-center gap-3"
|
||||
role="timer"
|
||||
aria-label="Tiempo restante de compra"
|
||||
>
|
||||
<span class="checkout-page__summary-countdown-label">Tiempo restante de compra:</span>
|
||||
<span class="checkout-page__summary-countdown-value">{{ remainingTime }}</span>
|
||||
</div>
|
||||
}
|
||||
|
||||
@if (checkoutEvent(); as event) {
|
||||
@if (event.image) {
|
||||
<div class="checkout-page__event-media">
|
||||
<img [src]="event.image" [alt]="event.title" />
|
||||
</div>
|
||||
}
|
||||
}
|
||||
} @else if (checkoutRemainingTime(); as remainingTime) {
|
||||
<div
|
||||
class="checkout-page__mobile-countdown d-flex d-md-none align-items-baseline justify-content-center gap-3"
|
||||
role="timer"
|
||||
|
||||
@@ -46,6 +46,38 @@
|
||||
line-height: 1;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
&__summary-countdown {
|
||||
flex: 0 0 auto;
|
||||
margin-bottom: 1.5rem;
|
||||
color: var(--tenant-primary);
|
||||
font-weight: 700;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&__summary-countdown-label {
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
&__summary-countdown-value {
|
||||
font-size: 20px;
|
||||
line-height: 1;
|
||||
font-variant-numeric: tabular-nums;
|
||||
}
|
||||
|
||||
&__event-media {
|
||||
flex: 0 0 auto;
|
||||
width: 100%;
|
||||
margin-bottom: 1rem;
|
||||
overflow: hidden;
|
||||
border-radius: 4px;
|
||||
|
||||
img {
|
||||
display: block;
|
||||
width: 100%;
|
||||
height: auto;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
.checkout-page__loading {
|
||||
|
||||
@@ -39,6 +39,8 @@ describe('CheckoutPageComponent payment validation', () => {
|
||||
let tenantState: ReturnType<
|
||||
typeof signal<{
|
||||
codigo: string;
|
||||
storefront_website_type_code?: string | null;
|
||||
checkout_summary_type?: 'default' | 'event';
|
||||
checkout_editing_policy?: CartEditingPolicy;
|
||||
}>
|
||||
>;
|
||||
@@ -468,6 +470,49 @@ describe('CheckoutPageComponent payment validation', () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('uses the event image and removes item images for multi-event checkout', () => {
|
||||
tenantState.set({
|
||||
...tenantState(),
|
||||
checkout_summary_type: 'event',
|
||||
});
|
||||
const { component } = createComponent();
|
||||
component.createdPurchase.set({
|
||||
id: 25,
|
||||
status: 'created',
|
||||
event: {
|
||||
id: 12,
|
||||
title: 'Festival de prueba',
|
||||
image: 'https://example.com/event.jpg',
|
||||
},
|
||||
items: [
|
||||
{
|
||||
id: 91,
|
||||
quantity: 1,
|
||||
unit_price: '10000.00',
|
||||
line_total: '10000.00',
|
||||
source_catalog_item_id: 8,
|
||||
source_variant_id: null,
|
||||
item_details: {
|
||||
nombre: 'Entrada general',
|
||||
descripcion: null,
|
||||
slug: 'entrada-general',
|
||||
imagen: 'https://example.com/product.jpg',
|
||||
attributes: [],
|
||||
},
|
||||
},
|
||||
],
|
||||
subtotal: '10000.00',
|
||||
total: '10000.00',
|
||||
});
|
||||
|
||||
expect(component.checkoutEvent()).toEqual({
|
||||
id: 12,
|
||||
title: 'Festival de prueba',
|
||||
image: 'https://example.com/event.jpg',
|
||||
});
|
||||
expect(component.mappedCartItems()[0].imageUrl).toBeNull();
|
||||
});
|
||||
|
||||
it('keeps the checkout hidden while the purchase is loading', async () => {
|
||||
let resolvePurchase!: (purchase: any) => void;
|
||||
routeParamMap = convertToParamMap({ id: 25 });
|
||||
|
||||
@@ -138,6 +138,12 @@ export class CheckoutPageComponent implements OnInit, OnDestroy {
|
||||
const purchase = this.createdPurchase();
|
||||
return purchase ? purchase.items.map((item) => this.mapPurchaseItemToMock(item)) : [];
|
||||
});
|
||||
protected readonly usesEventCheckoutSummary = computed(
|
||||
() => this.tenantService.tenant()?.checkout_summary_type === 'event',
|
||||
);
|
||||
protected readonly checkoutEvent = computed(() =>
|
||||
this.usesEventCheckoutSummary() ? (this.createdPurchase()?.event ?? null) : null,
|
||||
);
|
||||
|
||||
protected readonly isStep1Valid = signal(this.form.valid);
|
||||
protected readonly paymentMethods: ReadonlyArray<PaymentMethodOption> = [
|
||||
@@ -235,7 +241,7 @@ export class CheckoutPageComponent implements OnInit, OnDestroy {
|
||||
private mapPurchaseItemToMock(item: PurchaseDetailItemResponse): CartItemMock {
|
||||
return {
|
||||
cartItemId: item.id,
|
||||
imageUrl: item.item_details.imagen,
|
||||
imageUrl: this.usesEventCheckoutSummary() ? null : (item.item_details.imagen ?? null),
|
||||
product: item.item_details.nombre,
|
||||
originalPrice: null,
|
||||
discountedPrice: parseFloat(item.unit_price),
|
||||
|
||||
@@ -22,10 +22,12 @@ import { EventListComponent } from '../../components/event-list/event-list.compo
|
||||
export class EventCategoryPageComponent {
|
||||
private readonly route = inject(ActivatedRoute);
|
||||
private readonly tenant = inject(TenantService).tenant;
|
||||
private readonly params = toSignal(this.route.paramMap, { initialValue: this.route.snapshot.paramMap });
|
||||
private readonly params = toSignal(this.route.paramMap, {
|
||||
initialValue: this.route.snapshot.paramMap,
|
||||
});
|
||||
|
||||
protected readonly category = computed(() => {
|
||||
const id = Number(this.params().get('id'));
|
||||
return this.tenant()?.categories.find((category) => category.id === id) ?? null;
|
||||
return this.tenant()?.event_categories?.find((category) => category.id === id) ?? null;
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
@if (event(); as item) {
|
||||
<div class="event-detail row gx-sm-4 gx-lg-5">
|
||||
<aside class="event-detail__sidebar col-12 col-sm-4">
|
||||
<div class="event-detail">
|
||||
<aside class="event-detail__sidebar">
|
||||
<div class="event-detail__image" [class.event-detail__image--placeholder]="!item.image">
|
||||
@if (item.image) {
|
||||
<img [src]="item.image" [alt]="item.title" />
|
||||
@@ -12,37 +12,9 @@
|
||||
@if (item.starts_at) {
|
||||
<app-counter-to [startsAt]="item.starts_at" />
|
||||
}
|
||||
|
||||
@if (item.description) {
|
||||
<section class="event-detail__description" aria-labelledby="event-description-title">
|
||||
<h2 id="event-description-title">Descripción</h2>
|
||||
<p>{{ item.description }}</p>
|
||||
</section>
|
||||
}
|
||||
|
||||
@if (item.social_media?.length) {
|
||||
<section class="event-detail__social" aria-labelledby="event-social-title">
|
||||
<h2 id="event-social-title">Información</h2>
|
||||
@for (social of item.social_media; track social.code) {
|
||||
<a [href]="social.url" target="_blank" rel="noopener noreferrer">
|
||||
<i [class]="socialIcon(social.code)" aria-hidden="true"></i>
|
||||
<span>{{ socialLabel(social.code) }}</span>
|
||||
</a>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
|
||||
@if (mapLocations().length) {
|
||||
<app-location-map
|
||||
class="event-detail__map"
|
||||
[locations]="mapLocations()"
|
||||
ariaLabel="Ubicación del evento"
|
||||
mapStyle="minimal-light"
|
||||
/>
|
||||
}
|
||||
</aside>
|
||||
|
||||
<main class="event-detail__main col-12 col-sm-8">
|
||||
<main class="event-detail__main">
|
||||
<header class="event-detail__header">
|
||||
<h1>{{ item.title }}</h1>
|
||||
@if (item.subtitle) { <p class="event-detail__subtitle">{{ item.subtitle }}</p> }
|
||||
@@ -52,8 +24,8 @@
|
||||
{{ item.date_text }}@if (item.dates?.length === 1 && item.start_time) { · {{ item.start_time.slice(0, 5) }} h }
|
||||
</p>
|
||||
}
|
||||
@if (item.location) {
|
||||
<p><i class="fa-solid fa-location-dot" aria-hidden="true"></i>{{ item.location }}</p>
|
||||
@if (item.address?.address_text; as location) {
|
||||
<p><i class="fa-solid fa-location-dot" aria-hidden="true"></i>{{ location }}</p>
|
||||
}
|
||||
</div>
|
||||
</header>
|
||||
@@ -95,7 +67,7 @@
|
||||
</div>
|
||||
<div class="event-detail__total"><span>Total</span><strong>{{ formatPrice(total()) }}</strong></div>
|
||||
<div class="event-detail__buttons">
|
||||
<app-button variant="cancel" (click)="cancel()">Cancelar</app-button>
|
||||
<app-button variant="cancel" [disabled]="!hasSelectedItems()" (click)="cancel()">Cancelar</app-button>
|
||||
<app-button variant="primary" [disabled]="total() === 0 || submitting()" (click)="buyNow()">
|
||||
{{ submitting() ? 'Procesando…' : 'Comprar' }}
|
||||
</app-button>
|
||||
@@ -105,6 +77,36 @@
|
||||
}
|
||||
</section>
|
||||
</main>
|
||||
|
||||
<aside class="event-detail__details">
|
||||
@if (item.description) {
|
||||
<section class="event-detail__description" aria-labelledby="event-description-title">
|
||||
<h2 id="event-description-title">Descripción</h2>
|
||||
<p>{{ item.description }}</p>
|
||||
</section>
|
||||
}
|
||||
|
||||
@if (item.social_media?.length) {
|
||||
<section class="event-detail__social" aria-labelledby="event-social-title">
|
||||
<h2 id="event-social-title">Información</h2>
|
||||
@for (social of item.social_media; track social.code) {
|
||||
<a [href]="social.url" target="_blank" rel="noopener noreferrer">
|
||||
<i [class]="socialIcon(social.code)" aria-hidden="true"></i>
|
||||
<span>{{ socialLabel(social.code) }}</span>
|
||||
</a>
|
||||
}
|
||||
</section>
|
||||
}
|
||||
|
||||
@if (mapLocations().length) {
|
||||
<app-location-map
|
||||
class="event-detail__map"
|
||||
[locations]="mapLocations()"
|
||||
ariaLabel="Ubicación del evento"
|
||||
mapStyle="standard"
|
||||
/>
|
||||
}
|
||||
</aside>
|
||||
</div>
|
||||
} @else if (!loading()) {
|
||||
<p role="alert">No encontramos este evento.</p>
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
:host { display: block; color: #666666; }
|
||||
.event-detail { margin-bottom: 3rem; }
|
||||
.event-detail { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 2fr); column-gap: 1.5rem; margin-bottom: 3rem; }
|
||||
.event-detail__sidebar, .event-detail__main { min-width: 0; }
|
||||
.event-detail__sidebar { grid-column: 1; grid-row: 1; }
|
||||
.event-detail__main { grid-column: 2; grid-row: 1 / span 2; }
|
||||
.event-detail__details { min-width: 0; grid-column: 1; grid-row: 2; }
|
||||
.event-detail__image { background: #e7e8e9; }
|
||||
.event-detail__image--placeholder { aspect-ratio: 1.43; display: grid; place-items: center; }
|
||||
.event-detail__image img { width: 100%; height: auto; display: block; }
|
||||
@@ -10,8 +13,8 @@
|
||||
.event-detail__description p { margin: 0; white-space: pre-line; line-height: 1.36; font-size: 14px; }
|
||||
.event-detail__social { display: grid; gap: .35rem; margin-top: 2.3rem; }
|
||||
.event-detail__social a { color: #666666; font-family: 'Gotham Book', sans-serif; font-size: 14px; font-weight: 400; display: flex; align-items: center; gap: .5rem; text-decoration: none; font-style: italic; }
|
||||
.event-detail__social a:hover { color: var(--tenant-primary); text-decoration: underline; }
|
||||
.event-detail__social i { width: 14px; font-size: 14px; text-align: center; }
|
||||
.event-detail__social a:hover { color: var(--tenant-primary); text-decoration: none; }
|
||||
.event-detail__social i { width: 18px; height: 18px; font-size: 18px; line-height: 18px; text-align: center; }
|
||||
.event-detail__map { margin-top: 16px; --location-map-min-height: 180px; --location-map-border-radius: 0; }
|
||||
.event-detail__header { margin-bottom: 2rem; padding-top: .7rem; }
|
||||
.event-detail__header h1 { margin: 0; color: #666666; font-size: 24px; line-height: 1.25; font-weight: 700; text-transform: uppercase; letter-spacing: .03em; }
|
||||
@@ -34,10 +37,40 @@
|
||||
.event-detail__buttons { display: flex; justify-content: flex-end; gap: .5rem; margin-top: 1.6rem; }
|
||||
.event-detail__buttons app-button { min-width: 0; flex: 0 0 36%; }
|
||||
.event-detail__empty { color: #7c8286; font-size: .85rem; }
|
||||
@media (min-width: 992px) {
|
||||
.event-detail { column-gap: 3rem; }
|
||||
}
|
||||
@media (max-width: 575.98px) {
|
||||
.event-detail { grid-template-columns: minmax(0, 1fr); }
|
||||
.event-detail__sidebar, .event-detail__main, .event-detail__details { grid-column: 1; grid-row: auto; }
|
||||
.event-detail__main { margin-top: 2rem; }
|
||||
.event-detail__date-select { width: 100%; }
|
||||
.event-detail__description, .event-detail__social { margin-top: 1.5rem; }
|
||||
.event-detail__header { min-height: 0; margin-bottom: 2rem; }
|
||||
.event-detail__buttons { flex-wrap: wrap; }
|
||||
.event-detail__buttons app-button { flex: 1 1 100%; }
|
||||
.event-detail__header h1 { font-size: 20px; }
|
||||
.event-detail__product-list { gap: 42px; }
|
||||
.event-detail__product {
|
||||
display: grid;
|
||||
grid-template-columns: minmax(0, 1fr) 96px 72px;
|
||||
column-gap: 26px;
|
||||
margin-inline: 0;
|
||||
}
|
||||
.event-detail__product > * { width: auto; margin-top: 0; padding-inline: 0; }
|
||||
.event-detail__product h3 { align-self: center; font-size: 13px; }
|
||||
.event-detail__product-action { margin-left: 0 !important; }
|
||||
.event-detail__product-action app-quantity-selector {
|
||||
--quantity-selector-width: 96px;
|
||||
--quantity-selector-height: 32px;
|
||||
--quantity-selector-button-width: 28px;
|
||||
--quantity-selector-button-font-size: 14px;
|
||||
--quantity-selector-value-font-size: 14px;
|
||||
}
|
||||
.event-detail__price { align-self: center; font-size: 14px; }
|
||||
.event-detail__total { margin-top: 44px; padding-top: 25px; font-size: 13px; }
|
||||
.event-detail__total strong { font-size: 20px; }
|
||||
.event-detail__buttons { gap: 10px; margin-top: 44px; }
|
||||
.event-detail__buttons app-button {
|
||||
--app-button-min-height: 50px;
|
||||
flex: 1 1 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
import { signal } from '@angular/core';
|
||||
import { TestBed } from '@angular/core/testing';
|
||||
import { By } from '@angular/platform-browser';
|
||||
import { ActivatedRoute, convertToParamMap, provideRouter } from '@angular/router';
|
||||
import { of } from 'rxjs';
|
||||
import { beforeEach, describe, expect, it } from 'vitest';
|
||||
|
||||
import { AuthService } from '../../../../core/services/auth/auth.service';
|
||||
import { CheckoutService } from '../../../../core/services/checkout.service';
|
||||
import { StoreEvent } from '../../../../core/services/event/event.interface';
|
||||
import { EventService } from '../../../../core/services/event/event.service';
|
||||
import { TenantService } from '../../../../core/services/tenant.service';
|
||||
import { ToastService } from '../../../../core/services/toast.service';
|
||||
import { LocationMapComponent } from '../../../../shared/components/location-map/location-map.component';
|
||||
import { EventDetailPageComponent } from './event-detail-page.component';
|
||||
|
||||
const event: StoreEvent = {
|
||||
id: 1, slug: 'festival', title: 'Festival', event_category_id: null,
|
||||
subtitle: null, description: null, location: 'Ubicación anterior',
|
||||
exact_location: { latitude: 10, longitude: 20 }, date_text: null,
|
||||
attachment_id: null, image: null,
|
||||
address: { id: 20, label: 'Predio', address_text: 'Dirección del evento 123', latitude: 0, longitude: -60 },
|
||||
};
|
||||
|
||||
describe('EventDetailPageComponent address', () => {
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [EventDetailPageComponent],
|
||||
providers: [
|
||||
provideRouter([]),
|
||||
{ provide: ActivatedRoute, useValue: { paramMap: of(convertToParamMap({ slug: 'festival' })) } },
|
||||
{ provide: EventService, useValue: { get: () => of({ data: event }) } },
|
||||
{ provide: AuthService, useValue: {} },
|
||||
{ provide: CheckoutService, useValue: {} },
|
||||
{ provide: TenantService, useValue: { tenant: signal(null) } },
|
||||
{ provide: ToastService, useValue: {} },
|
||||
],
|
||||
}).compileComponents();
|
||||
});
|
||||
|
||||
it('uses the event address for its text and map including zero coordinates', () => {
|
||||
const fixture = TestBed.createComponent(EventDetailPageComponent);
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement.textContent).toContain('Dirección del evento 123');
|
||||
expect(fixture.nativeElement.textContent).not.toContain('Ubicación anterior');
|
||||
const map = fixture.debugElement.query(By.directive(LocationMapComponent)).componentInstance as LocationMapComponent;
|
||||
expect(map.locations).toEqual([{ id: 20, label: 'Predio', latitude: 0, longitude: -60, address: 'Dirección del evento 123' }]);
|
||||
});
|
||||
|
||||
it('shows address text without using old map coordinates when the new address has none', () => {
|
||||
TestBed.overrideProvider(EventService, { useValue: { get: () => of({ data: {
|
||||
...event, address: { ...event.address!, latitude: null, longitude: null },
|
||||
} }) } });
|
||||
const fixture = TestBed.createComponent(EventDetailPageComponent);
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement.textContent).toContain('Dirección del evento 123');
|
||||
expect(fixture.nativeElement.querySelector('app-location-map')).toBeNull();
|
||||
});
|
||||
|
||||
it('does not use old location fields when the event has no address', () => {
|
||||
TestBed.overrideProvider(EventService, { useValue: { get: () => of({ data: { ...event, address: null } }) } });
|
||||
const fixture = TestBed.createComponent(EventDetailPageComponent);
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement.textContent).not.toContain('Ubicación anterior');
|
||||
expect(fixture.nativeElement.querySelector('app-location-map')).toBeNull();
|
||||
});
|
||||
});
|
||||
@@ -41,27 +41,30 @@ export class EventDetailPageComponent {
|
||||
protected readonly submitting = signal(false);
|
||||
protected readonly mapLocations = computed<MapLocation[]>(() => {
|
||||
const event = this.event();
|
||||
const coordinates = event?.exact_location;
|
||||
if (!event || !coordinates) return [];
|
||||
const address = event?.address;
|
||||
if (!event || !address || address.latitude === null || address.longitude === null) return [];
|
||||
|
||||
return [{
|
||||
id: event.id,
|
||||
label: event.title,
|
||||
latitude: coordinates.latitude,
|
||||
longitude: coordinates.longitude,
|
||||
address: event.location ?? undefined,
|
||||
id: address.id,
|
||||
label: address.label,
|
||||
latitude: address.latitude,
|
||||
longitude: address.longitude,
|
||||
address: address.address_text,
|
||||
}];
|
||||
});
|
||||
protected readonly total = computed(() => (this.event()?.catalog_items ?? []).reduce((sum, product) => {
|
||||
const choice = this.resolveChoice(product);
|
||||
return sum + (choice ? choice.price * this.quantityFor(product.id) : 0);
|
||||
}, 0));
|
||||
protected readonly hasSelectedItems = computed(() =>
|
||||
Object.values(this.quantities()).some((quantity) => quantity > 0),
|
||||
);
|
||||
|
||||
constructor() {
|
||||
this.route.paramMap.pipe(
|
||||
map((params) => Number(params.get('id'))),
|
||||
switchMap((id) => Number.isInteger(id) && id > 0
|
||||
? this.events.get(id).pipe(map((response) => response.data), catchError(() => of(null)))
|
||||
map((params) => params.get('slug')?.trim() ?? ''),
|
||||
switchMap((slug) => slug
|
||||
? this.events.get(slug).pipe(map((response) => response.data), catchError(() => of(null)))
|
||||
: of(null)),
|
||||
takeUntilDestroyed(this.destroyRef),
|
||||
).subscribe((event) => {
|
||||
@@ -131,7 +134,7 @@ export class EventDetailPageComponent {
|
||||
}
|
||||
|
||||
protected cancel(): void {
|
||||
void this.router.navigate(['/']);
|
||||
this.quantities.set({});
|
||||
}
|
||||
|
||||
protected async buyNow(): Promise<void> {
|
||||
|
||||
@@ -1,22 +1,34 @@
|
||||
<app-menu-content-section menuCode="help.contact" titleId="contact-page-title">
|
||||
<div class="contact-page">
|
||||
<div class="contact-page__details">
|
||||
@if (contact().whatsappUrl && contact().whatsappLabel) {
|
||||
@for (whatsapp of contact().whatsapp; track whatsapp.code) {
|
||||
<a
|
||||
class="contact-page__contact-link"
|
||||
[href]="contact().whatsappUrl"
|
||||
[href]="whatsapp.url"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<i class="fa-brands fa-whatsapp" aria-hidden="true"></i>
|
||||
<span>{{ contact().whatsappLabel }}</span>
|
||||
<i [class]="whatsapp.icon" aria-hidden="true"></i>
|
||||
<span>{{ whatsapp.name }}</span>
|
||||
</a>
|
||||
}
|
||||
|
||||
@if (contact().phone; as phone) {
|
||||
<a class="contact-page__contact-link" [href]="phoneUrl(phone)">
|
||||
@for (social of contact().socialMedia; track social.code) {
|
||||
<a
|
||||
class="contact-page__contact-link"
|
||||
[href]="social.url"
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
>
|
||||
<i [class]="social.icon" aria-hidden="true"></i>
|
||||
<span>{{ social.name }}</span>
|
||||
</a>
|
||||
}
|
||||
|
||||
@for (phone of contact().phones; track phone.id) {
|
||||
<a class="contact-page__contact-link" [href]="phone.tel_url">
|
||||
<i class="fa-solid fa-phone" aria-hidden="true"></i>
|
||||
<span>{{ phone }}</span>
|
||||
<span>{{ phone.label }}: {{ phone.number }}</span>
|
||||
</a>
|
||||
}
|
||||
|
||||
@@ -35,7 +47,12 @@
|
||||
</article>
|
||||
}
|
||||
|
||||
@if (!contact().whatsappUrl && !contact().phone && contact().locations.length === 0) {
|
||||
@if (
|
||||
contact().whatsapp.length === 0 &&
|
||||
contact().socialMedia.length === 0 &&
|
||||
contact().phones.length === 0 &&
|
||||
contact().locations.length === 0
|
||||
) {
|
||||
<p class="contact-page__empty">No hay datos de contacto disponibles.</p>
|
||||
}
|
||||
</div>
|
||||
@@ -45,7 +62,7 @@
|
||||
class="contact-page__map"
|
||||
[locations]="contact().mapLocations"
|
||||
[markerColor]="markerColor()"
|
||||
mapStyle="minimal-light"
|
||||
mapStyle="standard"
|
||||
ariaLabel="Mapa de sucursales y puntos de atención"
|
||||
/>
|
||||
}
|
||||
|
||||
@@ -19,6 +19,56 @@ const tenant: Tenant = {
|
||||
header_logo: '',
|
||||
footer_logo: '',
|
||||
categories: [],
|
||||
social_media: [
|
||||
{
|
||||
code: 'whatsapp',
|
||||
name: 'WhatsApp',
|
||||
icon: 'fa-brands fa-whatsapp',
|
||||
url: 'https://wa.me/543412602222',
|
||||
},
|
||||
{
|
||||
code: 'instagram',
|
||||
name: 'Instagram',
|
||||
icon: 'fa-brands fa-instagram',
|
||||
url: 'https://www.instagram.com/comercio',
|
||||
},
|
||||
],
|
||||
phone_numbers: [
|
||||
{
|
||||
id: 1,
|
||||
label: 'Principal',
|
||||
number: '+54 9 (0341) 6658247',
|
||||
tel_url: 'tel:+54903416658247',
|
||||
is_main: true,
|
||||
},
|
||||
{ id: 2, label: 'Ventas', number: '3411234567', tel_url: 'tel:3411234567', is_main: false },
|
||||
],
|
||||
addresses: [
|
||||
{
|
||||
id: 1,
|
||||
label: 'Gigante de Arroyito',
|
||||
address_text: 'Av. Génova 640, Rosario',
|
||||
latitude: -32.913997,
|
||||
longitude: -60.674567,
|
||||
is_main: true,
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
label: 'Telepagos',
|
||||
address_text: 'Rioja 1150, piso 12, dpto. 3, Rosario',
|
||||
latitude: -32.94682,
|
||||
longitude: -60.63932,
|
||||
is_main: false,
|
||||
},
|
||||
{
|
||||
id: 3,
|
||||
label: 'San Martín 2450',
|
||||
address_text: 'San Martín 2450, Santa Fe',
|
||||
latitude: -31.63333,
|
||||
longitude: -60.7,
|
||||
is_main: false,
|
||||
},
|
||||
],
|
||||
menues: [
|
||||
{
|
||||
id: 1,
|
||||
@@ -33,42 +83,8 @@ const tenant: Tenant = {
|
||||
code: 'help.contact',
|
||||
label: 'Contacto',
|
||||
parent_menu_code: 'help',
|
||||
content_type: 'static',
|
||||
content_type: 'dynamic',
|
||||
route: '/ayuda/contacto',
|
||||
static_content: {
|
||||
whatsapp: {
|
||||
whatsapp_url: 'https://wa.me/543412602222',
|
||||
whatsapp_label: 'Chatea con nosotros',
|
||||
},
|
||||
phone: '+54 9 (0341) 6658247',
|
||||
locations: {
|
||||
rosario: {
|
||||
label: 'Rosario',
|
||||
addresses: [
|
||||
{
|
||||
label: 'Gigante de Arroyito',
|
||||
address: 'Av. Génova 640, Rosario',
|
||||
coordinates: [-32.913997, -60.674567],
|
||||
},
|
||||
{
|
||||
label: 'Telepagos',
|
||||
address: 'Rioja 1150, piso 12, dpto. 3, Rosario',
|
||||
coordinates: [-32.94682, -60.63932],
|
||||
},
|
||||
],
|
||||
},
|
||||
santa_fe: {
|
||||
label: 'Santa Fe',
|
||||
addresses: [
|
||||
{
|
||||
label: 'San Martín 2450',
|
||||
address: 'San Martín 2450, Santa Fe',
|
||||
coordinates: [-31.63333, -60.7],
|
||||
},
|
||||
],
|
||||
},
|
||||
},
|
||||
},
|
||||
submenues: [],
|
||||
},
|
||||
],
|
||||
@@ -78,15 +94,17 @@ const tenant: Tenant = {
|
||||
|
||||
describe('ContactPage', () => {
|
||||
let fixture: ComponentFixture<ContactPage>;
|
||||
let tenantState = signal<Tenant | null>(tenant);
|
||||
|
||||
beforeEach(async () => {
|
||||
tenantState = signal<Tenant | null>(tenant);
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [ContactPage],
|
||||
providers: [
|
||||
{
|
||||
provide: TenantService,
|
||||
useValue: {
|
||||
tenant: signal<Tenant | null>(tenant).asReadonly(),
|
||||
tenant: tenantState.asReadonly(),
|
||||
},
|
||||
},
|
||||
],
|
||||
@@ -104,7 +122,10 @@ describe('ContactPage', () => {
|
||||
const phone = element.querySelector<HTMLAnchorElement>('a[href="tel:+54903416658247"]');
|
||||
|
||||
expect(element.textContent).toContain('CONTACTO');
|
||||
expect(whatsapp?.textContent).toContain('Chatea con nosotros');
|
||||
expect(whatsapp?.textContent).toContain('WhatsApp');
|
||||
expect(
|
||||
element.querySelector('a[href="https://www.instagram.com/comercio"]')?.textContent,
|
||||
).toContain('Instagram');
|
||||
expect(phone?.textContent).toContain('+54 9 (0341) 6658247');
|
||||
expect(element.textContent).toContain('Rosario');
|
||||
expect(element.textContent).toContain('Gigante de Arroyito');
|
||||
@@ -112,11 +133,9 @@ describe('ContactPage', () => {
|
||||
expect(element.querySelector('.contact-page__addresses')?.textContent).toContain(
|
||||
'Av. Génova 640, Rosario',
|
||||
);
|
||||
expect(element.querySelector('.contact-page__addresses')?.textContent).toContain(
|
||||
'Rioja 1150, piso 12, dpto. 3, Rosario',
|
||||
);
|
||||
expect(element.textContent).not.toContain('Santa Fe');
|
||||
expect(element.textContent).not.toContain('San Martín 2450');
|
||||
expect(element.textContent).toContain('Rioja 1150, piso 12, dpto. 3, Rosario');
|
||||
expect(element.textContent).toContain('Santa Fe');
|
||||
expect(element.textContent).toContain('San Martín 2450');
|
||||
});
|
||||
|
||||
it('passes the tenant map coordinates to the reusable map component', () => {
|
||||
@@ -128,13 +147,148 @@ describe('ContactPage', () => {
|
||||
);
|
||||
|
||||
expect(map).not.toBeNull();
|
||||
expect(map?.getAttribute('mapstyle')).toBe('minimal-light');
|
||||
expect(accessibleLocations).toHaveLength(2);
|
||||
expect(map?.getAttribute('mapstyle')).toBe('standard');
|
||||
expect(accessibleLocations).toHaveLength(3);
|
||||
expect(map?.textContent).toContain('Gigante de Arroyito');
|
||||
expect(map?.textContent).toContain('Telepagos');
|
||||
expect(map?.textContent).toContain('Av. Génova 640, Rosario');
|
||||
expect(map?.textContent).toContain('Rioja 1150, piso 12, dpto. 3, Rosario');
|
||||
expect(directionsLinks).toHaveLength(2);
|
||||
expect(map?.textContent).not.toContain('San Martín 2450');
|
||||
expect(directionsLinks).toHaveLength(3);
|
||||
expect(map?.textContent).toContain('San Martín 2450');
|
||||
});
|
||||
|
||||
it('renders canonical numbers with the main first and never restores legacy numbers', () => {
|
||||
const element = fixture.nativeElement as HTMLElement;
|
||||
expect(element.querySelectorAll('a[href^="tel:"]')).toHaveLength(2);
|
||||
expect(element.querySelector('a[href^="tel:"]')?.textContent).toContain('Principal');
|
||||
tenantState.set({ ...tenant, phone: '999999', phone_numbers: [] });
|
||||
fixture.detectChanges();
|
||||
expect(element.querySelectorAll('a[href^="tel:"]')).toHaveLength(0);
|
||||
expect(element.textContent).not.toContain('999999');
|
||||
expect(element.textContent).not.toContain('+54 9 (0341) 6658247');
|
||||
});
|
||||
|
||||
it('shows every canonical address and maps only addresses with coordinates', () => {
|
||||
tenantState.set({
|
||||
...tenant,
|
||||
addresses: [
|
||||
{
|
||||
id: 10,
|
||||
label: 'Principal',
|
||||
address_text: 'Nueva sede 123',
|
||||
latitude: 0,
|
||||
longitude: 0,
|
||||
is_main: true,
|
||||
},
|
||||
{
|
||||
id: 11,
|
||||
label: 'Sucursal sin mapa',
|
||||
address_text: 'Otra calle 456',
|
||||
latitude: null,
|
||||
longitude: null,
|
||||
is_main: false,
|
||||
},
|
||||
{
|
||||
id: 12,
|
||||
label: 'Otra ciudad',
|
||||
address_text: 'Tercera 789',
|
||||
latitude: -31,
|
||||
longitude: -60,
|
||||
is_main: false,
|
||||
},
|
||||
],
|
||||
});
|
||||
fixture.detectChanges();
|
||||
const element = fixture.nativeElement as HTMLElement;
|
||||
expect(element.textContent).toContain('Nueva sede 123');
|
||||
expect(element.textContent).toContain('Otra calle 456');
|
||||
expect(element.textContent).toContain('Tercera 789');
|
||||
expect(element.textContent).not.toContain('Av. Génova 640');
|
||||
expect(element.querySelectorAll('.contact-page__location')).toHaveLength(3);
|
||||
expect(element.querySelectorAll('app-location-map .visually-hidden li')).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('does not restore old menu addresses when the canonical list is empty', () => {
|
||||
tenantState.set({ ...tenant, addresses: [] });
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement.querySelectorAll('.contact-page__location')).toHaveLength(0);
|
||||
expect(fixture.nativeElement.querySelector('app-location-map')).toBeNull();
|
||||
});
|
||||
|
||||
it('does not read old menu addresses when the address list is absent', () => {
|
||||
tenantState.set({ ...tenant, addresses: undefined });
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement.querySelectorAll('.contact-page__location')).toHaveLength(0);
|
||||
});
|
||||
|
||||
it('updates contact when the resolved social media changes to the active event channels', () => {
|
||||
tenantState.set({
|
||||
...tenant,
|
||||
social_media: [
|
||||
{
|
||||
code: 'whatsapp',
|
||||
name: 'WhatsApp del evento',
|
||||
icon: 'fa-brands fa-whatsapp',
|
||||
url: 'https://wa.me/541111111111',
|
||||
},
|
||||
],
|
||||
});
|
||||
fixture.detectChanges();
|
||||
const element = fixture.nativeElement as HTMLElement;
|
||||
expect(element.querySelector('a[href="https://wa.me/541111111111"]')?.textContent).toContain(
|
||||
'WhatsApp del evento',
|
||||
);
|
||||
expect(element.querySelector('a[href="https://wa.me/543412602222"]')).toBeNull();
|
||||
expect(element.textContent).not.toContain('Instagram');
|
||||
});
|
||||
|
||||
it('shows the main address first without reordering tenant data', () => {
|
||||
const addresses = [...tenant.addresses!].reverse();
|
||||
tenantState.set({ ...tenant, addresses });
|
||||
fixture.detectChanges();
|
||||
expect(
|
||||
fixture.nativeElement.querySelector('.contact-page__location-title')?.textContent,
|
||||
).toContain('Gigante de Arroyito');
|
||||
expect(addresses[0].id).toBe(3);
|
||||
});
|
||||
|
||||
it('ignores legacy static content and shows the empty state when no canonical data exists', () => {
|
||||
tenantState.set({
|
||||
...tenant,
|
||||
addresses: [],
|
||||
phone_numbers: [],
|
||||
social_media: [],
|
||||
menues: [
|
||||
{
|
||||
...tenant.menues![0].submenues[0],
|
||||
static_content: {
|
||||
whatsapp: {
|
||||
whatsapp_url: 'https://wa.me/549999999999',
|
||||
whatsapp_label: 'Legacy WhatsApp',
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement.textContent).toContain('No hay datos de contacto disponibles.');
|
||||
expect(fixture.nativeElement.textContent).not.toContain('Legacy WhatsApp');
|
||||
expect(fixture.nativeElement.querySelector('a')).toBeNull();
|
||||
expect(fixture.nativeElement.querySelector('app-location-map')).toBeNull();
|
||||
});
|
||||
|
||||
it('shows social-only contact and ignores blank social URLs', () => {
|
||||
tenantState.set({
|
||||
...tenant,
|
||||
addresses: [],
|
||||
phone_numbers: [],
|
||||
social_media: [tenant.social_media![1], { ...tenant.social_media![0], url: ' ' }],
|
||||
});
|
||||
fixture.detectChanges();
|
||||
expect(fixture.nativeElement.textContent).toContain('Instagram');
|
||||
expect(fixture.nativeElement.textContent).not.toContain(
|
||||
'No hay datos de contacto disponibles.',
|
||||
);
|
||||
expect(fixture.nativeElement.textContent).not.toContain('WhatsApp');
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
import { Component, computed, inject } from '@angular/core';
|
||||
|
||||
import { findMenu } from '../../../../../../core/services/menu.utils';
|
||||
import { TenantService } from '../../../../../../core/services/tenant.service';
|
||||
import { TenantPhoneNumber } from '../../../../../../core/services/phone-number.interface';
|
||||
import { SocialMedia } from '../../../../../../core/services/tenant.interface';
|
||||
import { MenuContentSectionComponent } from '../../../../components/menu-content-section/menu-content-section.component';
|
||||
import {
|
||||
LocationMapComponent,
|
||||
@@ -18,13 +19,13 @@ type ContactAddress = {
|
||||
id: string;
|
||||
label: string;
|
||||
address: string;
|
||||
coordinates: [number, number];
|
||||
coordinates: [number, number] | null;
|
||||
};
|
||||
|
||||
type ContactContent = {
|
||||
whatsappUrl: string | null;
|
||||
whatsappLabel: string | null;
|
||||
phone: string | null;
|
||||
whatsapp: SocialMedia[];
|
||||
socialMedia: SocialMedia[];
|
||||
phones: TenantPhoneNumber[];
|
||||
locations: ContactLocation[];
|
||||
mapLocations: MapLocation[];
|
||||
};
|
||||
@@ -42,108 +43,52 @@ export class ContactPage {
|
||||
() => this.tenantService.tenant()?.primary_color ?? '#6376f3',
|
||||
);
|
||||
|
||||
protected readonly contact = computed(() =>
|
||||
this.parseContactContent(
|
||||
findMenu(this.tenantService.tenant()?.menues ?? [], 'help.contact')?.static_content,
|
||||
),
|
||||
);
|
||||
protected readonly contact = computed(() => this.buildContactContent());
|
||||
|
||||
protected phoneUrl(phone: string): string {
|
||||
const normalizedPhone = phone.replace(/[^\d+]/g, '');
|
||||
return `tel:${normalizedPhone}`;
|
||||
}
|
||||
|
||||
private parseContactContent(value: unknown): ContactContent {
|
||||
const empty: ContactContent = {
|
||||
whatsappUrl: null,
|
||||
whatsappLabel: null,
|
||||
phone: null,
|
||||
locations: [],
|
||||
mapLocations: [],
|
||||
};
|
||||
|
||||
if (!this.isRecord(value)) {
|
||||
return empty;
|
||||
}
|
||||
|
||||
const whatsapp = this.isRecord(value['whatsapp']) ? value['whatsapp'] : null;
|
||||
const locations = this.parseLocations(value['locations']).slice(0, 1);
|
||||
private buildContactContent(): ContactContent {
|
||||
const tenant = this.tenantService.tenant();
|
||||
const socialMedia = (tenant?.social_media ?? []).filter((social) => social.url.trim());
|
||||
const addresses = [...(tenant?.addresses ?? [])].sort(
|
||||
(a, b) => Number(b.is_main) - Number(a.is_main),
|
||||
);
|
||||
const locations: ContactLocation[] = addresses.map((address) => ({
|
||||
id: String(address.id),
|
||||
label: address.label,
|
||||
addresses: [
|
||||
{
|
||||
id: String(address.id),
|
||||
label: address.label,
|
||||
address: address.address_text,
|
||||
coordinates:
|
||||
address.latitude !== null && address.longitude !== null
|
||||
? [address.latitude, address.longitude]
|
||||
: null,
|
||||
},
|
||||
],
|
||||
}));
|
||||
|
||||
return {
|
||||
whatsappUrl: whatsapp ? this.stringValue(whatsapp['whatsapp_url']) : null,
|
||||
whatsappLabel: whatsapp ? this.stringValue(whatsapp['whatsapp_label']) : null,
|
||||
phone: this.stringValue(value['phone']),
|
||||
whatsapp: socialMedia.filter((social) => social.code === 'whatsapp'),
|
||||
socialMedia: socialMedia.filter((social) => social.code !== 'whatsapp'),
|
||||
phones: [...(tenant?.phone_numbers ?? [])].sort(
|
||||
(a, b) => Number(b.is_main) - Number(a.is_main),
|
||||
),
|
||||
locations,
|
||||
mapLocations: locations.flatMap((location) =>
|
||||
location.addresses.map(
|
||||
(address): MapLocation => ({
|
||||
id: address.id,
|
||||
label: address.label,
|
||||
latitude: address.coordinates[0],
|
||||
longitude: address.coordinates[1],
|
||||
address: address.address,
|
||||
}),
|
||||
location.addresses.flatMap((address): MapLocation[] =>
|
||||
address.coordinates === null
|
||||
? []
|
||||
: [
|
||||
{
|
||||
id: address.id,
|
||||
label: address.label,
|
||||
latitude: address.coordinates[0],
|
||||
longitude: address.coordinates[1],
|
||||
address: address.address,
|
||||
},
|
||||
],
|
||||
),
|
||||
),
|
||||
};
|
||||
}
|
||||
|
||||
private parseLocations(value: unknown): ContactLocation[] {
|
||||
return this.recordEntries(value).flatMap(([id, item]): ContactLocation[] => {
|
||||
if (!this.isRecord(item)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const label = this.stringValue(item['label']);
|
||||
const addresses: ContactAddress[] = Array.isArray(item['addresses'])
|
||||
? item['addresses'].flatMap((address, index): ContactAddress[] => {
|
||||
if (!this.isRecord(address)) {
|
||||
return [];
|
||||
}
|
||||
|
||||
const addressLabel = this.stringValue(address['label']);
|
||||
const addressText = this.stringValue(address['address']);
|
||||
const coordinates = address['coordinates'];
|
||||
|
||||
if (
|
||||
!addressLabel ||
|
||||
!addressText ||
|
||||
!Array.isArray(coordinates) ||
|
||||
coordinates.length !== 2 ||
|
||||
typeof coordinates[0] !== 'number' ||
|
||||
typeof coordinates[1] !== 'number'
|
||||
) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
{
|
||||
id: `${id}-${index}`,
|
||||
label: addressLabel,
|
||||
address: addressText,
|
||||
coordinates: [coordinates[0], coordinates[1]],
|
||||
},
|
||||
];
|
||||
})
|
||||
: [];
|
||||
|
||||
return label && addresses.length > 0 ? [{ id, label, addresses }] : [];
|
||||
});
|
||||
}
|
||||
|
||||
private recordEntries(value: unknown): [string, unknown][] {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map((item, index) => [String(index), item]);
|
||||
}
|
||||
|
||||
return this.isRecord(value) ? Object.entries(value) : [];
|
||||
}
|
||||
|
||||
private stringValue(value: unknown): string | null {
|
||||
return typeof value === 'string' && value.trim() ? value.trim() : null;
|
||||
}
|
||||
|
||||
private isRecord(value: unknown): value is Record<string, unknown> {
|
||||
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -81,7 +81,7 @@ export class StoreHomePageComponent implements OnInit, OnDestroy {
|
||||
return {
|
||||
id: event.id,
|
||||
title: event.title,
|
||||
location: event.location,
|
||||
location: event.address?.address_text ?? null,
|
||||
dates_text: event.date_text,
|
||||
dates: event.dates.map((eventDate) => ({
|
||||
id: eventDate.id,
|
||||
|
||||
@@ -30,7 +30,9 @@ export const routes: Routes = [
|
||||
canMatch: [isMultiEventStorefront],
|
||||
canActivate: [hasMenuGuard('event.index')],
|
||||
loadComponent: () =>
|
||||
import('./pages/event-home-page/event-home-page.component').then((m) => m.EventHomePageComponent),
|
||||
import('./pages/event-home-page/event-home-page.component').then(
|
||||
(m) => m.EventHomePageComponent,
|
||||
),
|
||||
},
|
||||
{
|
||||
path: '',
|
||||
@@ -86,7 +88,9 @@ export const routes: Routes = [
|
||||
path: 'buscar',
|
||||
canMatch: [isMultiEventStorefront],
|
||||
loadComponent: () =>
|
||||
import('./pages/event-search-page/event-search-page.component').then((m) => m.EventSearchPageComponent),
|
||||
import('./pages/event-search-page/event-search-page.component').then(
|
||||
(m) => m.EventSearchPageComponent,
|
||||
),
|
||||
},
|
||||
{
|
||||
path: 'buscar',
|
||||
@@ -94,15 +98,18 @@ export const routes: Routes = [
|
||||
import('./pages/search-page/search-page.component').then((m) => m.SearchPageComponent),
|
||||
},
|
||||
{
|
||||
path: 'evento/:id',
|
||||
path: 'evento/:slug',
|
||||
canMatch: [isMultiEventStorefront],
|
||||
canActivate: [hasMenuGuard('event.detail')],
|
||||
loadComponent: () =>
|
||||
import('./pages/event-detail-page/event-detail-page.component').then((m) => m.EventDetailPageComponent),
|
||||
import('./pages/event-detail-page/event-detail-page.component').then(
|
||||
(m) => m.EventDetailPageComponent,
|
||||
),
|
||||
},
|
||||
{
|
||||
path: 'categoria/:id',
|
||||
path: 'eventos/categoria/:id',
|
||||
canMatch: [isMultiEventStorefront],
|
||||
canActivate: [hasMenuGuard('event.category')],
|
||||
loadComponent: () =>
|
||||
import('./pages/event-category-page/event-category-page.component').then(
|
||||
(m) => m.EventCategoryPageComponent,
|
||||
@@ -110,6 +117,7 @@ export const routes: Routes = [
|
||||
},
|
||||
{
|
||||
path: 'categoria/:id',
|
||||
canActivate: [hasMenuGuard('product.category')],
|
||||
loadComponent: () =>
|
||||
import('./pages/category-items-page/category-items-page.component').then(
|
||||
(m) => m.CategoryItemsPageComponent,
|
||||
@@ -223,6 +231,24 @@ export const routes: Routes = [
|
||||
(m) => m.PurchaseDetailPage,
|
||||
),
|
||||
},
|
||||
{
|
||||
path: 'tickets/:eventId',
|
||||
canMatch: [isMultiEventStorefront],
|
||||
canActivate: [hasMenuGuard('account.tickets')],
|
||||
loadComponent: () =>
|
||||
import('./pages/account-page/pages/tickets-page/tickets-page').then(
|
||||
(m) => m.TicketsPage,
|
||||
),
|
||||
},
|
||||
{
|
||||
path: 'tickets',
|
||||
canMatch: [isMultiEventStorefront],
|
||||
canActivate: [hasMenuGuard('account.tickets')],
|
||||
loadComponent: () =>
|
||||
import('./pages/account-page/pages/ticket-events-page/ticket-events-page').then(
|
||||
(m) => m.TicketEventsPage,
|
||||
),
|
||||
},
|
||||
{
|
||||
path: 'tickets',
|
||||
canActivate: [hasMenuGuard('account.tickets')],
|
||||
|
||||
@@ -4,12 +4,18 @@
|
||||
}
|
||||
|
||||
.btn {
|
||||
min-height: 40px;
|
||||
min-height: var(--app-button-min-height, 40px);
|
||||
font-weight: 700;
|
||||
font-size: 15px;
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
@media (max-width: 767.98px) {
|
||||
.btn {
|
||||
font-size: 11px;
|
||||
}
|
||||
}
|
||||
|
||||
.btn-primary,
|
||||
.btn-secondary,
|
||||
.btn-danger {
|
||||
|
||||
@@ -9,6 +9,8 @@
|
||||
[src]="image"
|
||||
alt=""
|
||||
[loading]="set === 0 && $index < 5 ? 'eager' : 'lazy'"
|
||||
fetchpriority="low"
|
||||
decoding="async"
|
||||
/>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -14,20 +14,21 @@
|
||||
.continuous-carousel__track {
|
||||
display: flex;
|
||||
width: max-content;
|
||||
margin-left: var(--carousel-offset, 0px);
|
||||
animation: continuous-carousel-scroll var(--duration) linear infinite;
|
||||
}
|
||||
|
||||
.continuous-carousel__set {
|
||||
display: flex;
|
||||
flex: none;
|
||||
gap: var(--gap);
|
||||
padding-right: var(--gap);
|
||||
gap: var(--carousel-gap, var(--gap));
|
||||
padding-right: var(--carousel-gap, var(--gap));
|
||||
}
|
||||
|
||||
.continuous-carousel__image {
|
||||
display: block;
|
||||
flex: none;
|
||||
width: var(--card-width);
|
||||
width: var(--carousel-card-width, var(--card-width));
|
||||
aspect-ratio: 1.45;
|
||||
object-fit: cover;
|
||||
border-radius: 2px;
|
||||
@@ -64,6 +65,7 @@
|
||||
}
|
||||
.continuous-carousel__track {
|
||||
animation: none;
|
||||
margin-left: 0;
|
||||
}
|
||||
.continuous-carousel__set[aria-hidden='true'] {
|
||||
display: none;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
:host { display: block; margin-top: 9px; }
|
||||
.counter-to { min-height: 30px; padding-block: 12px; display: grid; grid-template-columns: repeat(4, 1fr); align-items: center; text-align: center; border: 1px solid #d7d9db; border-radius: 3px; }
|
||||
.counter-to { min-height: 30px; padding-block: 12px; display: grid; grid-template-columns: repeat(4, 1fr); align-items: center; text-align: center; border: 1px solid #a0a0a0; border-radius: 3px; }
|
||||
.counter-to > div + div { border-left: 1px solid #e6e7e8; }
|
||||
.counter-to strong { display: block; color: #666666; font-size: 16px; font-weight: 700; line-height: 1.1; }
|
||||
.counter-to small { display: block; margin-top: 1px; color: #666666; font-size: 11px; font-weight: 400; letter-spacing: .02em; }
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
<div
|
||||
class="carousel"
|
||||
role="group"
|
||||
[attr.aria-label]="ariaLabel()"
|
||||
[class.carousel--looping]="looping()"
|
||||
>
|
||||
@if (showArrows()) {
|
||||
<button
|
||||
type="button"
|
||||
class="carousel__arrow"
|
||||
aria-label="Ver elementos anteriores"
|
||||
[disabled]="!overflowing()"
|
||||
(click)="move(-1)"
|
||||
>
|
||||
<i class="fa-solid fa-chevron-left" aria-hidden="true"></i>
|
||||
</button>
|
||||
}
|
||||
<div #viewport class="carousel__viewport" (scroll)="onScroll()" (scrollend)="normalize()">
|
||||
<div class="carousel__track">
|
||||
@for (block of blocks(); track block) {
|
||||
@if (block === 0) {
|
||||
<div #canonical class="carousel__set">
|
||||
@for (item of items(); track item.value) {
|
||||
<button
|
||||
type="button"
|
||||
class="carousel__item"
|
||||
(click)="itemSelect.emit(item)"
|
||||
(focus)="reveal($event)"
|
||||
>
|
||||
{{ item.label }}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
} @else {
|
||||
<div class="carousel__set" aria-hidden="true">
|
||||
@for (item of items(); track item.value) {
|
||||
<button
|
||||
type="button"
|
||||
class="carousel__item"
|
||||
tabindex="-1"
|
||||
(mousedown)="$event.preventDefault()"
|
||||
(click)="selectCopy(item)"
|
||||
>
|
||||
{{ item.label }}
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
@if (showArrows()) {
|
||||
<button
|
||||
type="button"
|
||||
class="carousel__arrow"
|
||||
aria-label="Ver más elementos"
|
||||
[disabled]="!overflowing()"
|
||||
(click)="move(1)"
|
||||
>
|
||||
<i class="fa-solid fa-chevron-right" aria-hidden="true"></i>
|
||||
</button>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,71 @@
|
||||
:host {
|
||||
display: block;
|
||||
min-width: 0;
|
||||
}
|
||||
.carousel {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
min-width: 0;
|
||||
}
|
||||
.carousel__viewport {
|
||||
container-type: inline-size;
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
overflow-x: auto;
|
||||
scrollbar-width: none;
|
||||
overflow-anchor: none;
|
||||
scroll-snap-type: var(--horizontal-carousel-snap, none);
|
||||
}
|
||||
.carousel__viewport::-webkit-scrollbar {
|
||||
display: none;
|
||||
}
|
||||
.carousel__track {
|
||||
display: flex;
|
||||
width: max-content;
|
||||
min-width: 100%;
|
||||
justify-content: center;
|
||||
}
|
||||
.carousel__set {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex: none;
|
||||
align-items: center;
|
||||
gap: var(--horizontal-carousel-gap, 1.5rem);
|
||||
}
|
||||
.carousel--looping .carousel__set {
|
||||
padding-right: var(--horizontal-carousel-gap, 1.5rem);
|
||||
}
|
||||
.carousel__item,
|
||||
.carousel__arrow {
|
||||
flex: none;
|
||||
min-height: 44px;
|
||||
border: 0;
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
color: inherit;
|
||||
font: inherit;
|
||||
cursor: pointer;
|
||||
}
|
||||
.carousel__item {
|
||||
width: var(--horizontal-carousel-item-width, auto);
|
||||
white-space: var(--horizontal-carousel-white-space, nowrap);
|
||||
overflow-wrap: anywhere;
|
||||
scroll-snap-align: start;
|
||||
text-transform: var(--horizontal-carousel-text-transform, none);
|
||||
}
|
||||
.carousel__arrow {
|
||||
width: 32px;
|
||||
font-size: 10px;
|
||||
}
|
||||
.carousel__arrow:disabled {
|
||||
opacity: 0.35;
|
||||
cursor: default;
|
||||
}
|
||||
.carousel__item:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.carousel__item:focus-visible,
|
||||
.carousel__arrow:focus-visible {
|
||||
outline: 2px solid currentColor;
|
||||
outline-offset: -2px;
|
||||
}
|
||||
@@ -0,0 +1,180 @@
|
||||
import { ComponentFixture, TestBed } from '@angular/core/testing';
|
||||
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
||||
import { HorizontalCarouselComponent } from './horizontal-carousel.component';
|
||||
|
||||
describe('HorizontalCarouselComponent', () => {
|
||||
let fixture: ComponentFixture<HorizontalCarouselComponent>;
|
||||
let host: HTMLElement;
|
||||
let available: number;
|
||||
let resize: () => void;
|
||||
const disconnect = vi.fn();
|
||||
const items = Array.from({ length: 5 }, (_, index) => ({ value: index, label: `Item ${index}` }));
|
||||
const viewport = () => host.querySelector<HTMLElement>('.carousel__viewport')!;
|
||||
const period = () =>
|
||||
host.querySelector<HTMLElement>('.carousel__set')!.getBoundingClientRect().width;
|
||||
|
||||
beforeEach(async () => {
|
||||
available = 320;
|
||||
vi.stubGlobal(
|
||||
'ResizeObserver',
|
||||
class {
|
||||
constructor(callback: () => void) {
|
||||
resize = callback;
|
||||
}
|
||||
observe() {}
|
||||
disconnect = disconnect;
|
||||
},
|
||||
);
|
||||
vi.spyOn(HTMLElement.prototype, 'clientWidth', 'get').mockImplementation(function (
|
||||
this: HTMLElement,
|
||||
) {
|
||||
return this.classList.contains('carousel__viewport') ? available - 64 : available;
|
||||
});
|
||||
vi.spyOn(HTMLElement.prototype, 'getBoundingClientRect').mockImplementation(function (
|
||||
this: HTMLElement,
|
||||
) {
|
||||
const index = this.parentElement ? Array.from(this.parentElement.children).indexOf(this) : 0;
|
||||
const left = this.classList.contains('carousel__item') ? index * 124.25 : 0;
|
||||
const width = this.classList.contains('carousel__set')
|
||||
? Math.max(
|
||||
0,
|
||||
this.children.length * 124.25 - (this.closest('.carousel--looping') ? 0 : 24.25),
|
||||
)
|
||||
: 100;
|
||||
return {
|
||||
left,
|
||||
right: left + width,
|
||||
width,
|
||||
top: 0,
|
||||
bottom: 44,
|
||||
height: 44,
|
||||
x: left,
|
||||
y: 0,
|
||||
toJSON() {},
|
||||
};
|
||||
});
|
||||
vi.stubGlobal(
|
||||
'matchMedia',
|
||||
vi.fn(() => ({ matches: true })),
|
||||
);
|
||||
// jsdom has no layout or scrolling implementation.
|
||||
Object.defineProperty(HTMLElement.prototype, 'scrollTo', {
|
||||
configurable: true,
|
||||
value: vi.fn(function (this: HTMLElement, options: ScrollToOptions) {
|
||||
this.scrollLeft = options.left ?? 0;
|
||||
}),
|
||||
});
|
||||
Object.defineProperty(HTMLElement.prototype, 'scrollBy', {
|
||||
configurable: true,
|
||||
value: vi.fn(function (this: HTMLElement, options: ScrollToOptions) {
|
||||
this.scrollLeft += options.left ?? 0;
|
||||
}),
|
||||
});
|
||||
Object.defineProperty(HTMLElement.prototype, 'scrollIntoView', {
|
||||
configurable: true,
|
||||
value: vi.fn(),
|
||||
});
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [HorizontalCarouselComponent],
|
||||
}).compileComponents();
|
||||
fixture = TestBed.createComponent(HorizontalCarouselComponent);
|
||||
fixture.componentRef.setInput('items', items);
|
||||
fixture.componentRef.setInput('ariaLabel', 'Opciones');
|
||||
host = fixture.nativeElement;
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
fixture.destroy();
|
||||
vi.restoreAllMocks();
|
||||
vi.unstubAllGlobals();
|
||||
});
|
||||
|
||||
it('starts in the middle with only one accessible set', () => {
|
||||
expect(host.querySelectorAll('.carousel__set')).toHaveLength(3);
|
||||
expect(host.querySelectorAll('[aria-hidden="true"] .carousel__item')).toHaveLength(10);
|
||||
expect(host.querySelectorAll('.carousel__item:not([tabindex="-1"])')).toHaveLength(5);
|
||||
expect(viewport().scrollLeft).toBe(period());
|
||||
});
|
||||
|
||||
it('wraps both directions preserving the exact fractional offset', () => {
|
||||
const width = period();
|
||||
viewport().scrollLeft = width - 30.5;
|
||||
viewport().dispatchEvent(new Event('scrollend'));
|
||||
expect(viewport().scrollLeft).toBe(2 * width - 30.5);
|
||||
viewport().scrollLeft = 2 * width + 42.5;
|
||||
viewport().dispatchEvent(new Event('scrollend'));
|
||||
expect(viewport().scrollLeft).toBe(width + 42.5);
|
||||
});
|
||||
|
||||
it('uses the idle fallback after a gesture', () => {
|
||||
vi.useFakeTimers();
|
||||
viewport().scrollLeft = 12;
|
||||
viewport().dispatchEvent(new Event('scroll'));
|
||||
vi.advanceTimersByTime(180);
|
||||
expect(viewport().scrollLeft).toBe(period() + 12);
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it('arrows respect reduced motion', () => {
|
||||
host.querySelectorAll<HTMLButtonElement>('.carousel__arrow')[1].click();
|
||||
expect(viewport().scrollBy).toHaveBeenCalledWith({
|
||||
left: (available - 64) * 0.8,
|
||||
behavior: 'instant',
|
||||
});
|
||||
});
|
||||
|
||||
it('selects the original value when clicking a copy', () => {
|
||||
const selected = vi.fn();
|
||||
fixture.componentInstance.itemSelect.subscribe(selected);
|
||||
host.querySelector<HTMLButtonElement>('[aria-hidden="true"] .carousel__item')!.click();
|
||||
expect(selected).toHaveBeenCalledWith(items[0]);
|
||||
});
|
||||
|
||||
it('removes copies and arrows when resized to fit, then restores them', async () => {
|
||||
available = 1000;
|
||||
resize();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
expect(host.querySelectorAll('.carousel__set')).toHaveLength(1);
|
||||
expect(host.querySelectorAll('.carousel__arrow')).toHaveLength(0);
|
||||
available = 320;
|
||||
resize();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
expect(host.querySelectorAll('.carousel__set')).toHaveLength(3);
|
||||
expect(viewport().scrollLeft).toBe(period());
|
||||
});
|
||||
|
||||
it('keeps arrows with three visible slots and advances one item', async () => {
|
||||
host.style.setProperty('--horizontal-carousel-visible-items', '3');
|
||||
resize();
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
host.querySelectorAll<HTMLElement>('.carousel__set').forEach((set) => {
|
||||
set.style.columnGap = '8px';
|
||||
});
|
||||
host.querySelectorAll<HTMLButtonElement>('.carousel__arrow')[1].click();
|
||||
expect(viewport().scrollBy).toHaveBeenCalledWith({ left: 108, behavior: 'instant' });
|
||||
|
||||
fixture.componentRef.setInput('items', items.slice(0, 3));
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
expect(host.querySelectorAll('.carousel__set')).toHaveLength(1);
|
||||
expect(host.querySelectorAll('.carousel__arrow:disabled')).toHaveLength(2);
|
||||
});
|
||||
|
||||
it('supports noncircular overflow and empty lists', async () => {
|
||||
fixture.componentRef.setInput('circular', false);
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
expect(host.querySelectorAll('.carousel__set')).toHaveLength(1);
|
||||
expect(host.querySelectorAll('.carousel__arrow')).toHaveLength(2);
|
||||
fixture.componentRef.setInput('items', []);
|
||||
fixture.detectChanges();
|
||||
await fixture.whenStable();
|
||||
expect(host.querySelectorAll('.carousel__arrow')).toHaveLength(0);
|
||||
expect(host.querySelectorAll('.carousel__item')).toHaveLength(0);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,154 @@
|
||||
import {
|
||||
afterNextRender,
|
||||
afterRenderEffect,
|
||||
ChangeDetectionStrategy,
|
||||
Component,
|
||||
computed,
|
||||
DestroyRef,
|
||||
ElementRef,
|
||||
inject,
|
||||
input,
|
||||
output,
|
||||
signal,
|
||||
viewChild,
|
||||
} from '@angular/core';
|
||||
|
||||
export interface HorizontalCarouselItem {
|
||||
/** Unique within the carousel. */
|
||||
value: string | number;
|
||||
label: string;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'app-horizontal-carousel',
|
||||
templateUrl: './horizontal-carousel.component.html',
|
||||
styleUrl: './horizontal-carousel.component.scss',
|
||||
changeDetection: ChangeDetectionStrategy.OnPush,
|
||||
})
|
||||
export class HorizontalCarouselComponent {
|
||||
readonly items = input.required<readonly HorizontalCarouselItem[]>();
|
||||
readonly circular = input(true);
|
||||
readonly ariaLabel = input.required<string>();
|
||||
readonly itemSelect = output<HorizontalCarouselItem>();
|
||||
|
||||
protected readonly overflowing = signal(false);
|
||||
protected readonly visibleItems = signal<number | null>(null);
|
||||
protected readonly showArrows = computed(
|
||||
() => this.overflowing() || (this.visibleItems() !== null && this.items().length > 0),
|
||||
);
|
||||
protected readonly looping = computed(() => this.circular() && this.overflowing());
|
||||
protected readonly blocks = computed(() => (this.looping() ? [-1, 0, 1] : [0]));
|
||||
private readonly host = inject<ElementRef<HTMLElement>>(ElementRef);
|
||||
private readonly viewport = viewChild.required<ElementRef<HTMLElement>>('viewport');
|
||||
private readonly canonical = viewChild.required<ElementRef<HTMLElement>>('canonical');
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private settleTimer?: ReturnType<typeof setTimeout>;
|
||||
private observer?: ResizeObserver;
|
||||
private initializedLoop = false;
|
||||
private transferringFocus = false;
|
||||
private lastItems?: readonly HorizontalCarouselItem[];
|
||||
|
||||
constructor() {
|
||||
afterRenderEffect(() => {
|
||||
const items = this.items();
|
||||
const looping = this.looping();
|
||||
const set = this.canonical().nativeElement;
|
||||
this.measure();
|
||||
if (this.lastItems !== items || this.initializedLoop !== looping) {
|
||||
this.viewport().nativeElement.scrollLeft = looping ? set.getBoundingClientRect().width : 0;
|
||||
this.lastItems = items;
|
||||
this.initializedLoop = looping;
|
||||
}
|
||||
});
|
||||
afterNextRender(() => {
|
||||
this.observer = new ResizeObserver(() => {
|
||||
this.measure();
|
||||
this.normalize();
|
||||
});
|
||||
this.observer.observe(this.host.nativeElement);
|
||||
this.observer.observe(this.canonical().nativeElement);
|
||||
});
|
||||
this.destroyRef.onDestroy(() => {
|
||||
this.observer?.disconnect();
|
||||
clearTimeout(this.settleTimer);
|
||||
});
|
||||
}
|
||||
|
||||
private measure(): void {
|
||||
const slots = Number(
|
||||
this.host.nativeElement.ownerDocument.defaultView
|
||||
?.getComputedStyle(this.host.nativeElement)
|
||||
.getPropertyValue('--horizontal-carousel-visible-items'),
|
||||
);
|
||||
this.visibleItems.set(slots > 0 ? slots : null);
|
||||
if (slots > 0) {
|
||||
this.overflowing.set(this.items().length > slots);
|
||||
return;
|
||||
}
|
||||
const set = this.canonical().nativeElement;
|
||||
const children = set.children;
|
||||
const first = children.item(0) as HTMLElement | null;
|
||||
const last = children.item(children.length - 1) as HTMLElement | null;
|
||||
const width =
|
||||
first && last ? last.getBoundingClientRect().right - first.getBoundingClientRect().left : 0;
|
||||
const available = this.host.nativeElement.clientWidth;
|
||||
this.overflowing.set(available > 0 && width > available + 1);
|
||||
}
|
||||
|
||||
protected move(direction: number): void {
|
||||
const viewport = this.viewport().nativeElement;
|
||||
const set = this.canonical().nativeElement;
|
||||
const first = set.children.item(0) as HTMLElement | null;
|
||||
const gap =
|
||||
parseFloat(viewport.ownerDocument.defaultView?.getComputedStyle(set).columnGap ?? '0') || 0;
|
||||
const distance =
|
||||
this.visibleItems() && first
|
||||
? first.getBoundingClientRect().width + gap
|
||||
: viewport.clientWidth * 0.8;
|
||||
const reduceMotion = viewport.ownerDocument.defaultView?.matchMedia(
|
||||
'(prefers-reduced-motion: reduce)',
|
||||
).matches;
|
||||
viewport.scrollBy({
|
||||
left: direction * distance,
|
||||
behavior: reduceMotion ? 'instant' : 'smooth',
|
||||
});
|
||||
}
|
||||
|
||||
protected onScroll(): void {
|
||||
clearTimeout(this.settleTimer);
|
||||
// Fallback for browsers without scrollend; momentum keeps resetting the timer.
|
||||
this.settleTimer = setTimeout(() => this.normalize(), 180);
|
||||
}
|
||||
|
||||
protected normalize(): void {
|
||||
clearTimeout(this.settleTimer);
|
||||
if (!this.looping()) return;
|
||||
const viewport = this.viewport().nativeElement;
|
||||
const width = this.canonical().nativeElement.getBoundingClientRect().width;
|
||||
if (!width) return;
|
||||
const left = viewport.scrollLeft;
|
||||
if (left < width || left >= 2 * width) {
|
||||
viewport.scrollTo({ left: width + (((left % width) + width) % width), behavior: 'instant' });
|
||||
}
|
||||
}
|
||||
|
||||
protected reveal(event: FocusEvent): void {
|
||||
// Only the canonical buttons participate in keyboard / screen-reader navigation.
|
||||
if (this.transferringFocus) return;
|
||||
(event.target as HTMLElement).scrollIntoView({
|
||||
block: 'nearest',
|
||||
inline: 'nearest',
|
||||
behavior: 'instant',
|
||||
});
|
||||
}
|
||||
|
||||
protected selectCopy(item: HorizontalCarouselItem): void {
|
||||
const index = this.items().findIndex((candidate) => candidate.value === item.value);
|
||||
this.transferringFocus = true;
|
||||
(this.canonical().nativeElement.children.item(index) as HTMLElement | null)?.focus({
|
||||
preventScroll: true,
|
||||
});
|
||||
this.transferringFocus = false;
|
||||
this.itemSelect.emit(item);
|
||||
}
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
} from '@angular/core';
|
||||
import type { LayerGroup, Map as LeafletMap, LatLngBounds, LatLngTuple, TileLayer } from 'leaflet';
|
||||
|
||||
export type MapStyle = 'minimal-light' | 'standard';
|
||||
export type MapStyle = 'standard';
|
||||
|
||||
const MAP_LAYERS: Record<
|
||||
MapStyle,
|
||||
@@ -23,12 +23,6 @@ const MAP_LAYERS: Record<
|
||||
maxZoom: number;
|
||||
}
|
||||
> = {
|
||||
'minimal-light': {
|
||||
url: 'https://{s}.basemaps.cartocdn.com/light_all/{z}/{x}/{y}{r}.png',
|
||||
attribution:
|
||||
'© <a href="https://www.openstreetmap.org/copyright">OpenStreetMap</a> contributors © <a href="https://carto.com/attributions">CARTO</a>',
|
||||
maxZoom: 20,
|
||||
},
|
||||
standard: {
|
||||
url: 'https://tile.openstreetmap.org/{z}/{x}/{y}.png',
|
||||
attribution:
|
||||
@@ -56,7 +50,7 @@ export class LocationMapComponent implements AfterViewInit, OnChanges, OnDestroy
|
||||
@Input() fallbackCenter: LatLngTuple = [-32.94682, -60.63932];
|
||||
@Input() fallbackZoom = 13;
|
||||
@Input() maxFitZoom = 15;
|
||||
@Input() mapStyle: MapStyle = 'minimal-light';
|
||||
@Input() mapStyle: MapStyle = 'standard';
|
||||
@Input() markerColor = '#24a9e0';
|
||||
|
||||
@ViewChild('mapContainer', { static: true })
|
||||
|
||||
@@ -12,18 +12,21 @@
|
||||
>
|
||||
<div class="main-carousel__viewport" aria-live="off">
|
||||
@for (image of images(); track $index; let index = $index) {
|
||||
<img
|
||||
class="main-carousel__image"
|
||||
[class.main-carousel__image--active]="index === activeIndex()"
|
||||
[attr.src]="imageSource(image, index)"
|
||||
[alt]="imageAlt(index)"
|
||||
[attr.aria-hidden]="index === activeIndex() ? null : 'true'"
|
||||
loading="eager"
|
||||
[attr.fetchpriority]="index === activeIndex() ? 'high' : 'low'"
|
||||
draggable="false"
|
||||
(load)="handleImageLoad(index)"
|
||||
(error)="handleImageError(index)"
|
||||
/>
|
||||
<picture>
|
||||
<source media="(max-width: 576px)" [attr.srcset]="mobileImageSource(image, index)" />
|
||||
<img
|
||||
class="main-carousel__image"
|
||||
[class.main-carousel__image--active]="index === activeIndex()"
|
||||
[attr.src]="imageSource(image, index)"
|
||||
[alt]="imageAlt(index)"
|
||||
[attr.aria-hidden]="index === activeIndex() ? null : 'true'"
|
||||
loading="eager"
|
||||
[attr.fetchpriority]="index === activeIndex() ? 'high' : 'low'"
|
||||
draggable="false"
|
||||
(load)="handleImageLoad(index)"
|
||||
(error)="handleImageError(index)"
|
||||
/>
|
||||
</picture>
|
||||
}
|
||||
</div>
|
||||
|
||||
|
||||
@@ -17,9 +17,7 @@
|
||||
&__viewport {
|
||||
position: relative;
|
||||
width: 100%;
|
||||
aspect-ratio: 4 / 1;
|
||||
min-height: 9rem;
|
||||
max-height: 25rem;
|
||||
aspect-ratio: 355 / 90;
|
||||
}
|
||||
|
||||
&__image {
|
||||
|
||||
@@ -18,12 +18,20 @@ class TestHostComponent {
|
||||
readonly images = ['/images/one.webp', '/images/two.webp', '/images/three.webp'];
|
||||
}
|
||||
|
||||
@Component({
|
||||
imports: [MainCarouselComponent],
|
||||
template: `<app-main-carousel [images]="images" />`,
|
||||
})
|
||||
class ResponsiveTestHostComponent {
|
||||
readonly images = [{ desktop: '/images/desktop.webp', mobile: '/images/mobile.webp' }];
|
||||
}
|
||||
|
||||
describe('MainCarouselComponent', () => {
|
||||
let fixture: ComponentFixture<TestHostComponent>;
|
||||
|
||||
beforeEach(async () => {
|
||||
await TestBed.configureTestingModule({
|
||||
imports: [TestHostComponent],
|
||||
imports: [TestHostComponent, ResponsiveTestHostComponent],
|
||||
}).compileComponents();
|
||||
|
||||
fixture = TestBed.createComponent(TestHostComponent);
|
||||
@@ -41,6 +49,19 @@ describe('MainCarouselComponent', () => {
|
||||
expect(images[0].classList).toContain('main-carousel__image--active');
|
||||
});
|
||||
|
||||
it('usa la variante móvil del crop cuando está disponible', () => {
|
||||
const responsiveFixture = TestBed.createComponent(ResponsiveTestHostComponent);
|
||||
responsiveFixture.detectChanges();
|
||||
|
||||
const picture = responsiveFixture.nativeElement.querySelector('picture') as HTMLPictureElement;
|
||||
const source = picture.querySelector('source') as HTMLSourceElement;
|
||||
const image = picture.querySelector('img') as HTMLImageElement;
|
||||
|
||||
expect(source.getAttribute('media')).toBe('(max-width: 576px)');
|
||||
expect(source.getAttribute('srcset')).toBe('/images/mobile.webp');
|
||||
expect(image.getAttribute('src')).toBe('/images/desktop.webp');
|
||||
});
|
||||
|
||||
it('carga las imágenes secuencialmente y prioriza la imagen visible', () => {
|
||||
const images = fixture.nativeElement.querySelectorAll(
|
||||
'.main-carousel__image',
|
||||
|
||||
@@ -11,6 +11,9 @@ import {
|
||||
signal,
|
||||
} from '@angular/core';
|
||||
import { isPlatformBrowser } from '@angular/common';
|
||||
import type { WebsiteExtras } from '../../../core/services/tenant.interface';
|
||||
|
||||
type CarouselImage = NonNullable<WebsiteExtras['carousel']>[number];
|
||||
|
||||
@Component({
|
||||
selector: 'app-main-carousel',
|
||||
@@ -26,7 +29,7 @@ export class MainCarouselComponent {
|
||||
private readonly settledIndexes = signal<ReadonlySet<number>>(new Set());
|
||||
private firstImageReadyEmitted = false;
|
||||
|
||||
readonly images = input.required<readonly string[]>();
|
||||
readonly images = input.required<readonly CarouselImage[]>();
|
||||
readonly imageAlts = input<readonly string[]>([]);
|
||||
readonly autoSlideInterval = input(5000);
|
||||
readonly ariaLabel = input('Imágenes destacadas');
|
||||
@@ -91,13 +94,21 @@ export class MainCarouselComponent {
|
||||
this.paused.set(paused);
|
||||
}
|
||||
|
||||
protected imageSource(image: string, index: number): string | null {
|
||||
protected imageSource(image: CarouselImage, index: number): string | null {
|
||||
const shouldLoad =
|
||||
this.loadedIndexes().has(index) ||
|
||||
index === this.sequentialLoadIndex() ||
|
||||
index === this.activeIndex();
|
||||
|
||||
return shouldLoad ? image : null;
|
||||
return shouldLoad ? (typeof image === 'string' ? image : image.desktop) : null;
|
||||
}
|
||||
|
||||
protected mobileImageSource(image: CarouselImage, index: number): string | null {
|
||||
if (typeof image === 'string' || this.imageSource(image, index) === null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return image.mobile;
|
||||
}
|
||||
|
||||
protected handleImageLoad(index: number): void {
|
||||
|
||||
@@ -4,16 +4,16 @@
|
||||
|
||||
.quantity-selector {
|
||||
border: 1px solid var(--border-color);
|
||||
width: 78px;
|
||||
height: 40px;
|
||||
min-height: 40px;
|
||||
width: var(--quantity-selector-width, 78px);
|
||||
height: var(--quantity-selector-height, 40px);
|
||||
min-height: var(--quantity-selector-height, 40px);
|
||||
background-color: #ffffff;
|
||||
box-sizing: border-box;
|
||||
|
||||
&__button {
|
||||
width: 24px;
|
||||
width: var(--quantity-selector-button-width, 24px);
|
||||
height: 100%;
|
||||
font-size: 20px;
|
||||
font-size: var(--quantity-selector-button-font-size, 20px);
|
||||
color: #6f6f6f;
|
||||
background-color: #ffffff;
|
||||
transition:
|
||||
@@ -34,7 +34,7 @@
|
||||
}
|
||||
|
||||
&__value {
|
||||
font-size: 16px;
|
||||
font-size: var(--quantity-selector-value-font-size, 16px);
|
||||
color: #6f6f6f;
|
||||
}
|
||||
|
||||
|
||||
@@ -11,6 +11,11 @@
|
||||
line-height: 1.5;
|
||||
}
|
||||
|
||||
h2.simple-modal__content {
|
||||
font-size: 15px;
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
.simple-modal__actions {
|
||||
display: flex;
|
||||
justify-content: center;
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
z-index: 1500;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 0.5rem;
|
||||
gap: 0.25rem;
|
||||
pointer-events: none;
|
||||
width: 90vw;
|
||||
max-width: 800px;
|
||||
|
||||
Reference in New Issue
Block a user