import { Component, OnInit } from '@angular/core'; import { SharedService } from '../../shared/shared.service'; import { CustomerService } from 'app/services/customer.service'; import { Customer } from 'app/shared/modal/customer'; import { ActivatedRoute } from '@angular/router'; @Component({ selector: 'public-customer', templateUrl: './customer.component.html', styleUrls: ['./customer.component.css'] }) export class PublicCustomerComponent implements OnInit { storeId: number; customer: Customer; orderNumberFromURL: number; constructor(private sharedService: SharedService, private customerService: CustomerService, private activatedRoute: ActivatedRoute ) { } ngOnInit() { // Reading the StoreID and OrderID from URL this.sharedService.storeId.subscribe((val: number) => { this.storeId = val; //Setting the storeId }); this.activatedRoute.queryParams.subscribe(params => { this.orderNumberFromURL = parseInt(params.orderId.substring(2)); }); this.sharedService.showSpinner(true); // spinner this.customerService.getCustomerProfile(this.storeId, this.orderNumberFromURL, null).subscribe(customerData => { this.sharedService.showSpinner(false); // spinner this.customer = customerData; }, error => { this.sharedService.showSpinner(false); // spinner this.sharedService.showErrorMessage(error, true); }); } }