@kiwicom/smart-faq
Version:
102 lines (83 loc) • 3.69 kB
JavaScript
;
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.GuaranteeChatInfoState = void 0;
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
var _objectSpread2 = _interopRequireDefault(require("@babel/runtime/helpers/objectSpread"));
var React = _interopRequireWildcard(require("react"));
// @flow
/* eslint-disable react/no-unused-state */
var initialState = {
showGuaranteeChat: false,
guaranteeChatBookingInfo: null,
chatConfig: {}
};
var GuaranteeChatInfoState = React.createContext((0, _objectSpread2.default)({}, initialState, {
onSetBookingInfo: function onSetBookingInfo() {},
onAppWithOpenChatClose: function onAppWithOpenChatClose() {},
toggleGuaranteeChat: function toggleGuaranteeChat(showGuaranteeChat
/*: boolean*/
) {},
// eslint-disable-line no-unused-vars
isChatEnabled: function isChatEnabled() {
return true;
}
}));
exports.GuaranteeChatInfoState = GuaranteeChatInfoState;
var GuaranteeChatInfo =
/*#__PURE__*/
function (_React$Component) {
(0, _inherits2.default)(GuaranteeChatInfo, _React$Component);
function GuaranteeChatInfo(props
/*: Props*/
) {
var _this;
(0, _classCallCheck2.default)(this, GuaranteeChatInfo);
_this = (0, _possibleConstructorReturn2.default)(this, (0, _getPrototypeOf2.default)(GuaranteeChatInfo).call(this, props));
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "onSetBookingInfo", function (guaranteeChatBookingInfo
/*: GuaranteeChatBookingInfo*/
) {
_this.setState({
guaranteeChatBookingInfo: guaranteeChatBookingInfo
});
});
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "toggleGuaranteeChat", function (showGuaranteeChat
/*: boolean*/
) {
_this.setState({
showGuaranteeChat: showGuaranteeChat
});
});
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)((0, _assertThisInitialized2.default)(_this)), "isChatEnabled", function () {
return _this.props.enableChat || false;
});
_this.state = (0, _objectSpread2.default)({}, initialState, {
onSetBookingInfo: _this.onSetBookingInfo,
toggleGuaranteeChat: _this.toggleGuaranteeChat,
isChatEnabled: _this.isChatEnabled,
chatConfig: _this.props.chatConfig,
onAppWithOpenChatClose: _this.props.onAppWithOpenChatClose
});
return _this;
}
(0, _createClass2.default)(GuaranteeChatInfo, [{
key: "render",
value: function render() {
return React.createElement(GuaranteeChatInfoState.Provider, {
value: this.state
}, this.props.children);
}
}]);
return GuaranteeChatInfo;
}(React.Component);
var _default = GuaranteeChatInfo;
exports.default = _default;