import Template from 'template'; import SystemId from 'system/enum/id'; import AccountNode from 'type/node/account'; import getNodeParameters from 'utility/get-node-parameters'; interface Input { readonly account: AccountNode; } class AccountMenuTemplate extends Template { protected getHtml(): string { if (this.isAuthenticated()) { return this.renderAuthenticated(); } else { return this.renderUnauthenticated(); } } private renderAuthenticated(): string { const account_id = this.getAccountId(); const account_url = this.getAccountUrl(); return `
`; } private renderUnauthenticated(): string { return ` `; } private isAuthenticated(): boolean { const account_id = this.getAccountId(); return account_id !== SystemId.ANONYMOUS_ACCOUNT; } private getAccountId(): string { const account = this.getAccount(); const parameters = getNodeParameters(account.url); return parameters.id; } private getAccountUrl(): string { const account = this.getAccount(); return account.url; } private getAccount(): AccountNode { const input = this.getInput(); return input.account; } } export default AccountMenuTemplate;