feat: Support multiple file upload on dashboard (#3748)
Co-authored-by: Sivin Varghese <64252451+iamsivin@users.noreply.github.com>
This commit is contained in:
parent
b304f5a826
commit
8cff690640
4 changed files with 22 additions and 9 deletions
|
@ -7,14 +7,16 @@ export const buildCreatePayload = ({
|
|||
isPrivate,
|
||||
contentAttributes,
|
||||
echoId,
|
||||
file,
|
||||
files,
|
||||
ccEmails = '',
|
||||
bccEmails = '',
|
||||
}) => {
|
||||
let payload;
|
||||
if (file) {
|
||||
if (files && files.length !== 0) {
|
||||
payload = new FormData();
|
||||
payload.append('attachments[]', file, file.name);
|
||||
files.forEach(file => {
|
||||
payload.append('attachments[]', file, file.name);
|
||||
});
|
||||
if (message) {
|
||||
payload.append('content', message);
|
||||
}
|
||||
|
@ -46,7 +48,7 @@ class MessageApi extends ApiClient {
|
|||
private: isPrivate,
|
||||
contentAttributes,
|
||||
echo_id: echoId,
|
||||
file,
|
||||
files,
|
||||
ccEmails = '',
|
||||
bccEmails = '',
|
||||
}) {
|
||||
|
@ -58,7 +60,7 @@ class MessageApi extends ApiClient {
|
|||
isPrivate,
|
||||
contentAttributes,
|
||||
echoId,
|
||||
file,
|
||||
files,
|
||||
ccEmails,
|
||||
bccEmails,
|
||||
}),
|
||||
|
|
|
@ -36,7 +36,7 @@ describe('#ConversationAPI', () => {
|
|||
echoId: 12,
|
||||
isPrivate: true,
|
||||
|
||||
file: new Blob(['test-content'], { type: 'application/pdf' }),
|
||||
files: [new Blob(['test-content'], { type: 'application/pdf' })],
|
||||
});
|
||||
expect(formPayload).toBeInstanceOf(FormData);
|
||||
expect(formPayload.get('content')).toEqual('test content');
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue