Skip to content
5 changes: 3 additions & 2 deletions src/actions/sponsor-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import {
fetchErrorHandler,
postFile
} from "openstack-uicore-foundation/lib/utils/actions";
import debounce from "lodash/debounce"
import debounce from "lodash/debounce";
import URI from "urijs";
import { getAccessTokenSafely } from "../utils/methods";
import { normalizeLeadReportSettings } from "../models/lead-report-settings";
Expand Down Expand Up @@ -195,7 +195,8 @@ export const querySponsors = debounce(async (input, summitId, callback) => {
.then((json) => {
const options = [...json.data].map((sp) => ({
id: sp.id,
name: sp.company.name
name: sp.company.name,
companyId: sp.company.id
}));
callback(options);
})
Expand Down
74 changes: 38 additions & 36 deletions src/actions/sponsor-users-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -504,46 +504,48 @@ export const deleteSponsorUser =

/** **************** SPONSOR USERS TAB *************************************** */

export const sendSponsorUserInvite = (email) => async (dispatch, getState) => {
const { currentSummitState, currentSponsorState } = getState();
const accessToken = await getAccessTokenSafely();
const { currentSummit } = currentSummitState;
const { entity } = currentSponsorState;
export const sendSponsorUserInvite =
(email, sponsorId = null) =>
async (dispatch, getState) => {
const { currentSummitState, currentSponsorState } = getState();
const accessToken = await getAccessTokenSafely();
const { currentSummit } = currentSummitState;
const { entity } = currentSponsorState;

const params = {
access_token: accessToken
};
const params = {
access_token: accessToken
};

dispatch(startLoading());
dispatch(startLoading());

const payload = {
user_email: email,
sponsor_id: entity.id,
summit_id: currentSummit.id
};
const payload = {
user_email: email,
sponsor_id: sponsorId || entity.id,
summit_id: currentSummit.id
};

return postRequest(
null,
createAction(DUMMY_ACTION),
`${window.SPONSOR_USERS_API_URL}/api/v1/sponsor-users`,
payload,
snackbarErrorHandler,
entity
)(params)(dispatch)
.then(() => {
dispatch(stopLoading());
dispatch(
snackbarSuccessHandler({
title: T.translate("general.success"),
html: T.translate("sponsor_users.new_user.success")
})
);
})
.catch(console.log) // need to catch promise reject
.finally(() => {
dispatch(stopLoading());
});
};
return postRequest(
null,
createAction(DUMMY_ACTION),
`${window.SPONSOR_USERS_API_URL}/api/v1/sponsor-users`,
payload,
snackbarErrorHandler,
entity
)(params)(dispatch)
Comment on lines +525 to +532

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tomrndom Confirmed. I traced postRequest's internal handler (oe in the minified openstack-uicore-foundation bundle) — on error it dispatches the error handler and calls reject(...), so removing the .catch(console.log) here does make the returned promise reject on failure where it previously always resolved. new-user-popup.js:38 (sendSponsorUserInvite(values.email).finally(...)) has no .catch(), so a failed invite from that (untouched) screen will now surface as an unhandled promise rejection. Needs a .catch() added there (or a rethrow-and-log wrapper kept in the action) as part of this PR, since it's the one changing the contract.

.then(() => {
dispatch(stopLoading());
Comment thread
smarcet marked this conversation as resolved.
Outdated
dispatch(
snackbarSuccessHandler({
title: T.translate("general.success"),
html: T.translate("sponsor_users.new_user.success")
})
);
})
.catch(console.log) // need to catch promise reject
Comment thread
tomrndom marked this conversation as resolved.
Outdated
.finally(() => {
dispatch(stopLoading());
});
Comment thread
smarcet marked this conversation as resolved.
};

export const fetchSponsorUsersBySummit = async (
currentSummitId,
Expand Down
Loading
Loading