image upload broken

This commit is contained in:
2020-12-06 22:58:09 +01:00
parent be55d34c03
commit e43fa02ead

View File

@@ -1,10 +1,12 @@
import React, { useState } from "react";
import CircularProgress from "@material-ui/core/CircularProgress";
import { useSelector } from "react-redux";
import { useSelector, useDispatch } from "react-redux";
import axios from "axios";
import { backend } from "../../config";
import { notification } from "../../actions/index";
export default function ImageUpload(props) {
const dispatch = useDispatch();
const { img } = props;
const [loading, setLoading] = useState(false);
const token = useSelector((state) => state.data.userData.jwt);
@@ -28,15 +30,15 @@ export default function ImageUpload(props) {
setLoading(false);
})
.catch((error) => {
console.log("Wystąpił błąd podczas wgrywania pliku.");
setLoading(false);
throw error;
dispatch(notification("Błąd wysyłania. Sprawdź rozmiar pliku (max 3MB.)", "error"))
setLoading(false);
throw error;
});
};
let imagePreview = (
<div className="image-preview">
{loading ? <CircularProgress /> : "Proszę wybrać obraz. (max. 2MB)"}
{loading ? <CircularProgress /> : "Proszę wybrać obraz. (max. 3MB)"}
</div>
);
if (img) {