From 02f1d95b52e41c82c08b151647c8f7dab2e7ce8f Mon Sep 17 00:00:00 2001 From: Ben Goldsworthy Date: Sun, 1 Nov 2020 18:05:03 +0000 Subject: [PATCH] Clear up Feedback component --- src/app/dashboard/feedback.component.html | 2 +- src/app/dashboard/feedback.component.ts | 23 +++++++++-------------- 2 files changed, 10 insertions(+), 15 deletions(-) diff --git a/src/app/dashboard/feedback.component.html b/src/app/dashboard/feedback.component.html index 431a548..c2efc97 100644 --- a/src/app/dashboard/feedback.component.html +++ b/src/app/dashboard/feedback.component.html @@ -11,7 +11,7 @@
- + Enter your email here if it doesn't show.
diff --git a/src/app/dashboard/feedback.component.ts b/src/app/dashboard/feedback.component.ts index 2811183..8532455 100644 --- a/src/app/dashboard/feedback.component.ts +++ b/src/app/dashboard/feedback.component.ts @@ -1,11 +1,11 @@ import { Component, OnInit } from '@angular/core'; -import { Validators, FormBuilder, FormGroup } from '@angular/forms'; +import { FormControl, FormGroup, Validators } from '@angular/forms'; import { ApiService } from '../providers/api-service'; - @Component({ templateUrl: 'feedback.component.html', }) + export class FeedbackComponent implements OnInit { feedbackForm: FormGroup; loggedInEmail: string; @@ -14,23 +14,19 @@ export class FeedbackComponent implements OnInit { feedbackFormStatus: any; feedbackFormStatusError = 'Error received, please try again.'; - constructor( - private formBuilder: FormBuilder, - private api: ApiService, - ) { - this.feedbackForm = this.formBuilder.group({ - email: ['', [Validators.required]], - feedbacktext: ['', [Validators.required]], + constructor(private api: ApiService) { + this.feedbackForm = new FormGroup({ + email: new FormControl({value: this.loggedInEmail, disabled: this.noEmail}, Validators.required), + feedbacktext: new FormControl('', Validators.required), }); } ngOnInit(): void { - if (localStorage.getItem('email')) { this.loggedInEmail = localStorage.getItem('email'); } - console.log('loggedInEmail: ' + this.loggedInEmail); - if (this.loggedInEmail) { + + if (!this.loggedInEmail) { console.log('email not found in storage'); this.api.accountFullLoad().subscribe( result => { @@ -48,7 +44,7 @@ export class FeedbackComponent implements OnInit { } } - onSubmit() { + onSubmit(): void { this.api .feedback(this.feedbackForm.value) .subscribe( @@ -76,5 +72,4 @@ export class FeedbackComponent implements OnInit { } ); } - }