import * as React from 'react';
import { Component } from 'react';
import '../stylesheets/bbb/oauth.scss';

export default class OAuthPage extends Component {
	public state = {
		loadTime: +new Date()
	};
	props: {
		onReceiveToken: (token: string) => any;
		pathname: string;
	};
	// componentDidMount() {
	//   this.setState({ loadTime: +new Date() });
	//   const params = extractOauthUrlParams();
	//   if (params && params.code) {
	//     const { code, state } = params;
	//     upgradeToken({ code, state }).then(({ token }) => this.props.onReceiveToken(token));
	//   }
	// }
	renderDots() {
		const numDots = Math.min(Math.ceil((+new Date() - this.state.loadTime) / 1000), 10);
		return new Array(numDots).map((d) => '.').join('');
	}
	render() {
		return (
			<div className="app">
				<h1 className="oauth-loading-message">Validating..{this.renderDots()}</h1>
			</div>
		);
	}
}
