Skip to content

Commit

Permalink
fix(admin-ui): show error message on api failure
Browse files Browse the repository at this point in the history
Signed-off-by: Jeet Viramgama <jviramgama5@gmail.com>
  • Loading branch information
jv18creator committed Nov 7, 2023
1 parent b3e1ffd commit 00a1236
Showing 1 changed file with 11 additions and 6 deletions.
17 changes: 11 additions & 6 deletions admin-ui/plugins/admin/redux/sagas/ApiPermissionSaga.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export function* addPermission({ payload }) {
return data
} catch (e) {
yield put(updateToast(true, 'error'))
yield put(addPermissionResponse(null))
yield put(addPermissionResponse({ data: null }))
if (isFourZeroOneError(e)) {
const jwt = yield select((state) => state.authReducer.userinfo_jwt)
yield put(getAPIAccessToken(jwt))
Expand All @@ -94,19 +94,24 @@ export function* editPermission({ payload }) {
try {
addAdditionalData(audit, UPDATE, API_PERMISSION, payload)
const permApi = yield* newFunction()
const data = yield call(permApi.editPermission, payload.action.action_data)
const editPayload = { ...payload?.action?.action_data }
if (editPayload?.tableData) {
delete editPayload.tableData
}
const data = yield call(permApi.editPermission, editPayload)
yield put(updateToast(true, 'success'))
yield put(editPermissionResponse({ data }))
yield call(postUserAction, audit)
return data
} catch (e) {
yield put(updateToast(true, 'error'))
yield put(editPermissionResponse(null))
const errorMessage = e?.response?.body?.responseMessage || e.message
yield put(updateToast(true, 'error', errorMessage))
yield put(editPermissionResponse({ data: null }))
if (isFourZeroOneError(e)) {
const jwt = yield select((state) => state.authReducer.userinfo_jwt)
yield put(getAPIAccessToken(jwt))
}
return data
return e
}
}

Expand All @@ -123,7 +128,7 @@ export function* deletePermission({ payload }) {
return data
} catch (e) {
yield put(updateToast(true, 'error'))
yield put(deletePermissionResponse(null))
yield put(deletePermissionResponse({ inum: null }))
if (isFourZeroOneError(e)) {
const jwt = yield select((state) => state.authReducer.userinfo_jwt)
yield put(getAPIAccessToken(jwt))
Expand Down

0 comments on commit 00a1236

Please sign in to comment.