feedback.page.ts 1.44 KB
Newer Older
gap95's avatar
gap95 committed
1
import { Component, OnInit } from '@angular/core';
gap95's avatar
gap95 committed
2
3
4
5
6
7
8
import { Router } from '@angular/router';
import { HttpClient, HttpHeaders } from '@angular/common/http';
import { RestService } from '../rest.service';
import { UserService } from '../services/user.service';
import { Storage } from '@ionic/storage';
import { Observable } from 'rxjs';
import { FeedbackService } from 'src/app/services/feedback.service';
gap95's avatar
gap95 committed
9
10
11
12
13
14
15

@Component({
  selector: 'app-feedback',
  templateUrl: './feedback.page.html',
  styleUrls: ['./feedback.page.scss'],
})
export class FeedbackPage implements OnInit {
gap95's avatar
gap95 committed
16
17
  feedbackApi:  Observable<any>;
  content: "";
18
  bikeId="";
gap95's avatar
gap95 committed
19

gap95's avatar
gap95 committed
20
21
22
23
24
25
  constructor(private router: Router,
    public httpClient: HttpClient,
    public restService: RestService,
    public userService: UserService,
    private storage: Storage,
    public feedbackService: FeedbackService) { }
gap95's avatar
gap95 committed
26
27
28

  ngOnInit() {
  }
gap95's avatar
gap95 committed
29
30
31
32
33
  submitFeedback() {
    this.storage.get('token').then((token) => {
      let url = 'http://193.196.52.237:8081/feedbacks'
      
      const headers = new HttpHeaders().set("Authorization", "Bearer " + token);
34
      this.feedbackApi = this.httpClient.post<any>(url, {"content": this.content,"bikeId":this.feedbackService.getBikeid()},{headers});
gap95's avatar
gap95 committed
35
36
37
38
39
40
41
42
      this.feedbackApi.subscribe((resp) => {
        console.log("rides response", resp);
        
        //this.loadingService.hideLoader();
      }, (error) => {console.log(error)
        //this.loadingService.hideLoader();
      });
    });
gap95's avatar
gap95 committed
43
}
gap95's avatar
gap95 committed
44
}