Skip to content

Commit

Permalink
feat: redirect users correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
gion-andri committed Aug 18, 2023
1 parent bc032fe commit b51514f
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ const routes: Routes = [
{
path: 'admin',
children: [
{path: 'events/new', component: NewEventComponent, canActivate: [authGuard()]},
{path: 'events/new', component: NewEventComponent},
{path: 'events', component: MyEventsComponent, canActivate: [authGuard()]},
{path: 'subscriptions', component: MySubscriptionsComponent, canActivate: [authGuard()]},
{path: 'profile', component: ProfileComponent, canActivate: [authGuard()]},
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/admin/new-event/new-event.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<h1>Registrar in’occurrenza</h1>

<form [formGroup]="f">
<div class="mb-3">
<div class="mb-3" *ngIf="f.controls['contactEmail'].enabled">
<label for="contactEmail" class="form-label">adressa dad e-mail (betg public, mo per diever
administrativ)</label>
<input formControlName="contactEmail" type="email" class="form-control" id="contactEmail"
Expand Down
12 changes: 5 additions & 7 deletions src/app/pages/admin/new-event/new-event.component.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import {Component, OnInit} from '@angular/core';
import {
FormArray,
FormBuilder,
FormControl,
FormGroup,
Validators
} from "@angular/forms";
import {FormArray, FormBuilder, FormControl, FormGroup, Validators} from "@angular/forms";
import {AuthenticationService} from "../../../services/authentication.service";
import {StaticDataService} from "../../../services/static-data.service";
import {EventLanguage, Genre, Region} from "../../../data/static-data";
Expand Down Expand Up @@ -139,6 +133,10 @@ export class NewEventComponent implements OnInit {
});
this.addOccurrence();

if (isLoggedIn) {
this.f.get('contactEmail')!.disable();
}

this.f.get('onlineOnly')!.valueChanges.subscribe(val => {
if (val) {
this.f.get('location')!.disable();
Expand Down
2 changes: 1 addition & 1 deletion src/app/pages/u/events/events.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ <h2>Cuntinuar senza s’annunziar</h2>
</p>

<div>
<button type="button" class="clndr accent">Endatar senza s’annunziar</button>
<button type="button" class="clndr accent" (click)="createEvent()">Endatar senza s’annunziar</button>
</div>
</div>
</div>
Expand Down
6 changes: 5 additions & 1 deletion src/app/pages/u/events/events.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ export class EventsComponent {
}

login(): void {
this.router.navigate(['/u/login']);
this.router.navigate(['/u/login'], {queryParams: {redirectTo: '/admin/events/new'}});
}

createEvent(): void {
this.router.navigate(['/admin/events/new']);
}
}

0 comments on commit b51514f

Please sign in to comment.