Delete old verification component
This commit is contained in:
parent
277ef55615
commit
b91f8a1ab5
|
@ -1,71 +0,0 @@
|
||||||
import {Component, Input, OnInit} from "@angular/core";
|
|
||||||
import {FormBuilder, FormControl, Validators} from "@angular/forms";
|
|
||||||
import {UserRegistryService} from "../services/user-registry.service";
|
|
||||||
|
|
||||||
@Component({
|
|
||||||
selector: 'verification',
|
|
||||||
template: `
|
|
||||||
<div *ngIf="loading" class="loading-gif"></div>
|
|
||||||
<div *ngIf="name && !loading" class="uk-text-center uk-text-large">
|
|
||||||
<ng-container *ngIf="state === 'default'">
|
|
||||||
<div>
|
|
||||||
You have been invited to join <span class="uk-text-bold">{{name}}</span> as Manager;<br>
|
|
||||||
Fill in the verification code, sent to your email, to accept the invitation request.
|
|
||||||
</div>
|
|
||||||
<div class="uk-margin-medium-top">
|
|
||||||
<input [formControl]="code" class="uk-input uk-width-small" [class.uk-form-danger]="code.invalid">
|
|
||||||
</div>
|
|
||||||
<div class="uk-margin-medium-top">
|
|
||||||
<button class="uk-button" [class.portal-button]="code.valid" [class.uk-disabled]="code.invalid"
|
|
||||||
(click)="verify()">Accept
|
|
||||||
</button>
|
|
||||||
<button class="uk-button uk-button-danger uk-margin-medium-left" (click)="reject()">Reject</button>
|
|
||||||
</div>
|
|
||||||
</ng-container>
|
|
||||||
<ng-container *ngIf="state === 'verified'">
|
|
||||||
<div>
|
|
||||||
You are now manager of {{name}}.
|
|
||||||
</div>
|
|
||||||
</ng-container>
|
|
||||||
<ng-container *ngIf="state === 'refused'">
|
|
||||||
<div>
|
|
||||||
You have been refused to be manager of {{name}}.
|
|
||||||
</div>
|
|
||||||
</ng-container>
|
|
||||||
</div>
|
|
||||||
`
|
|
||||||
})
|
|
||||||
export class VerificationComponent implements OnInit {
|
|
||||||
|
|
||||||
@Input()
|
|
||||||
public name: string;
|
|
||||||
@Input()
|
|
||||||
public invitation;
|
|
||||||
public code: FormControl;
|
|
||||||
public loading = false;
|
|
||||||
public state: 'default' | 'verified' | 'refused' | 'error' = 'default';
|
|
||||||
|
|
||||||
constructor(private fb: FormBuilder,
|
|
||||||
private userRegistryService: UserRegistryService) {
|
|
||||||
}
|
|
||||||
|
|
||||||
ngOnInit() {
|
|
||||||
this.code = this.fb.control('', [Validators.required, Validators.pattern('^[+0-9]{6}$')]);
|
|
||||||
}
|
|
||||||
|
|
||||||
verify() {
|
|
||||||
this.loading = true;
|
|
||||||
this.userRegistryService.verify(this.invitation.id, this.code.value).subscribe(() => {
|
|
||||||
this.state = 'verified';
|
|
||||||
this.loading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
reject() {
|
|
||||||
this.loading = true;
|
|
||||||
this.userRegistryService.deleteVerification(this.invitation.id).subscribe(() => {
|
|
||||||
this.state = 'refused';
|
|
||||||
this.loading = false;
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -1,11 +0,0 @@
|
||||||
import {NgModule} from "@angular/core";
|
|
||||||
import {CommonModule} from "@angular/common";
|
|
||||||
import {VerificationComponent} from "./verification.component";
|
|
||||||
import {ReactiveFormsModule} from "@angular/forms";
|
|
||||||
|
|
||||||
@NgModule({
|
|
||||||
imports: [CommonModule, ReactiveFormsModule],
|
|
||||||
declarations: [VerificationComponent],
|
|
||||||
exports: [VerificationComponent]
|
|
||||||
})
|
|
||||||
export class VerificationModule {}
|
|
Loading…
Reference in New Issue