import { Component, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { NavController } from '@ionic/angular';
import Parse from "parse";

@Component({
  selector: 'app-book-detail',
  templateUrl: './book-detail.page.html',
  styleUrls: ['./book-detail.page.scss'],
})
export class BookDetailPage implements OnInit {

  constructor(private route:ActivatedRoute,
    private navCtrl:NavController
  ) { }

  ngOnInit() {
    this.loadBookById()
  }

  book:Parse.Object|undefined
  async loadBookById(){
    // let id = location.pathname.split("/").pop();
    let id = this.route.snapshot.params["id"]

    if(id){
      let query = new Parse.Query("LQLBook");
      this.book = await query.get(id);
    }
  }

  goToBack()
  {
    this.navCtrl.back();
  }

}
