/**
 * React Native Full App (https://store.enappd.com/product/react-native-full-app)
 *
 * Copyright © 2019-present Enappd. All rights reserved.
 *
 * This source code is licensed as per the terms found in the
 * LICENSE.md file in the root directory of this source tree.
 */
import React, { Component } from 'react';
import { Root } from 'native-base';
import VerificationView from './verficationView';
import { NavigationStackScreenProps } from 'react-navigation-stack';

interface Iprops extends NavigationStackScreenProps {}
interface Istate {
  spinner: boolean;
}

class VerificationContainer extends Component<Iprops, Istate> {
  static navigationOptions = {
    headerShown: false,
  };

  constructor(props: Iprops) {
    super(props);
    this.state = {
      spinner: false,
    };
  }

  goBack = () => {
    this.props.navigation.goBack();
  };

  gotoHome = () => {
    if (!this.state.spinner) {
      this.setState({ spinner: true });
      setTimeout(() => {
        this.props.navigation.navigate('App');
        this.setState({
          spinner: false,
        });
      }, 100);
    }
  };

  goToSignup = () => {
    this.props.navigation.navigate('signup');
  };

  render() {
    return (
      <Root>
        <VerificationView
          goBack={this.goBack}
          gotoHome={this.gotoHome}
          spinner={this.state.spinner}
        />
      </Root>
    );
  }
}
export default VerificationContainer;
