Skip to content

Commit

Permalink
fixed interactive message api difference
Browse files Browse the repository at this point in the history
  • Loading branch information
mdshamoon committed Sep 7, 2021
1 parent d7e681f commit 2400f64
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
6 changes: 1 addition & 5 deletions src/common/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,9 @@ export const getInteractiveMessageBody = (interactiveJSON: any) => {
const { content } = interactiveJSON;
switch (content.type) {
case 'text':
messageBody = content.caption;
break;
case 'image':
messageBody = content.caption;
break;
case 'video':
messageBody = content.caption;
messageBody = content.text;
break;
case 'file':
messageBody = content.filename;
Expand Down
14 changes: 7 additions & 7 deletions src/containers/InteractiveMessage/InteractiveMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,24 @@ const convertJSONtoStateData = (JSONData: any, interactiveType: string) => {
const { title, body, items, content, options, globalButtons } = data;

if (interactiveType === QUICK_REPLY) {
const { type, caption, url, text } = content;
const { type, header, url, text } = content;
const result: any = {};
result.templateButtons = options.map((option: any) => ({ value: option.title }));
result.title = text || '';
result.title = header || '';
switch (type) {
case 'image':
case 'video':
result.type = `${type.toUpperCase()}`;
result.attachmentURL = url;
result.body = caption;
result.body = text;
break;
case 'file':
result.type = 'DOCUMENT';
result.attachmentURL = url;
break;
default:
result.type = null;
result.body = caption || '';
result.body = text || '';
}
return result;
}
Expand Down Expand Up @@ -507,7 +507,7 @@ export const InteractiveMessage: React.SFC<FlowProps> = ({ match }) => {
case 'VIDEO':
result.type = `${mediaType.toLowerCase()}`;
result.url = payload.attachmentURL;
result.caption = payload.body.getCurrentContent().getPlainText();
result.text = payload.body.getCurrentContent().getPlainText();
break;
case 'DOCUMENT':
result.type = 'file';
Expand All @@ -516,8 +516,8 @@ export const InteractiveMessage: React.SFC<FlowProps> = ({ match }) => {
break;
default:
result.type = 'text';
result.text = payload.title;
result.caption = payload.body.getCurrentContent().getPlainText();
result.header = payload.title;
result.text = payload.body.getCurrentContent().getPlainText();
break;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const getTranslations = (type: string, language: any, data: string) => {
const result = Object.keys(dataObj).reduce((acc: any, langId: string) => {
const { content, body } = dataObj[langId];
if (type === QUICK_REPLY) {
acc[langId] = { body: content?.caption || '' };
acc[langId] = { body: content?.text || '' };
} else {
acc[langId] = { body };
}
Expand Down

0 comments on commit 2400f64

Please sign in to comment.