@botonic/react
Version:
Build Chatbots using React
35 lines • 1.52 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.ReactBot = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const core_1 = require("@botonic/core");
const text_1 = require("./components/text");
const contexts_1 = require("./contexts");
class ReactBot extends core_1.CoreBot {
constructor(options) {
super(Object.assign({ defaultRoutes: [
{
path: '404',
action: () => (0, jsx_runtime_1.jsx)(text_1.Text, { children: "I don't understand you" }), // eslint-disable-line
},
], renderer: (args) => this.renderReactActions(args) }, options));
}
renderReactActions({ request, actions }) {
return tslib_1.__awaiter(this, void 0, void 0, function* () {
const renderedActions = [];
for (const Action of actions) {
if (Action) {
const props = Action.botonicInit
? yield Action.botonicInit(request)
: {};
const renderedAction = ((0, jsx_runtime_1.jsx)(contexts_1.RequestContext.Provider, Object.assign({ value: request }, { children: (0, jsx_runtime_1.jsx)(Action, Object.assign({}, props)) })));
renderedActions.push(renderedAction);
}
}
return renderedActions;
});
}
}
exports.ReactBot = ReactBot;
//# sourceMappingURL=react-bot.js.map
;