Made it load email on feedback form load
This commit is contained in:
parent
68cef62bde
commit
0aa6340454
5 changed files with 30 additions and 9 deletions
|
@ -34,6 +34,7 @@ export class LoginComponent implements OnInit {
|
|||
.subscribe(
|
||||
result => {
|
||||
console.log('Logged out!');
|
||||
localStorage.clear();
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
<div class="form-group row">
|
||||
<label class="col-md-3 form-control-label" for="text-input"><strong>Email</strong></label>
|
||||
<div class="col-md-9">
|
||||
<input type="text" class="form-control" formControlName="email" [(ngModel)]="loggedInEmail" [disabled]="noEmail">
|
||||
<span class="help-block">Your email will load here.</span>
|
||||
<input type="text" class="form-control" name="email" formControlName="email" placeholder="Enter Account Email Here" [(ngModel)]="loggedInEmail" [disabled]="noEmail">
|
||||
<span class="help-block">Enter your email here if it doesn't show.</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group row">
|
||||
|
|
|
@ -10,7 +10,7 @@ import 'rxjs/add/operator/map';
|
|||
})
|
||||
export class FeedbackComponent {
|
||||
feedbackForm: FormGroup;
|
||||
loggedInEmail: any;
|
||||
loggedInEmail: string;
|
||||
noEmail: boolean = false;
|
||||
username: any;
|
||||
feedbackFormStatus: any;
|
||||
|
@ -21,17 +21,36 @@ export class FeedbackComponent {
|
|||
private formBuilder: FormBuilder,
|
||||
private api: ApiService,
|
||||
) {
|
||||
this.loggedInEmail = localStorage.getItem('email');
|
||||
if (this.loggedInEmail == null) {
|
||||
this.noEmail = true;
|
||||
}
|
||||
|
||||
this.feedbackForm = this.formBuilder.group({
|
||||
email: ['', [Validators.required]],
|
||||
feedbacktext: ['', [Validators.required]],
|
||||
});
|
||||
}
|
||||
|
||||
ngOnInit(): void {
|
||||
|
||||
if(localStorage.getItem('email')) {
|
||||
this.loggedInEmail = localStorage.getItem('email');
|
||||
}
|
||||
console.log('loggedInEmail: ' + this.loggedInEmail);
|
||||
if (this.loggedInEmail) {
|
||||
console.log('email not found in storage');
|
||||
this.api.accountFullLoad().subscribe(
|
||||
result => {
|
||||
console.log(result);
|
||||
this.feedbackForm.patchValue({
|
||||
email: result.email,
|
||||
});
|
||||
this.api.setUserInfo( result.email, result.display_name );
|
||||
},
|
||||
error => {
|
||||
console.log( error._body );
|
||||
this.noEmail = true;
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
this.api
|
||||
.feedback(this.feedbackForm.value)
|
||||
|
|
|
@ -40,6 +40,7 @@ export class FullLayoutComponent implements OnInit {
|
|||
.subscribe(
|
||||
result => {
|
||||
console.log('Logged out!');
|
||||
localStorage.clear();
|
||||
this.router.navigate(['/login']);
|
||||
}
|
||||
);
|
||||
|
|
Reference in a new issue