
/**
 * 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 VerificationProps extends NavigationStackScreenProps {
    gotoHome: () => void;
    goBack: () => void;
    showLeftTime: () => void;
    goToSignup: () => void
    spinner: any

}
interface VerificationState {
    spinner: boolean,
    show: boolean
}
class VerificationContainer extends Component<VerificationProps, VerificationState> {
    static navigationOptions = {
        headerShown: false,
    }

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

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

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

    goToSignup = () => {
        this.props.navigation.navigate('signup')
    }
    showLeftTime = () => {
        this.setState({
            show: true
        })
        setTimeout(() => {
            if (this.state.show) {
                this.setState({
                    show: false
                });
            }

        }, 3000)
    }

    render() {
        const oneTime = ' A One time Password has ben sent to you!'
        const { spinner, show } = this.state
        return (
            <Root>
                <VerificationView
                    goBack={this.goBack}
                    gotoHome={this.gotoHome}
                    spinner={spinner}
                    showLeftTime={this.showLeftTime}
                    show={show}
                    oneTime={oneTime} />

            </Root>
        );
    }
}
export default VerificationContainer;
