diff --git a/src/actions/index.js b/src/actions/index.js index ad73a82..b59ffc8 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -22,8 +22,8 @@ axios.interceptors.response.use( }) resolve(response) } - throw error - }) + throw error; + }) }); const autocomplete = (input) => { diff --git a/src/components/Input/ImageUpload.js b/src/components/Input/ImageUpload.js index cb39153..03c413a 100644 --- a/src/components/Input/ImageUpload.js +++ b/src/components/Input/ImageUpload.js @@ -30,15 +30,28 @@ export default function ImageUpload(props) { setLoading(false); }) .catch((error) => { - dispatch(notification("Błąd wysyłania. Sprawdź rozmiar pliku (max 3MB.)", "error")) + if (error.response) { + if (error.response.status === 413) { + dispatch(notification("Błąd wysyłania. Sprawdź rozmiar pliku (max 2MB.)", "error")) + } else if (error.response.status === 401) { + dispatch(notification("Błąd wysyłania. Brak dostępu.", "error")) + } else { + dispatch(notification("Błąd wysyłania. Serwer odrzucił plik.", "error")) + } setLoading(false); - throw error; + } else if (error.request) { + dispatch(notification("Błąd wysyłania. Brak odpowiedzi od serwera.", "error")) + setLoading(false); + } else { + dispatch(notification("Błąd wysyłania.", "error")) + setLoading(false); + } }); }; let imagePreview = (