Skip to content
This repository has been archived by the owner on Dec 9, 2022. It is now read-only.

Commit

Permalink
Add page for account activation (#235)
Browse files Browse the repository at this point in the history
* Add activation page

* Center result message

* Remove unused imports
  • Loading branch information
marcauberer authored Apr 29, 2021
1 parent 46176e5 commit e707815
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/app/app-routing.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ const routes: Routes = [
{ path: 'login', loadChildren: () => import('./pages/login/login.module').then(m => m.LoginModule) },
{ path: 'signup', loadChildren: () => import('./pages/sign-up/sign-up.module').then(m => m.SignUpModule) },
{ path: 'p/:slug', loadChildren: () => import('./pages/poll-participants/poll-participants.module').then(m => m.PollParticipantsModule) },
{ path: 'activate/:token', loadChildren: () => import('./pages/activation/activation.module').then(m => m.ActivationModule) },
{ path: 'dashboard', component: DashboardComponent,
children: [
{ path: '', pathMatch: 'full', redirectTo: '/dashboard/home' },
Expand Down
17 changes: 17 additions & 0 deletions src/app/pages/activation/activation-routing.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
* Copyright © Live-Poll 2020-2021. All rights reserved
*/

import {NgModule} from '@angular/core';
import {RouterModule, Routes} from '@angular/router';
import {ActivationComponent} from './activation.component';

const routes: Routes = [
{ path: '', component: ActivationComponent },
];

@NgModule({
imports: [RouterModule.forChild(routes)],
exports: [RouterModule]
})
export class ActivationRoutingModule { }
32 changes: 32 additions & 0 deletions src/app/pages/activation/activation.component.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<!--
~ Copyright © Live-Poll 2020-2021. All rights reserved
-->

<div class="page">
<!-- Spinner -->
<nz-spin *ngIf="loading" nzSimple nzSize="large" class="spinner"></nz-spin>

<!-- Success message -->
<nz-result
*ngIf="!loading && success"
nzStatus="success"
nzTitle="Successfully activated your account!"
nzSubTitle="You can now continue by logging in to your account. To log in, click below.">
<div nz-result-extra>
<button nz-button nzType="primary" routerLink="/login">Continue to login</button>
<button nz-button routerLink="/">Go to main page</button>
</div>
</nz-result>

<!-- Error message -->
<nz-result
*ngIf="!loading && !success"
nzStatus="error"
nzTitle="An error occurred while activating your account!"
nzSubTitle="Maybe you're using an expired link or you changed it somehow.">
<div nz-result-extra>
<button nz-button nzType="primary" routerLink="/signup">Retry registration</button>
<button nz-button routerLink="/login">Go to main page</button>
</div>
</nz-result>
</div>
10 changes: 10 additions & 0 deletions src/app/pages/activation/activation.component.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*!
/ Copyright © Live-Poll 2020-2021. All rights reserved
/
.page
display: flex
height: 100vh
align-items: center
justify-content: center

42 changes: 42 additions & 0 deletions src/app/pages/activation/activation.component.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
* Copyright © Live-Poll 2020-2021. All rights reserved
*/

import {Component, EventEmitter, OnInit} from '@angular/core';
import {Poll} from '../../model/poll';
import {User} from '../../model/user';
import {ActivatedRoute} from '@angular/router';
import {AccountService} from '../../service/account.service';

@Component({
selector: 'app-home',
templateUrl: './activation.component.html',
styleUrls: ['./activation.component.sass']
})
export class ActivationComponent implements OnInit {

loading = true;
success = true;

/**
* Initialize component
*
* @param route Active route
* @param accountService Injected AccountService
*/
constructor(
private route: ActivatedRoute,
private accountService: AccountService
) {}

ngOnInit(): void {
this.route.params.subscribe(params => {
this.accountService.confirm(params.token).subscribe((_) => {
this.loading = false;
}, (_) => {
this.success = true;
this.loading = false;
});
});
}
}
29 changes: 29 additions & 0 deletions src/app/pages/activation/activation.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright © Live-Poll 2020-2021. All rights reserved
*/

import {NgModule} from '@angular/core';
import {ActivationRoutingModule} from './activation-routing.module';
import {ActivationComponent} from './activation.component';
import {NzButtonModule} from 'ng-zorro-antd/button';
import {NzEmptyModule} from 'ng-zorro-antd/empty';
import {NzBreadCrumbModule} from 'ng-zorro-antd/breadcrumb';
import {NzLayoutModule} from 'ng-zorro-antd/layout';
import {NzIconModule} from 'ng-zorro-antd/icon';
import {CommonModule} from '@angular/common';
import {ResultEmptyModule} from '../../components/result-empty/result-empty.module';
import {NzResultModule} from 'ng-zorro-antd/result';
import {NzSpinModule} from 'ng-zorro-antd/spin';

@NgModule({
imports: [
ActivationRoutingModule,
NzResultModule,
NzSpinModule,
CommonModule,
NzButtonModule
],
declarations: [ActivationComponent],
exports: [ActivationComponent]
})
export class ActivationModule { }

0 comments on commit e707815

Please sign in to comment.