@rnga/orders
Version:
## Get schema from @prisma-cms 1. yarn get-api-schema -e http://localhost:4000 2. yarn build-api-fragments
256 lines (199 loc) • 6.94 kB
JavaScript
;
exports.__esModule = true;
exports.Modal = undefined;
var _class, _temp2;
var _react = require('react');
var _react2 = _interopRequireDefault(_react);
var _propTypes = require('prop-types');
var _propTypes2 = _interopRequireDefault(_propTypes);
var _materialUi = require('material-ui');
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 styles = {
root: {
"& .overlay": {
zIndex: 100
}
},
modal: {
minWidth: 300,
maxWidth: "100%",
"& h5.title": {
"position": "absolute",
"top": "10px",
"left": "0",
width: "100%",
textAlign: "center",
textTransform: "uppercase !important",
"color": "#d7dee4",
"margin": "0",
"fontSize": "12px"
}
}
};
var Modal = exports.Modal = (_temp2 = _class = function (_Component) {
_inherits(Modal, _Component);
function Modal() {
var _temp, _this, _ret;
_classCallCheck(this, Modal);
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) {
args[_key] = arguments[_key];
}
return _ret = (_temp = (_this = _possibleConstructorReturn(this, _Component.call.apply(_Component, [this].concat(args))), _this), _this.state = {
joinFormOpened: false,
joinFormVisible: false
}, _temp), _possibleConstructorReturn(_this, _ret);
}
Modal.prototype.componentDidMount = function componentDidMount() {
if (this.isOpened()) {
this.openForm();
}
this.initListeners();
};
Modal.prototype.componentDidUpdate = function componentDidUpdate(prevProps, prevState) {
var opened = this.props.opened;
var prevOpened = prevProps.opened;
if ((opened || prevOpened) && opened !== prevOpened) {
if (opened) {
this.openForm();
} else {
this.closeForm();
}
}
};
Modal.prototype.initListeners = function initListeners() {
// if (($('.popup2').height() + 60) > windowHeight) {
// $('.popup2').css('height', windowHeight - 100 + 'px');
// $('.popup2 .client-order').css('height', windowHeight - parseInt($('.popup2 .window').css('border-top-width')) - 100 + 'px');
// $('.popup2').css('top', '45%');
// }
var popup = this.popup;
// console.log("initListeners popup", popup);
if (!popup) {
return;
}
try {
var _global = global,
window = _global.window;
var windowHeight = window.innerHeight;
var popupHeight = popup.offsetHeight;
var maxHeight = popupHeight + 60;
// console.log("initListeners maxHeight > windowHeight", maxHeight > windowHeight, maxHeight, windowHeight);
if (maxHeight > windowHeight) {
// $('.popup2').css('height', windowHeight - 100 + 'px');
// $('.popup2 .client-order').css('height', windowHeight - parseInt($('.popup2 .window').css('border-top-width')) - 100 + 'px');
// $('.popup2').css('top', '45%');
var innerWindow = popup.querySelector(".window");
if (innerWindow) {
Object.assign(popup.style, {
height: windowHeight - 100 + 'px',
top: "46%",
display: "flex",
flexDirection: "column"
});
Object.assign(innerWindow.style, {
flex: 1,
overflow: "auto"
});
}
// const clientOrder
}
} catch (error) {
console.error(error);
}
};
Modal.prototype.isOpened = function isOpened() {
var opened = this.props.opened;
return opened;
};
Modal.prototype.openForm = function openForm(event) {
var _this2 = this;
this.setState({
joinFormVisible: true
});
setTimeout(function () {
_this2.setState({
joinFormOpened: true
});
}, 50);
};
Modal.prototype.closeForm = function closeForm(event) {
var _this3 = this;
this.setState({
joinFormOpened: false
});
setTimeout(function () {
_this3.setState({
joinFormVisible: false
});
}, 500);
};
Modal.prototype.render = function render() {
var _this4 = this;
var _state = this.state,
joinFormOpened = _state.joinFormOpened,
joinFormVisible = _state.joinFormVisible;
var _props = this.props,
children = _props.children,
handleClose = _props.handleClose,
title = _props.title,
classes = _props.classes,
className = _props.className;
var styles = {
opacity: joinFormOpened ? 1 : 0,
visibility: joinFormVisible ? "visible" : "hidden",
zIndex: 1000
};
return _react2.default.createElement(
'div',
{
className: classes.root
},
_react2.default.createElement('div', {
className: ["overlay", classes.overlay].join(" "),
style: styles,
onClick: handleClose
}),
_react2.default.createElement(
'div',
{
className: [classes.modal, className].join(" "),
style: styles,
onClick: function onClick(event) {
return event.stopPropagation();
},
ref: function ref(el) {
_this4.popup = el;
}
},
title ? _react2.default.createElement(
'h5',
{ className: "h5 title" },
title
) : null,
children,
handleClose ? _react2.default.createElement(
'div',
{
className: 'close_modal',
onClick: handleClose
},
'x'
) : null
)
);
};
return Modal;
}(_react.Component), _class.defaultProps = {
className: "popup2"
}, _temp2);
Modal.propTypes = process.env.NODE_ENV !== "production" ? {
className: _propTypes2.default.string.isRequired
} : {};
Modal.propTypes = process.env.NODE_ENV !== "production" ? {
opened: _propTypes2.default.bool.isRequired,
handleClose: _propTypes2.default.func
} : {};
exports.default = (0, _materialUi.withStyles)(styles)(Modal);