Commit 9e34c060 authored by gap95's avatar gap95
Browse files

feedback validations added and change in login url back to authenticate

parent ace1e8b7
......@@ -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
});
......
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]
......
......@@ -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
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
}
......@@ -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>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment