feat(event): refactor event retrieval to use slug instead of id
This commit is contained in:
@@ -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" />
|
||||
|
||||
@@ -62,9 +62,9 @@ export class EventDetailPageComponent {
|
||||
|
||||
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) => {
|
||||
|
||||
@@ -98,7 +98,7 @@ 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: () =>
|
||||
|
||||
Reference in New Issue
Block a user