diff --git a/src/app/auth/login/login.page.ts b/src/app/auth/login/login.page.ts index 6a48bb33110874f73721988484fa5de3c8d2f8fd..1f73808ff44a633f24c4c119ea04653cfe948cd9 100644 --- a/src/app/auth/login/login.page.ts +++ b/src/app/auth/login/login.page.ts @@ -38,7 +38,7 @@ export class LoginPage implements OnInit { } loginApiCall() { - this.loginApi = this.httpClient.post('http://193.196.52.237:8081/login', { + this.loginApi = this.httpClient.post('http://193.196.52.237:8081/authenticate', { "email": this.username, "password": this.password }); diff --git a/src/app/feedback/feedback.module.ts b/src/app/feedback/feedback.module.ts index a9a436ae7a451a2b1f2593d5fb640362d2efdcd4..e31e3e56f5923e8273a816e167067170fee3a600 100644 --- a/src/app/feedback/feedback.module.ts +++ b/src/app/feedback/feedback.module.ts @@ -1,6 +1,6 @@ import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; -import { FormsModule } from '@angular/forms'; +import { FormsModule, ReactiveFormsModule } from '@angular/forms'; import { IonicModule } from '@ionic/angular'; @@ -13,6 +13,7 @@ import { FeedbackPage } from './feedback.page'; CommonModule, FormsModule, IonicModule, + ReactiveFormsModule, FeedbackPageRoutingModule ], declarations: [FeedbackPage] diff --git a/src/app/feedback/feedback.page.html b/src/app/feedback/feedback.page.html index 206a8fc40e770038a3d9f6206c643d3fa1037f29..82583d40bf8d44d5fddc4a5d90db29919fc5d405 100644 --- a/src/app/feedback/feedback.page.html +++ b/src/app/feedback/feedback.page.html @@ -6,13 +6,12 @@ <ion-title slot="start"> Feedback </ion-title> - </ion-toolbar> </ion-header> <ion-content> - <!--form [formGroup]="angForm" novalidate--><div> + <form [formGroup]="angForm" novalidate> <ion-grid> <ion-row justify-content-center> <ion-col align-self-center size-md="6" size-lg="5" size-xs="12"> @@ -23,27 +22,23 @@ <h3>Feedback</h3> </div> - <div > + <ion-item > - <ion-textarea class="ion-text-content" [(ngModel)]="content" placeholder="Enter Feedback"></ion-textarea> - </ion-item> + + <ion-textarea class="ion-text-content" formControlName="feedback" placeholder="Enter Feedback"></ion-textarea> + </ion-item> + <div + *ngIf="angForm.controls['feedback'].invalid && (angForm.controls['feedback'].dirty || angForm.controls['feedback'].touched)" + class="alert-danger"><ion-icon name="alert"></ion-icon> + <div *ngIf="angForm.controls['feedback'].errors.required"> + Feedback is required. </div> - - - - - - - - - - - <div padding> - <ion-button size="large" expand="block" (click)="submitFeedback()">Submit Feedback</ion-button> - </div> + </div> + <div padding> + <ion-button size="large" expand="block" (click)="submitFeedback()">Submit Feedback</ion-button> + </div> </ion-col> </ion-row> </ion-grid> - </div> - <!--/form--> -</ion-content> + </form> +</ion-content> \ No newline at end of file diff --git a/src/app/feedback/feedback.page.ts b/src/app/feedback/feedback.page.ts index 9fbe39306ab7e8502c420b7fa718dc94c874a13a..e1793e3c1ab132c38cb241d011ca36878e66f196 100644 --- a/src/app/feedback/feedback.page.ts +++ b/src/app/feedback/feedback.page.ts @@ -1,11 +1,12 @@ import { Component, OnInit } from '@angular/core'; -import { Router } from '@angular/router'; +import { Observable } from 'rxjs'; import { HttpClient, HttpHeaders } from '@angular/common/http'; -import { RestService } from '../rest.service'; -import { UserService } from '../services/user.service'; +import { RestService } from 'src/app/rest.service'; import { Storage } from '@ionic/storage'; -import { Observable } from 'rxjs'; -import { FeedbackService } from 'src/app/services/feedback.service'; +import { Router } from '@angular/router'; +import { FormGroup, FormBuilder, Validators } from '@angular/forms'; +import { ToastService } from '../services/toast.service'; +import { FeedbackService } from '../services/feedback.service'; @Component({ selector: 'app-feedback', @@ -13,32 +14,64 @@ import { FeedbackService } from 'src/app/services/feedback.service'; styleUrls: ['./feedback.page.scss'], }) export class FeedbackPage implements OnInit { + public angForm: FormGroup; + + + feedbackApi: Observable<any>; content: ""; bikeId=""; + public isDetailsVisible = false; + + + + - constructor(private router: Router, - public httpClient: HttpClient, + constructor(private router: Router, + public httpClient: HttpClient, public restService: RestService, - public userService: UserService, + private toastService: ToastService, + private fb: FormBuilder, private storage: Storage, - public feedbackService: FeedbackService) { } + public feedbackService: FeedbackService) { + this.createForm(); + + } ngOnInit() { + } + createForm() { + this.angForm = this.fb.group({ + + + feedback: ['', [Validators.required ]], + + + + + }); + } submitFeedback() { + if (this.angForm.invalid) { + return; + } + let Form = JSON.stringify(this.angForm.value); + this.storage.get('token').then((token) => { let url = 'http://193.196.52.237:8081/feedbacks' - + let Form = JSON.stringify(this.angForm.value); const headers = new HttpHeaders().set("Authorization", "Bearer " + token); - this.feedbackApi = this.httpClient.post<any>(url, {"content": this.content,"bikeId":this.feedbackService.getBikeid()},{headers}); + this.feedbackApi = this.httpClient.post<any>(url, {"content": Form,"bikeId":this.feedbackService.getBikeid()},{headers}); this.feedbackApi.subscribe((resp) => { console.log("rides response", resp); - + this.isDetailsVisible = false; + this.router.navigateByUrl('/ridehistory'); //this.loadingService.hideLoader(); }, (error) => {console.log(error) //this.loadingService.hideLoader(); }); }); } -} \ No newline at end of file + } + diff --git a/src/app/home/home.page.html b/src/app/home/home.page.html index 2c25d362d3a955d661739433c73e5815e2f17ddf..91f7f46c9bd6905837f7eb174dd2e1129a2dfcf5 100644 --- a/src/app/home/home.page.html +++ b/src/app/home/home.page.html @@ -112,9 +112,9 @@ <ion-col> <ion-button size="medium" expand="block" (click)="reserveBike()">Reserve</ion-button> </ion-col> - <ion-col> + <!--<ion-col> <ion-button size="medium" expand="block" (click)="navigatetoBike()">Navigate</ion-button> - </ion-col> + </ion-col>--> </ion-row> </ion-grid> </div>