|
1 | 1 | import * as CONSTANTS from "assets/constants/overviewConstants"; |
2 | 2 | import * as TYPES from "./types"; |
3 | 3 |
|
| 4 | +import { DANGER, ERROR_MSG } from "assets/constants/toastConstants"; |
| 5 | + |
4 | 6 | import API from "../utils/axiosInstance"; |
5 | | -import { DANGER } from "assets/constants/toastConstants"; |
6 | 7 | import { expandUriTemplate } from "../utils/helper"; |
7 | 8 | import { findNoOfDays } from "utils/dateFunctions"; |
8 | 9 | import { showToast } from "./toastActions"; |
@@ -41,7 +42,7 @@ export const getDatasets = () => async (dispatch, getState) => { |
41 | 42 | } |
42 | 43 | } |
43 | 44 | } catch (error) { |
44 | | - dispatch(showToast(DANGER, error?.response?.data?.message)); |
| 45 | + dispatch(showToast(DANGER, error?.response?.data?.message ?? ERROR_MSG)); |
45 | 46 | dispatch({ type: TYPES.NETWORK_ERROR }); |
46 | 47 | } |
47 | 48 | if (alreadyRendered) { |
@@ -135,8 +136,20 @@ export const updateDataset = |
135 | 136 | payload: runs, |
136 | 137 | }); |
137 | 138 | dispatch(initializeRuns()); |
| 139 | + |
| 140 | + const errors = response.data?.errors; |
| 141 | + if (errors && Object.keys(errors).length > 0) { |
| 142 | + let errorText = ""; |
| 143 | + |
| 144 | + for (const [key, value] of Object.entries(errors)) { |
| 145 | + errorText += `${key} : ${value} \n`; |
| 146 | + } |
| 147 | + dispatch( |
| 148 | + showToast("warning", "Problem updating metadata", errorText) |
| 149 | + ); |
| 150 | + } |
138 | 151 | } else { |
139 | | - dispatch(showToast(DANGER, response?.data?.errors)); |
| 152 | + dispatch(showToast(DANGER, response?.data?.message ?? ERROR_MSG)); |
140 | 153 | } |
141 | 154 | } catch (error) { |
142 | 155 | dispatch(showToast(DANGER, error?.response?.data?.message)); |
@@ -173,7 +186,7 @@ export const deleteDataset = (dataset) => async (dispatch, getState) => { |
173 | 186 | dispatch(showToast(CONSTANTS.SUCCESS, "Deleted!")); |
174 | 187 | } |
175 | 188 | } catch (error) { |
176 | | - dispatch(showToast(DANGER, error?.response?.data?.message)); |
| 189 | + dispatch(showToast(DANGER, error?.response?.data?.message ?? ERROR_MSG)); |
177 | 190 | dispatch({ type: TYPES.NETWORK_ERROR }); |
178 | 191 | } |
179 | 192 | dispatch({ type: TYPES.COMPLETED }); |
@@ -245,7 +258,7 @@ export const publishDataset = |
245 | 258 | dispatch(showToast(CONSTANTS.SUCCESS, "Updated!")); |
246 | 259 | } |
247 | 260 | } catch (error) { |
248 | | - dispatch(showToast(DANGER, error?.response?.data?.message)); |
| 261 | + dispatch(showToast(DANGER, error?.response?.data?.message ?? ERROR_MSG)); |
249 | 262 | dispatch({ type: TYPES.NETWORK_ERROR }); |
250 | 263 | } |
251 | 264 | dispatch({ type: TYPES.COMPLETED }); |
|
0 commit comments