import { AgentState } from '../common/state/AgentState'; import { LayoutState } from '../common/state/LayoutState'; import { AgentAuthClient } from '../common/clients/AgentAuthClient'; import { AppConfigType } from '../common/entities/AppConfig'; export class LayoutController { isTestEnvironment: boolean; isAgentMode: boolean; year: number; constructor(appConfig: AppConfigType, public layoutState: LayoutState, public agentState: AgentState, agentAuthClient: AgentAuthClient) { this.isAgentMode = appConfig.csa; this.isTestEnvironment = appConfig.isTestEnvironment; this.year = new Date().getFullYear(); // Check if the agent is already logged in and set the initial state - i.e. hide the login box if (appConfig.csa) { agentAuthClient.user().then(response => agentState.username = response.data.username); } } }