import Controller from 'sap/fe/core/PageController';
// @ts-ignore
import { URLHelper } from 'sap/m/library';
// @ts-ignore
import MessageBox, { Action } from 'sap/m/MessageBox';

/**
* @namespace at.clouddna.books.ext.main.Main.controller
*/
export default class Main extends Controller {
    public onInit(): void {
        Controller.prototype.onInit.apply(this);
    }
    public onSearchPress(event: any) {
        let isbn: string = event.getSource().getBindingContext().getObject().ISBN;

        MessageBox.confirm("This will open another window. Do you want to continue?", {
            onClose: (action: Action) => {
                if (action === Action.OK) {
                    URLHelper.redirect(`https://www.google.com/search?q=ISBN ${isbn}`, true);
                }
            }
        });

    }
}