|
|
@@ -2,9 +2,8 @@ import { Component, Input } from '@angular/core';
|
|
|
import { EventsApiService } from 'src/app/events-api.service';
|
|
|
import { GroupEvent } from '../group-event';
|
|
|
import { RegistrationState, RegistrationStateItems } from '../registration-state';
|
|
|
-import { Registration } from '../registration';
|
|
|
-import { AuthService } from '@auth0/auth0-angular';
|
|
|
import { combineLatest, take } from 'rxjs';
|
|
|
+import { PermissionService } from 'src/app/users/permission.service';
|
|
|
|
|
|
interface RegistrationModel {
|
|
|
readonly name: string;
|
|
|
@@ -30,7 +29,7 @@ export class EventViewComponent {
|
|
|
public currentState = RegistrationState.Unknown;
|
|
|
|
|
|
public constructor(
|
|
|
- private readonly authService: AuthService,
|
|
|
+ private readonly permissionService: PermissionService,
|
|
|
private readonly eventsApi: EventsApiService
|
|
|
) { }
|
|
|
|
|
|
@@ -38,10 +37,10 @@ export class EventViewComponent {
|
|
|
this.eventsApi.getEvent(this.eventId).then(event => {
|
|
|
this.event = event;
|
|
|
});
|
|
|
- combineLatest([this.authService.user$, this.eventsApi.getRegistrations(this.eventId)])
|
|
|
+ combineLatest([this.permissionService.userProfile, this.eventsApi.getRegistrations(this.eventId)])
|
|
|
.pipe(take(1))
|
|
|
- .subscribe(([user, registrations]) => {
|
|
|
- const currentRegistrationIndex = registrations.findIndex(r => r.owner?.userId === user?.sub);
|
|
|
+ .subscribe(([userProfile, registrations]) => {
|
|
|
+ const currentRegistrationIndex = registrations.findIndex(r => r.owner?.userId === userProfile?.userId);
|
|
|
|
|
|
this.currentState = (currentRegistrationIndex >= 0 ? registrations.splice(currentRegistrationIndex, 1)[0] : null)?.status ?? RegistrationState.Unknown;
|
|
|
this.registrations = registrations
|