Skip to content
Snippets Groups Projects
Commit a264cde7 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

when there is a problem with data when adding overlay show toast

parent 49b4c6fb
No related branches found
No related tags found
2 merge requests!264Resolve "add support for matomo",!245Resolve "Displaying a prompt message when uploading wrong format of overlay"
...@@ -15,6 +15,7 @@ import { showToast } from '@/utils/showToast'; ...@@ -15,6 +15,7 @@ import { showToast } from '@/utils/showToast';
import { ThunkConfig } from '@/types/store'; import { ThunkConfig } from '@/types/store';
import { BASE_API_URL } from '@/constants'; import { BASE_API_URL } from '@/constants';
import { getError } from '@/utils/error-report/getError'; import { getError } from '@/utils/error-report/getError';
import axios from 'axios';
import { apiPath } from '../apiPath'; import { apiPath } from '../apiPath';
import { import {
CHUNK_SIZE, CHUNK_SIZE,
...@@ -221,7 +222,12 @@ export const addOverlay = createAsyncThunk<undefined, AddOverlayArgs, ThunkConfi ...@@ -221,7 +222,12 @@ export const addOverlay = createAsyncThunk<undefined, AddOverlayArgs, ThunkConfi
showToast({ type: 'success', message: USER_OVERLAY_ADD_SUCCESS_MESSAGE }); showToast({ type: 'success', message: USER_OVERLAY_ADD_SUCCESS_MESSAGE });
} catch (error) { } catch (error) {
return Promise.reject(getError({ error, prefix: USER_OVERLAY_ADD_ERROR_PREFIX })); if (axios.isAxiosError(error) && error.code === 'ERR_BAD_REQUEST') {
const data = error.response?.data;
showToast({ type: 'error', message: data.reason, duration: 120000 });
} else {
return Promise.reject(getError({ error, prefix: USER_OVERLAY_ADD_ERROR_PREFIX }));
}
} }
}, },
); );
......
...@@ -16,7 +16,7 @@ export const Toast = ({ type, message, onDismiss }: ToastArgs): React.ReactNode ...@@ -16,7 +16,7 @@ export const Toast = ({ type, message, onDismiss }: ToastArgs): React.ReactNode
> >
<p <p
className={twMerge( className={twMerge(
'text-base font-bold ', 'h-full overflow-y-auto text-base font-bold',
type === 'error' ? 'text-red-500' : 'text-green-500', type === 'error' ? 'text-red-500' : 'text-green-500',
)} )}
> >
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment