From d1c8be3af389c03573f41f768318d7573f03be2d Mon Sep 17 00:00:00 2001 From: Jose Buitron Date: Tue, 17 Oct 2023 16:36:16 -0500 Subject: [PATCH] fix: Send target for group uploads --- src/group/components/GroupSharedDataUpload.js | 7 +++++-- .../components/GroupSharedDataUploadFiles.test.js | 4 ++++ .../components/LandscapeSharedDataUpload.js | 3 +-- src/sharedData/sharedDataService.js | 12 ++++-------- 4 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/group/components/GroupSharedDataUpload.js b/src/group/components/GroupSharedDataUpload.js index 29e78d8e86..baff961906 100644 --- a/src/group/components/GroupSharedDataUpload.js +++ b/src/group/components/GroupSharedDataUpload.js @@ -79,9 +79,12 @@ const GroupSharedDataUpload = () => { - + diff --git a/src/group/components/GroupSharedDataUploadFiles.test.js b/src/group/components/GroupSharedDataUploadFiles.test.js index da4338ad90..9e408f23f5 100644 --- a/src/group/components/GroupSharedDataUploadFiles.test.js +++ b/src/group/components/GroupSharedDataUploadFiles.test.js @@ -215,6 +215,10 @@ test('GroupSharedDataUpload: Complete Success', async () => { await waitFor(() => expect(uploadButton).not.toHaveAttribute('disabled')); await act(async () => fireEvent.click(uploadButton)); expect(navigate.mock.calls[0]).toEqual(['/groups/slug-1']); + + const saveCall = terrasoApi.request.mock.calls[0]; + expect(saveCall[0].body.get('target_type')).toBe('group'); + expect(saveCall[0].body.get('target_slug')).toBe('slug-1'); }); test('GroupSharedDataUpload: PDF Success', async () => { diff --git a/src/landscape/components/LandscapeSharedDataUpload.js b/src/landscape/components/LandscapeSharedDataUpload.js index f1f949230a..8188185ade 100644 --- a/src/landscape/components/LandscapeSharedDataUpload.js +++ b/src/landscape/components/LandscapeSharedDataUpload.js @@ -85,9 +85,8 @@ const LandscapeSharedDataUpload = () => { name: landscape.name, })} /> - + { const path = '/shared-data/upload/'; const body = new FormData(); const filename = `${file.name}${file.resourceType}`; - if (groupSlug) { - body.append('groups', groupSlug); - } - if (landscapeSlug) { - body.append('landscapes', landscapeSlug); - } + body.append('target_type', targetType); + body.append('target_slug', targetSlug); body.append('name', file.name); if (file.description) { body.append('description', file.description);