Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion src/actions/sponsor-forms-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const RECEIVE_SPONSOR_MANAGED_FORMS = "RECEIVE_SPONSOR_MANAGED_FORMS";
export const REQUEST_SPONSOR_MANAGED_FORM = "REQUEST_SPONSOR_MANAGED_FORM";
export const RECEIVE_SPONSOR_MANAGED_FORM = "RECEIVE_SPONSOR_MANAGED_FORM";
export const SPONSOR_MANAGED_FORMS_ADDED = "SPONSOR_MANAGED_FORMS_ADDED";
export const SPONSOR_MANAGED_FORM_DELETED = "SPONSOR_MANAGED_FORM_DELETED";
export const SPONSOR_MANAGED_FORMS_UPGRADED = "SPONSOR_MANAGED_FORMS_UPGRADED";
export const SPONSOR_MANAGED_FORMS_OVERRIDEN =
"SPONSOR_MANAGED_FORMS_OVERRIDEN";
Expand Down Expand Up @@ -564,7 +565,7 @@ export const getSponsorManagedForms =
const params = {
page,
fields:
"id,code,name,is_archived,opens_at,expires_at,items_count,allowed_add_ons",
"id,code,name,is_archived,opens_at,expires_at,items_count,allowed_add_ons,assignment_type",
expands: "allowed_add_ons",
per_page: perPage,
access_token: accessToken
Expand Down Expand Up @@ -689,6 +690,38 @@ export const upgradeSponsorManagedForm =
});
};

export const deleteSponsorManagedForm =
(formId) => async (dispatch, getState) => {
const { currentSummitState, currentSponsorState } = getState();
const { currentSummit } = currentSummitState;
const {
entity: { id: sponsorId }
} = currentSponsorState;
const accessToken = await getAccessTokenSafely();
const params = { access_token: accessToken };

dispatch(startLoading());

return deleteRequest(
null,
createAction(SPONSOR_MANAGED_FORM_DELETED)({ formId }),
`${window.PURCHASES_API_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsorId}/managed-forms/${formId}`,
null,
snackbarErrorHandler
)(params)(dispatch)
.then(() => {
dispatch(
snackbarSuccessHandler({
title: T.translate("general.success"),
html: T.translate("sponsor_forms.form_delete_success")
})
);
})
.finally(() => {
dispatch(stopLoading());
});
};

const normalizeSponsorManagedForm = (entity) => {
const normalizedEntity = {
show_form_ids: entity.forms,
Expand Down
Loading
Loading