Skip to content

Commit

Permalink
Merge branch 'master' into package-updates
Browse files Browse the repository at this point in the history
  • Loading branch information
mdshamoon authored Oct 11, 2022
2 parents f577f80 + 35ee88c commit 427a437
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 27 deletions.
3 changes: 2 additions & 1 deletion src/containers/Chat/ChatMessages/ChatInput/ChatInput.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -173,11 +173,12 @@ export const ChatInput = ({
null,
Number(selectedTemplate.id)
);
resetVariable();
// else the type will by default be text
} else {
onSendMessage(message, null, 'TEXT', selectedTemplate, variableParam);
resetVariable();
}
resetVariable();

// Resetting the EditorState
setEditorState(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { v4 as uuidv4 } from 'uuid';

import styles from './QuickReplyTemplate.module.css';
import { ChatMessageType } from '../ChatMessage/ChatMessageType/ChatMessageType';
import { MessagesWithLinks } from '../MessagesWithLinks/MessagesWithLinks';

interface Content {
type: string;
Expand Down Expand Up @@ -90,6 +91,7 @@ export const QuickReplyTemplate = ({
location={{}}
isSimulatedMessage={isSimulator}
/>
{contentType === 'DOCUMENT' && <MessagesWithLinks message={media.text} />}
</div>
<div className={styles.ButtonContainer}>{quickReplyButtons}</div>
</div>
Expand Down
13 changes: 7 additions & 6 deletions src/containers/InteractiveMessage/InteractiveMessage.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,19 +123,18 @@ export const convertJSONtoStateData = (JSONData: any, interactiveType: string, l
case 'video':
result.type = type.toUpperCase();
result.attachmentURL = url;
result.body = text;
result.title = label;
break;
case 'file':
result.type = 'DOCUMENT';
result.attachmentURL = url;
result.body = '';

result.title = label;
break;
default:
result.type = null;
result.body = text || '';
}
result.body = text || '';
return result;
}

Expand Down Expand Up @@ -243,20 +242,22 @@ export const getPayloadByMediaType = (mediaType: string, payload: any) => {
case 'VIDEO':
result.type = `${mediaType.toLowerCase()}`;
result.url = payload.attachmentURL;
result.text = getPlainTextFromEditor(payload.body);
break;
case 'DOCUMENT':
result.type = 'file';
result.url = payload.attachmentURL;
result.filename = 'file';
result.filename = payload.attachmentURL?.substring(
payload.attachmentURL.lastIndexOf('/') + 1
);
break;
default:
result.type = 'text';
result.header = payload.title;
result.text = getPlainTextFromEditor(payload.body);
break;
}

result.text = getPlainTextFromEditor(payload.body);

return result;
};

Expand Down
20 changes: 0 additions & 20 deletions src/containers/InteractiveMessage/InteractiveMessage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@ export const InteractiveMessage = () => {

const [previousState, setPreviousState] = useState<any>({});
const [nextLanguage, setNextLanguage] = useState<any>('');
const [warning, setWarning] = useState<any>();
const { t } = useTranslation();
const params = useParams();

Expand Down Expand Up @@ -395,28 +394,10 @@ export const InteractiveMessage = () => {
}
};

const displayWarning = () => {
if (type && type.id === 'DOCUMENT') {
setWarning(
<div className={styles.Warning}>
<ol>
<li>{t('Body is not supported for document.')}</li>
</ol>
</div>
);
} else {
setWarning(null);
}
};

useEffect(() => {
handleAddInteractiveTemplate(false, QUICK_REPLY);
}, []);

useEffect(() => {
displayWarning();
}, [type]);

const dialogMessage = t("You won't be able to use this again.");

const options = MEDIA_MESSAGE_TYPES.filter(
Expand Down Expand Up @@ -648,7 +629,6 @@ export const InteractiveMessage = () => {
options,
optionLabel: 'label',
multiple: false,
helperText: warning,
textFieldProps: {
variant: 'outlined',
label: t('Attachment type'),
Expand Down

0 comments on commit 427a437

Please sign in to comment.