fix: show the error message received from the server when sending test email fails (#11972)

This commit is contained in:
akash-codemonk 2022-03-24 16:50:43 +05:30 committed by GitHub
parent a486474483
commit 7443c16e59
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -110,34 +110,32 @@ function* SendTestEmail(action: ReduxAction<SendTestEmailPayload>) {
try { try {
const response = yield call(UserApi.sendTestEmail, action.payload); const response = yield call(UserApi.sendTestEmail, action.payload);
const currentUser = yield select(getCurrentUser); const currentUser = yield select(getCurrentUser);
let actionElement; const isValidResponse = yield validateResponse(response);
if (response.data) {
actionElement = ( if (isValidResponse) {
<> let actionElement;
<br /> if (response.data) {
<span onClick={() => window.open(EMAIL_SETUP_DOC, "blank")}> actionElement = (
{createMessage(TEST_EMAIL_SUCCESS_TROUBLESHOOT)} <>
</span> <br />
</> <span onClick={() => window.open(EMAIL_SETUP_DOC, "blank")}>
); {createMessage(TEST_EMAIL_SUCCESS_TROUBLESHOOT)}
</span>
</>
);
}
Toaster.show({
actionElement,
text: createMessage(
response.data
? TEST_EMAIL_SUCCESS(currentUser?.email)
: TEST_EMAIL_FAILURE,
),
hideProgressBar: true,
variant: response.data ? Variant.info : Variant.danger,
});
} }
Toaster.show({ } catch (e) {}
actionElement,
text: createMessage(
response.data
? TEST_EMAIL_SUCCESS(currentUser?.email)
: TEST_EMAIL_FAILURE,
),
hideProgressBar: true,
variant: response.data ? Variant.info : Variant.danger,
});
} catch (e) {
Toaster.show({
text: e?.message || createMessage(TEST_EMAIL_FAILURE),
hideProgressBar: true,
variant: Variant.danger,
});
}
} }
function* InitSuperUserSaga(action: ReduxAction<User>) { function* InitSuperUserSaga(action: ReduxAction<User>) {