Chatwoot/app/javascript/widget/store/modules/messageV2/helpers.js
Nithin David Thomas 211f5cdedd
feat: Refactors API on widget side to support multiple conversations (#3032)
* State structure

* How to refactr action modules

* feat: Add state and mutations for multiple conversation on widget

* Adds actions to support multiple conversation

* feat: Adds public API endpoints for widget

* fixes lint errors

* Refactors store

* Update mutations to accommodate new changes in store

* Refactors actions in messages

* fixes broken tests
2021-09-23 11:56:24 +05:30

32 lines
723 B
JavaScript

import { MESSAGE_TYPE } from 'widget/helpers/constants';
import getUuid from '../../../helpers/uuid';
export const createTemporaryMessage = ({ attachments, content }) => {
const timestamp = new Date().getTime() / 1000;
return {
id: getUuid(),
content,
attachments,
status: 'in_progress',
created_at: timestamp,
message_type: MESSAGE_TYPE.INCOMING,
};
};
export const createTemporaryAttachmentMessage = ({
thumbUrl,
fileType,
content,
}) => {
const attachment = {
thumb_url: thumbUrl,
data_url: thumbUrl,
file_type: fileType,
status: 'in_progress',
};
const message = createTemporaryMessage({
attachments: [attachment],
content,
});
return message;
};