UNPKG

@botonic/react

Version:

Build Chatbots using React

25 lines 1.35 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WhatsappTemplate = void 0; const tslib_1 = require("tslib"); const jsx_runtime_1 = require("react/jsx-runtime"); const core_1 = require("@botonic/core"); const react_1 = tslib_1.__importDefault(require("react")); const react_2 = require("../util/react"); const message_1 = require("./message"); const serialize = whatsappTemplateProps => { return { text: whatsappTemplateProps }; }; const WhatsappTemplate = props => { const renderBrowser = () => { // Return a dummy message for browser const message = `Template ${props.name} with namespace ${props.namespace} would be sent to the user.`; return ((0, jsx_runtime_1.jsx)(message_1.Message, Object.assign({ json: serialize(message) }, props, { type: core_1.INPUT.TEXT }, { children: message }))); }; const renderNode = () => { return ((0, jsx_runtime_1.jsx)("message", Object.assign({}, props, { header: props.header && JSON.stringify(props.header), body: props.body && JSON.stringify(props.body), footer: props.footer && JSON.stringify(props.footer), type: core_1.INPUT.WHATSAPP_TEMPLATE }))); }; return (0, react_2.renderComponent)({ renderBrowser, renderNode }); }; exports.WhatsappTemplate = WhatsappTemplate; //# sourceMappingURL=whatsapp-template.js.map