211f5cdedd
* 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
32 lines
723 B
JavaScript
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;
|
|
};
|