import { inject, observer } from 'mobx-react';
import React from 'react';
import { Home, LoginWebview } from './components';
import { AppStore } from './stores/app.store';

interface IProps {
  appStore?: AppStore;
}

interface IState {}

@inject('appStore')
@observer
export class Wrapper extends React.Component<IProps, IState> {
  constructor(props: any) {
    super(props);
  }

  public render() {
    const { appStore } = this.props;

    if (!appStore!.appReady) {
      return null;
    }

    if (!appStore!.isLoggedIn) {
      return <LoginWebview />;
    }

    return <Home />;
  }
}
