From 82a8a8d6e58318fe679a6f390a732cb756d32235 Mon Sep 17 00:00:00 2001 From: Jan Naahs Date: Sat, 24 Oct 2020 12:25:30 +0200 Subject: [PATCH] refactoring save upload to match mod upload --- ui/App/views/Saves/components/UploadSaveForm.jsx | 7 +++---- ui/api/resources/saves.js | 4 ++-- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/ui/App/views/Saves/components/UploadSaveForm.jsx b/ui/App/views/Saves/components/UploadSaveForm.jsx index ff75fa0..89eb10c 100644 --- a/ui/App/views/Saves/components/UploadSaveForm.jsx +++ b/ui/App/views/Saves/components/UploadSaveForm.jsx @@ -8,12 +8,11 @@ const UploadSaveForm = ({onSuccess}) => { const {register, handleSubmit, errors} = useForm(); const [fileName, setFileName] = useState('Select File ...'); - const onSubmit = async (data, e) => { - const res = await saves.upload(data.savefile); - if (res.success) { + const onSubmit = (data, e) => { + saves.upload(data.savefile[0]).then(_ => { e.target.reset(); onSuccess(); - } + }) }; return ( diff --git a/ui/api/resources/saves.js b/ui/api/resources/saves.js index 7459f13..d0cd79f 100644 --- a/ui/api/resources/saves.js +++ b/ui/api/resources/saves.js @@ -13,9 +13,9 @@ export default { const response = await client.get(`/api/saves/create/${name}`); return response.data; }, - upload: async (data) => { + upload: async file => { let formData = new FormData(); - formData.append("savefile", data[0]); + formData.append("savefile", file); const response = await client.post(`/api/saves/upload`, formData, { headers: {