mirror of
https://github.com/OpenFactorioServerManager/factorio-server-manager.git
synced 2024-12-31 03:11:17 +02:00
refactoring save upload to match mod upload
This commit is contained in:
parent
a0952f7301
commit
82a8a8d6e5
@ -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 (
|
||||
|
@ -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: {
|
||||
|
Loading…
Reference in New Issue
Block a user