import { Component, OnInit } from '@angular/core';
import { Location } from '@angular/common';
import { trigger, transition, animate, style } from '@angular/animations';
import { Router, ActivatedRoute } from '@angular/router';
import { AuthenticationService } from '../../Config/services/auth.service';
import {StorageService } from '../../Config/services/storage.service';
import { ValidationService } from '../../Config/services/validation.service';
@Component({
  selector: 'app-myorders',
  templateUrl: './myorders.page.html',
  styleUrls: ['./myorders.page.scss'],
})
export class MyordersPage implements OnInit {
 oderDeatils = [];
  constructor(
    private router: Router,
    private route: ActivatedRoute,
    private location: Location,
    private authenticationservice: AuthenticationService,
    private storageservice: StorageService,
    private validationservice: ValidationService
  ) {
    this.oderDeatils = null;
    this.getMyorders();
  }

  ngOnInit() {
  }


  goToPage(path, data= null) {
    this.router.navigateByUrl(path, {queryParams: data});
    document.body.scrollTop = document.documentElement.scrollTop = 0;
  }

  goBack() {
    this.location.back();
  }
getMyorders() {
  this.authenticationservice.get_data('').subscribe((data) => {
    if ( data.status === 'success') {
      this.oderDeatils = data.data;
      console.log(this.oderDeatils);
    } else {
      this.oderDeatils = null;
      this.validationservice.presentToast(data.message);
    }
  });
}
}