From b82f8ef333df5ac8416cee8b70c7f6ff88319f98 Mon Sep 17 00:00:00 2001 From: Ahmad Farhat Date: Wed, 29 Nov 2023 10:40:32 -0500 Subject: [PATCH] Fixed issues with uploads (profile, presentation, branding) (#5590) --- app/controllers/api/v1/admin/site_settings_controller.rb | 2 +- .../mutations/admin/site_settings/useUpdateSiteSetting.jsx | 6 +++++- .../hooks/mutations/rooms/useUploadPresentation.jsx | 6 +++++- app/javascript/hooks/mutations/users/useCreateAvatar.jsx | 6 +++++- 4 files changed, 16 insertions(+), 4 deletions(-) diff --git a/app/controllers/api/v1/admin/site_settings_controller.rb b/app/controllers/api/v1/admin/site_settings_controller.rb index 6b8a273c0c..49109a35d4 100644 --- a/app/controllers/api/v1/admin/site_settings_controller.rb +++ b/app/controllers/api/v1/admin/site_settings_controller.rb @@ -35,7 +35,7 @@ def index render_data data: site_settings, status: :ok end - # GET /api/v1/admin/site_settings/:name.json + # PATCH /api/v1/admin/site_settings/:name.json # Updates the value of the specified Site Setting def update site_setting = SiteSetting.joins(:setting) diff --git a/app/javascript/hooks/mutations/admin/site_settings/useUpdateSiteSetting.jsx b/app/javascript/hooks/mutations/admin/site_settings/useUpdateSiteSetting.jsx index 0fb1a45285..c956b52404 100644 --- a/app/javascript/hooks/mutations/admin/site_settings/useUpdateSiteSetting.jsx +++ b/app/javascript/hooks/mutations/admin/site_settings/useUpdateSiteSetting.jsx @@ -35,7 +35,11 @@ export default function useUpdateSiteSetting(name) { settings = data; } - return axios.patch(`/admin/site_settings/${name}.json`, settings); + return axios.patch(`/admin/site_settings/${name}.json`, settings, { + headers: { + 'Content-Type': 'multipart/form-data', + }, + }); }; const handleSuccess = () => { diff --git a/app/javascript/hooks/mutations/rooms/useUploadPresentation.jsx b/app/javascript/hooks/mutations/rooms/useUploadPresentation.jsx index 4830574d16..3f5e0e2c75 100644 --- a/app/javascript/hooks/mutations/rooms/useUploadPresentation.jsx +++ b/app/javascript/hooks/mutations/rooms/useUploadPresentation.jsx @@ -28,7 +28,11 @@ export default function useUploadPresentation(friendlyId) { fileValidation(presentation, 'presentation'); const formData = new FormData(); formData.append('room[presentation]', presentation); - return axios.patch(`/rooms/${friendlyId}.json`, formData); + return axios.patch(`/rooms/${friendlyId}.json`, formData, { + headers: { + 'Content-Type': 'multipart/form-data', + }, + }); }; const mutation = useMutation(uploadPresentation, { diff --git a/app/javascript/hooks/mutations/users/useCreateAvatar.jsx b/app/javascript/hooks/mutations/users/useCreateAvatar.jsx index ab4baf77c6..106ade8fd9 100644 --- a/app/javascript/hooks/mutations/users/useCreateAvatar.jsx +++ b/app/javascript/hooks/mutations/users/useCreateAvatar.jsx @@ -30,7 +30,11 @@ export default function useCreateAvatar(currentUser) { }); const formData = new FormData(); formData.append('user[avatar]', avatarBlob); - return axios.patch(`/users/${currentUser.id}.json`, formData); + return axios.patch(`/users/${currentUser.id}.json`, formData, { + headers: { + 'Content-Type': 'multipart/form-data', + }, + }); } const mutation = useMutation(