import * as React from "react" ; import * as ReactDOM from "react-dom" ; import * as MvcRouter from "mvc-router-spa" ; import { ControllerBase } from "./ControllerBase" ; import { Account } from "../Models/Account" ; import { BankApp } from "../BankApp" ; import { AccountPageProps , AccountPage , AccountPageState } from "../Views/AccountPage" ; export class AccountController extends ControllerBase { private accountType : number ; private account : Account ; private accountPage : AccountPage ; constructor ( app ) { super ( app ) ; } protected loadPage ( params ) { this . accountType = parseInt ( params [ "type" ] , 10 ) ; this . account = this . app . getBank ( ) . getAccount ( this . accountType ) ; const props = { account : this . account , onDepositClicked : ( ) => this . onDepositClicked ( ) , onWithdrawClicked : ( ) => this . onWithdrawClicked ( ) , ref : component => { if ( component ) { this . accountPage = component ; } } } ; ReactDOM . render ( React . createElement ( AccountPage , props ) , this . pageContainer , ( ) => { this . initPage ( ) ; } ) ; } private initPage ( ) { } private onDepositClicked ( ) { this . app . navigate ( `/account/${ this . accountType }/deposit` ) ; } private onWithdrawClicked ( ) { this . app . navigate ( `/account/${ this . accountType }/withdrawal` ) ; } }