File size: 2,136 Bytes
1e92f2d
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
import '@automattic/calypso-polyfills';
import i18n from 'i18n-calypso';
import PropTypes from 'prop-types';
import { Component } from 'react';
import RenderDom from 'react-dom';
import Main from 'calypso/components/main';
import InvalidActionPage from './invalid-action';
import RegistrantVerificationPage from './registrant-verification';
import TransferAwayConfirmationPage from './transfer-away-confirmation';

import 'calypso/assets/stylesheets/style.scss';
import './style.scss';

class DomainsLandingPage extends Component {
	static propTypes = {
		action: PropTypes.string.isRequired,
		query: PropTypes.object.isRequired,
	};

	renderRegistrantVerificationContent() {
		// The reseller parameter is optional and contains the name of the DSAPI reseller that the domain was registered with
		const { domain, email, reseller, token } = this.props.query;
		return (
			<RegistrantVerificationPage
				domain={ domain }
				email={ email }
				reseller={ reseller }
				token={ token }
			/>
		);
	}

	renderTransferAwayConfirmation() {
		const { domain, recipient_id, token } = this.props.query;
		return (
			<TransferAwayConfirmationPage
				domain={ domain }
				recipientId={ recipient_id }
				token={ token }
			/>
		);
	}

	renderUnknownActionContent() {
		return <InvalidActionPage />;
	}

	renderContent() {
		switch ( this.props.action ) {
			case 'registrant-verification':
				return this.renderRegistrantVerificationContent();

			case 'transfer-away-confirmation':
				return this.renderTransferAwayConfirmation();

			case 'unknown-action':
			default:
				return this.renderUnknownActionContent();
		}
	}

	render() {
		return <Main className="domains">{ this.renderContent() }</Main>;
	}
}

/**
 * Default export. Boots up the landing page.
 */
function boot() {
	if ( window.i18nLocaleStrings ) {
		const i18nLocaleStringsObject = JSON.parse( window.i18nLocaleStrings );
		i18n.setLocale( i18nLocaleStringsObject );
	}

	RenderDom.render(
		<DomainsLandingPage
			action={ window.domainsLandingData.action }
			query={ window.domainsLandingData.query }
		/>,
		document.getElementById( 'primary' )
	);
}

boot();