Skip to content

Commit

Permalink
botonic-react: add whatsapp catalog component
Browse files Browse the repository at this point in the history
  • Loading branch information
AlbertGom committed Dec 23, 2024
1 parent 6a7cbaa commit 5de727f
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/botonic-react/src/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ export {
WhatsappButtonListRowProps,
WhatsappButtonListSectionProps,
} from './whatsapp-button-list'
export { WhatsappCatalog, WhatsappCatalogProps } from './whatsapp-catalog'
export {
WhatsappCTAUrlButton,
WhatsappCTAUrlButtonProps,
Expand Down
42 changes: 42 additions & 0 deletions packages/botonic-react/src/components/whatsapp-catalog.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import { INPUT } from '@botonic/core'
import React from 'react'

import { renderComponent } from '../util/react'
import { Message } from './message'

export interface WhatsappCatalogProps {
body: string
footer: string
thumbnailProductId?: string
}

const serialize = (message: string) => {
return { text: message }
}

export const WhatsappCatalog = (props: WhatsappCatalogProps) => {
const renderBrowser = () => {
// Return a dummy message for browser
const message = `WhatsApp Catalog would be sent to the user.`
return (
<Message json={serialize(message)} {...props} type={INPUT.TEXT}>
{message}
</Message>
)
}

const renderNode = () => {
return (
// @ts-ignore Property 'message' does not exist on type 'JSX.IntrinsicElements'.
<message
{...props}
body={props.body}
footer={props.footer}
thumbnailProductId={props.thumbnailProductId}
type={INPUT.WHATSAPP_CATALOG}
/>
)
}

return renderComponent({ renderBrowser, renderNode })
}

0 comments on commit 5de727f

Please sign in to comment.