feat(event): refactor event retrieval to use slug instead of id
This commit is contained in:
@@ -2,6 +2,7 @@ import { ApiPaginatedResponse } from '../api-paginated-response.interface';
|
|||||||
|
|
||||||
export interface StoreEvent {
|
export interface StoreEvent {
|
||||||
id: number;
|
id: number;
|
||||||
|
slug: string;
|
||||||
event_category_id: number | null;
|
event_category_id: number | null;
|
||||||
title: string;
|
title: string;
|
||||||
subtitle: string | null;
|
subtitle: 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>>(
|
return this.http.get<ApiResponse<StoreEvent>>(
|
||||||
`${this.tenantService.getTenantApiUrl()}/events/${id}`,
|
`${this.tenantService.getTenantApiUrl()}/events/${slug}`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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">
|
<div class="event-card__image">
|
||||||
@if (event().image) {
|
@if (event().image) {
|
||||||
<img [src]="event().image" [alt]="event().title" />
|
<img [src]="event().image" [alt]="event().title" />
|
||||||
|
|||||||
@@ -62,9 +62,9 @@ export class EventDetailPageComponent {
|
|||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this.route.paramMap.pipe(
|
this.route.paramMap.pipe(
|
||||||
map((params) => Number(params.get('id'))),
|
map((params) => params.get('slug')?.trim() ?? ''),
|
||||||
switchMap((id) => Number.isInteger(id) && id > 0
|
switchMap((slug) => slug
|
||||||
? this.events.get(id).pipe(map((response) => response.data), catchError(() => of(null)))
|
? this.events.get(slug).pipe(map((response) => response.data), catchError(() => of(null)))
|
||||||
: of(null)),
|
: of(null)),
|
||||||
takeUntilDestroyed(this.destroyRef),
|
takeUntilDestroyed(this.destroyRef),
|
||||||
).subscribe((event) => {
|
).subscribe((event) => {
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ export const routes: Routes = [
|
|||||||
import('./pages/search-page/search-page.component').then((m) => m.SearchPageComponent),
|
import('./pages/search-page/search-page.component').then((m) => m.SearchPageComponent),
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'evento/:id',
|
path: 'evento/:slug',
|
||||||
canMatch: [isMultiEventStorefront],
|
canMatch: [isMultiEventStorefront],
|
||||||
canActivate: [hasMenuGuard('event.detail')],
|
canActivate: [hasMenuGuard('event.detail')],
|
||||||
loadComponent: () =>
|
loadComponent: () =>
|
||||||
|
|||||||
Reference in New Issue
Block a user