UNPKG

@botonic/react

Version:

Build Chatbots using React

34 lines 1.69 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.WhatsappProductCarousel = void 0; const jsx_runtime_1 = require("react/jsx-runtime"); const core_1 = require("@botonic/core"); const functional_1 = require("../util/functional"); const react_1 = require("../util/react"); const message_1 = require("./message"); const serialize = (message) => { return { text: message }; }; const WhatsappProductCarousel = (props) => { const renderBrowser = () => { // Return a dummy message for browser const message = `WhatsApp Product Carousel 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 getCards = (cards) => { cards.forEach((card, index) => { if (!card.cardIndex) { card.cardIndex = index; } }); return (0, functional_1.toSnakeCaseKeys)(cards); }; const renderNode = () => { return ( // @ts-ignore Property 'message' does not exist on type 'JSX.IntrinsicElements'. (0, jsx_runtime_1.jsx)("message", Object.assign({}, props, { bodyParameters: JSON.stringify((0, functional_1.toSnakeCaseKeys)(props.bodyParameters)), cards: JSON.stringify(getCards(props.cards)), templateName: props.templateName, templateLanguage: props.templateLanguage, type: core_1.INPUT.WHATSAPP_PRODUCT_CAROUSEL }))); }; return (0, react_1.renderComponent)({ renderBrowser, renderNode }); }; exports.WhatsappProductCarousel = WhatsappProductCarousel; //# sourceMappingURL=whatsapp-product-carousel.js.map