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.
pull/21833/head
Luke Barnard 2017-01-31 13:17:01 +00:00
parent 878e5593ba
commit c2b0c603c0
2 changed files with 24 additions and 1 deletions

View File

@ -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 (
<div>
<h3>Referral</h3>
<div className="mx_UserSettings_section">
Refer a friend to Riot: <a href={href}>{href}</a>
</div>
</div>
);
},
_renderUserInterfaceSettings: function() { _renderUserInterfaceSettings: function() {
var client = MatrixClientPeg.get(); var client = MatrixClientPeg.get();
@ -819,6 +840,8 @@ module.exports = React.createClass({
{accountJsx} {accountJsx}
</div> </div>
{this._renderReferral()}
{notification_area} {notification_area}
{this._renderUserInterfaceSettings()} {this._renderUserInterfaceSettings()}

View File

@ -57,7 +57,7 @@ module.exports = React.createClass({
// URL of the riot-team-server to get team configurations and track referrals // URL of the riot-team-server to get team configurations and track referrals
teamServerURL: React.PropTypes.string.isRequired, teamServerURL: React.PropTypes.string.isRequired,
}), }),
teamSelected: null, teamSelected: React.PropTypes.object,
defaultDeviceDisplayName: React.PropTypes.string, defaultDeviceDisplayName: React.PropTypes.string,