Vulcan/packages/vulcan-accounts/imports/ui/components/PasswordOrService.jsx
2017-06-01 11:42:30 +09:00

37 lines
No EOL
1.1 KiB
JavaScript
Executable file
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import React, { PureComponent } from 'react';
import PropTypes from 'prop-types';
import { hasPasswordService } from '../../helpers.js';
import { registerComponent } from 'meteor/vulcan:core';
import { intlShape } from 'meteor/vulcan:i18n';
export class AccountsPasswordOrService extends PureComponent {
render () {
let { className = "password-or-service", style = {} } = this.props;
const services = Object.keys(this.props.oauthServices).map(service => {
return this.props.oauthServices[service].label;
});
let labels = services;
if (services.length > 2) {
labels = [];
}
if (hasPasswordService() && services.length > 0) {
return (
<div style={ style } className={ className }>
{ `${this.context.intl.formatMessage({id: 'accounts.or_use'})} ${ labels.join(' / ') }` }
</div>
);
}
return null;
}
}
AccountsPasswordOrService.propTypes = {
oauthServices: PropTypes.object
};
AccountsPasswordOrService.contextTypes = {
intl: intlShape
};
registerComponent('AccountsPasswordOrService', AccountsPasswordOrService);