-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
botonic-react: add whatsapp catalog component
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
42 changes: 42 additions & 0 deletions
42
packages/botonic-react/src/components/whatsapp-catalog.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 }) | ||
} |