From c2b0c603c03fb638c1192270dac9ddd76afecf66 Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 31 Jan 2017 13:17:01 +0000 Subject: [PATCH 1/2] Add referral section to user settings This allows those who have registered to referrer other students to Riot and have their referral counted for the campaign competition. --- src/components/structures/UserSettings.js | 23 +++++++++++++++++++ .../structures/login/Registration.js | 2 +- 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index cf4a63e2f7..ab2b73711a 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -444,6 +444,27 @@ module.exports = React.createClass({ ); }, + _renderReferral: function() { + const teamToken = window.localStorage.getItem('mx_team_token'); + if (!teamToken) { + return null; + } + if (typeof teamToken !== 'string') { + console.warn('Team token not a string'); + return null; + } + const href = window.location.origin + + `/#/register?referrer=${this._me}&team_token=${teamToken}`; + return ( +
+

Referral

+
+ Refer a friend to Riot: {href} +
+
+ ); + }, + _renderUserInterfaceSettings: function() { var client = MatrixClientPeg.get(); @@ -819,6 +840,8 @@ module.exports = React.createClass({ {accountJsx} + {this._renderReferral()} + {notification_area} {this._renderUserInterfaceSettings()} diff --git a/src/components/structures/login/Registration.js b/src/components/structures/login/Registration.js index 82cdbef9ca..d38441a76c 100644 --- a/src/components/structures/login/Registration.js +++ b/src/components/structures/login/Registration.js @@ -57,7 +57,7 @@ module.exports = React.createClass({ // URL of the riot-team-server to get team configurations and track referrals teamServerURL: React.PropTypes.string.isRequired, }), - teamSelected: null, + teamSelected: React.PropTypes.object, defaultDeviceDisplayName: React.PropTypes.string, From c261ca1f5ee8342a00ae5b4949cc03f22586de0b Mon Sep 17 00:00:00 2001 From: Luke Barnard Date: Tue, 31 Jan 2017 15:17:43 +0000 Subject: [PATCH 2/2] Allow base referral URL to be configurable --- src/components/structures/LoggedInView.js | 1 + src/components/structures/UserSettings.js | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/components/structures/LoggedInView.js b/src/components/structures/LoggedInView.js index c00bd2c6db..44beb787c8 100644 --- a/src/components/structures/LoggedInView.js +++ b/src/components/structures/LoggedInView.js @@ -171,6 +171,7 @@ export default React.createClass({ brand={this.props.config.brand} collapsedRhs={this.props.collapse_rhs} enableLabs={this.props.config.enableLabs} + referralBaseUrl={this.props.config.referralBaseUrl} />; if (!this.props.collapse_rhs) right_panel = ; break; diff --git a/src/components/structures/UserSettings.js b/src/components/structures/UserSettings.js index ab2b73711a..3d330e3649 100644 --- a/src/components/structures/UserSettings.js +++ b/src/components/structures/UserSettings.js @@ -92,6 +92,9 @@ module.exports = React.createClass({ // True to show the 'labs' section of experimental features enableLabs: React.PropTypes.bool, + // The base URL to use in the referral link. Defaults to window.location.origin. + referralBaseUrl: React.PropTypes.string, + // true if RightPanel is collapsed collapsedRhs: React.PropTypes.bool, }, @@ -453,7 +456,7 @@ module.exports = React.createClass({ console.warn('Team token not a string'); return null; } - const href = window.location.origin + + const href = (this.props.referralBaseUrl || window.location.origin) + `/#/register?referrer=${this._me}&team_token=${teamToken}`; return (