UNPKG

@rnga/orders

Version:

## Get schema from @prisma-cms 1. yarn get-api-schema -e http://localhost:4000 2. yarn build-api-fragments

205 lines (146 loc) 6.24 kB
'use strict'; exports.__esModule = true; exports.default = undefined; var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; var _class, _temp; var _react = require('react'); var _react2 = _interopRequireDefault(_react); var _propTypes = require('prop-types'); var _propTypes2 = _interopRequireDefault(_propTypes); var _Prototype2 = require('./Prototype'); var _Prototype3 = _interopRequireDefault(_Prototype2); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; } 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; } // import {connect} from 'react-redux'; // import {bindActionCreators} from 'redux'; // import * as userActions from 'modules/Redux/actions/userActions'; // import * as documentActions from 'modules/Redux/actions/documentActions'; // import Prototype from 'material-ui-components/src/Auth'; // import Avatar from 'modules/Site/components/fields/User/avatar.js'; var AuthPrototype = function (_Prototype) { _inherits(AuthPrototype, _Prototype); function AuthPrototype() { _classCallCheck(this, AuthPrototype); return _possibleConstructorReturn(this, _Prototype.apply(this, arguments)); } AuthPrototype.prototype.findUser = function findUser() { var _this2 = this; if (this.state.wait_for_response === true) { return; } var query = this.state.login; var body = new FormData(); var data = { query: query }; for (var i in data) { body.append(i, data[i]); }; // var headers; var newStata = { errors: { login: "" }, wait_for_response: false }; fetch(this.props.connector_url + '?pub_action=users/find_user', { credentials: 'same-origin', method: "POST", body: body }).then(function (response) { return response.json(); }).then(function (data) { if (data.success) { if (data.object && data.object.id) { Object.assign(newStata, { step: 2, login: data.object.username, avatar: data.object.image, fullname: data.object.fullname || data.object.username }); } else { newStata.errors = { login: { errorText: "Ошибка" } }; this.props.addInformerMessage({ text: data.message || "Пользователь не был найден", autohide: 3000 }); } } else { this.props.addInformerMessage({ text: data.message || "Ошибка выполнения запроса", autohide: 4000 }); } this.setState(newStata); }.bind(this)).catch(function (error) { console.error('Request failed', error); _this2.setState(newStata); _this2.props.addInformerMessage({ text: "Ошибка выполнения запроса", autohide: 4000 }); }); this.setState({ wait_for_response: true }); }; return AuthPrototype; }(_Prototype3.default); var Auth = (_temp = _class = function (_Component) { _inherits(Auth, _Component); function Auth() { _classCallCheck(this, Auth); return _possibleConstructorReturn(this, _Component.apply(this, arguments)); } Auth.prototype.render = function render() { var _props = this.props, loginCanceled = _props.loginCanceled, loginComplete = _props.loginComplete, other = _objectWithoutProperties(_props, ['loginCanceled', 'loginComplete']); return _react2.default.createElement(AuthPrototype, _extends({ loginCanceled: loginCanceled // GetOwnData={GetOwnData} , loginComplete: loginComplete // addInformerMessage={addInformerMessage} }, other)); }; return Auth; }(_react.Component), _class.defaultProps = { open: false, step: 1, showRegForm: true, allowPasswordRecovery: true }, _temp); // Auth.defaultProps = defaultProps; // Auth.propTypes = { // userActions: PropTypes.object.isRequired, // documentActions: PropTypes.object.isRequired, // }; // function mapStateToProps(state) { // return state; // } // function mapDispatchToProps(dispatch) { // return { // // proxyActions: bindActionCreators(proxyActions, dispatch), // userActions: bindActionCreators(userActions, dispatch), // documentActions: bindActionCreators(documentActions, dispatch), // // documentActions: bindActionCreators(documentActions, dispatch), // } // } // export default connect(mapStateToProps, mapDispatchToProps)(Auth); exports.default = Auth; Auth.propTypes = process.env.NODE_ENV !== "production" ? { // handleClose: PropTypes.func.isRequired, loginCanceled: _propTypes2.default.func.isRequired, // GetOwnData: PropTypes.func.isRequired, loginComplete: _propTypes2.default.func.isRequired // addInformerMessage: PropTypes.func.isRequired, } : {}; module.exports = exports['default'];