UNPKG

@botonic/react

Version:

Build Chatbots using React

20 lines 761 B
import { jsx as _jsx } from "react/jsx-runtime"; import React, { useContext } from 'react'; import { RequestContext } from '../../contexts'; import { Reply } from '../reply'; import { isWhatsapp } from './multichannel-utils'; export const MultichannelReply = props => { const requestContext = useContext(RequestContext); const hasPath = () => Boolean(props.path); const hasPayload = () => Boolean(props.payload); const getText = () => `${props.children}`; if (isWhatsapp(requestContext)) { if (hasPath() || hasPayload()) return `${getText()}`; return null; } else { return _jsx(Reply, Object.assign({}, props, { children: props.children })); } }; //# sourceMappingURL=multichannel-reply.js.map