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