UNPKG

redux-security

Version:
79 lines (53 loc) 3.41 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _reduxJournal = require('redux-journal'); var _Snackbar = require('material-ui/Snackbar'); var _Snackbar2 = _interopRequireDefault(_Snackbar); var _actions = require('../actions'); var _config = require('../config'); var _select = require('../select'); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } var tags = _config.TAGS + '.react.snackbar.login'; var AuthSnackbarLogin = function (_React$Component) { _inherits(AuthSnackbarLogin, _React$Component); function AuthSnackbarLogin(props, context) { _classCallCheck(this, AuthSnackbarLogin); var _this = _possibleConstructorReturn(this, Object.getPrototypeOf(AuthSnackbarLogin).call(this, props, context)); _this.componentWillReceiveProps = function (nextProps) { var auth = (0, _select.select)(nextProps.auth); if (auth.status() == _actions.types.LOGIN_REQUEST) _this.setState({ value: true }); }; _this.onRequestClose = function () { return _this.setState({ value: false }); }; var _props$serviceName = props.serviceName; var serviceName = _props$serviceName === undefined ? _config.SERVICE : _props$serviceName; _this.state = { serviceName: serviceName, value: false }; return _this; } _createClass(AuthSnackbarLogin, [{ key: 'render', value: function render() { return _react2.default.createElement(_Snackbar2.default, { open: this.state.value, message: 'LOGIN', autoHideDuration: 2000, onRequestClose: this.onRequestClose }); } }]); return AuthSnackbarLogin; }(_react2.default.Component); AuthSnackbarLogin.propTypes = { auth: _react.PropTypes.object.isRequired, serviceName: _react.PropTypes.string }; exports.default = AuthSnackbarLogin;