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
50 changes: 22 additions & 28 deletions src/actions/inventory-item-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -233,23 +233,20 @@ export const saveInventoryItem = (entity) => async (dispatch) => {
promises.push(saveItemMetaFieldTypes(normalizedEntity)(dispatch));
}

Promise.all(promises)
.then(() => {
dispatch(
showSuccessMessage(
T.translate("edit_inventory_item.inventory_item_saved")
)
);
})
.catch((err) => {
console.error(err);
})
.finally(() => {
dispatch(stopLoading());
});
return Promise.all(promises).then(() => {
dispatch(
showSuccessMessage(
T.translate("edit_inventory_item.inventory_item_saved")
)
);
});
})
.catch((err) => {
console.error(err);
throw err;
Comment thread
tomrndom marked this conversation as resolved.
})
.finally(() => {
dispatch(stopLoading());
});
}

Expand Down Expand Up @@ -279,23 +276,20 @@ export const saveInventoryItem = (entity) => async (dispatch) => {
promises.push(saveItemMetaFieldTypes(inventoryItem)(dispatch));
}

Promise.all(promises)
.then(() => {
dispatch(
showMessage(success_message, () => {
history.push("/app/inventory");
})
);
})
.catch((err) => {
console.error(err);
})
.finally(() => {
dispatch(stopLoading());
});
return Promise.all(promises).then(() => {
dispatch(
showMessage(success_message, () => {
history.push("/app/inventory");
})
);
});
})
.catch((err) => {
console.error(err);
throw err;
})
.finally(() => {
dispatch(stopLoading());
});
};

Expand Down
2 changes: 0 additions & 2 deletions src/actions/page-template-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,6 @@ export const savePageTemplate = (entity) => async (dispatch) => {
html: T.translate("page_template_list.page_crud.page_saved")
})
);
getPageTemplates()(dispatch);
})
.catch((err) => {
console.error(err);
Expand All @@ -200,7 +199,6 @@ export const savePageTemplate = (entity) => async (dispatch) => {
html: T.translate("page_template_list.page_crud.page_created")
})
);
getPageTemplates()(dispatch);
})
.catch((err) => {
console.error(err);
Expand Down
36 changes: 18 additions & 18 deletions src/actions/sponsor-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1128,7 +1128,7 @@ export const saveSummitSponsorship = (entity) => async (dispatch, getState) => {
const normalizedEntity = normalizeSponsorship(entity);

if (entity.id) {
putRequest(
return putRequest(
createAction(UPDATE_SUMMIT_SPONSORSHIP),
createAction(SUMMIT_SPONSORSHIP_UPDATED),
`${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/sponsorships-types/${entity.id}`,
Expand All @@ -1140,24 +1140,24 @@ export const saveSummitSponsorship = (entity) => async (dispatch, getState) => {
showSuccessMessage(T.translate("edit_sponsorship.sponsorship_saved"))
);
});
} else {
const success_message = {
title: T.translate("general.done"),
html: T.translate("edit_sponsorship.sponsorship_created"),
type: "success"
};

postRequest(
createAction(UPDATE_SUMMIT_SPONSORSHIP),
createAction(SUMMIT_SPONSORSHIP_ADDED),
`${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/sponsorships-types`,
normalizedEntity,
authErrorHandler,
entity
)(params)(dispatch).then(() => {
dispatch(showMessage(success_message));
});
}

const success_message = {
title: T.translate("general.done"),
html: T.translate("edit_sponsorship.sponsorship_created"),
type: "success"
};

return postRequest(
createAction(UPDATE_SUMMIT_SPONSORSHIP),
createAction(SUMMIT_SPONSORSHIP_ADDED),
`${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/sponsorships-types`,
normalizedEntity,
authErrorHandler,
entity
)(params)(dispatch).then(() => {
dispatch(showMessage(success_message));
});
};

export const uploadSponsorshipBadgeImage =
Expand Down
8 changes: 6 additions & 2 deletions src/actions/sponsor-forms-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1322,7 +1322,9 @@ export const updateSponsorFormItem =
);
});
})
.catch(console.log) // need to catch promise reject
.catch((err) => {
throw err;
})
.finally(() => {
dispatch(stopLoading());
});
Expand Down Expand Up @@ -1457,7 +1459,9 @@ export const addInventoryItems =
})
);
})
.catch(console.log) // need to catch promise reject
.catch((err) => {
throw err;
})
.finally(() => {
dispatch(stopLoading());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import SearchInput from "openstack-uicore-foundation/lib/components/mui/search-i
import MenuButton from "../../../components/mui/menu-button";

const FormTemplateFromDuplicateDialog = ({
open,
options,
onClose,
onDuplicate,
Expand Down Expand Up @@ -94,7 +93,7 @@ const FormTemplateFromDuplicateDialog = ({
];

return (
<Dialog open={open} onClose={handleClose} maxWidth="md" fullWidth>
<Dialog open onClose={handleClose} maxWidth="md" fullWidth>
<DialogTitle sx={{ display: "flex", justifyContent: "space-between" }}>
<Typography fontSize="1.5rem">
{T.translate("form_template_from_duplicate_dialog.duplicate_form")}
Expand Down Expand Up @@ -176,7 +175,6 @@ const FormTemplateFromDuplicateDialog = ({
};

FormTemplateFromDuplicateDialog.propTypes = {
open: PropTypes.bool.isRequired,
onClose: PropTypes.func.isRequired,
onDuplicate: PropTypes.func.isRequired,
onSearch: PropTypes.func.isRequired,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ const FormTemplateItemListPage = ({
);
};

const handleFormTemplateSave = (item) => {
const handleFormTemplateSave = (item) =>
saveFormTemplateItem(formTemplateId, item).then(() =>
getFormTemplateItems(
formTemplateId,
Expand All @@ -184,10 +184,8 @@ const FormTemplateItemListPage = ({
order,
orderDir,
showArchived
)
).catch(() => {})
);
setShowInventoryItemModal(false);
};

const columns = [
{
Expand Down
77 changes: 42 additions & 35 deletions src/pages/sponsors-global/form-templates/form-template-list-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,11 @@ const FormTemplateListPage = ({
setFormTemplateFromDuplicatePopupOpen(false);
};

const handleCloseFormTemplateDialog = () => {
resetFormTemplateForm();
setFormTemplatePopupOpen(false);
};

const handleDuplicatePopupClose = () => {
getFormTemplates(
"",
Expand Down Expand Up @@ -212,17 +217,17 @@ const FormTemplateListPage = ({
sortDir: orderDir
};

const handleOnSave = async (values) => {
await saveFormTemplate(values);
getFormTemplates(
"",
DEFAULT_CURRENT_PAGE,
perPage,
order,
orderDir,
showArchived
const handleOnSave = (values) =>
saveFormTemplate(values).then(() =>
getFormTemplates(
"",
DEFAULT_CURRENT_PAGE,
perPage,
order,
orderDir,
showArchived
).catch(() => {})
);
};

return (
<div className="container">
Expand Down Expand Up @@ -330,31 +335,33 @@ const FormTemplateListPage = ({
/>
</div>
)}
<FormTemplateDialog
entity={currentFormTemplate}
errors={currentFormTemplateErrors}
open={formTemplatePopupOpen}
onSave={handleOnSave}
toDuplicate={formTemplateDuplicate}
onClose={() => setFormTemplatePopupOpen(false)}
onMetaFieldTypeDeleted={deleteFormTemplateMetaFieldType}
onMetaFieldTypeValueDeleted={deleteFormTemplateMetaFieldTypeValue}
onMaterialDeleted={deleteFormTemplateMaterial}
/>
<FormTemplateFromDuplicateDialog
open={formTemplateFromDuplicatePopupOpen}
options={tableOptions}
onClose={handleDuplicatePopupClose}
onDuplicate={handleDuplicateForm}
onSearch={handleSearch}
onSort={handleSort}
perPage={perPage}
currentPage={currentPage}
totalRows={totalFormTemplates}
onPageChange={handlePageChange}
onPerPageChange={handlePerPageChange}
formTemplates={formTemplates}
/>
{formTemplatePopupOpen && (
<FormTemplateDialog
entity={currentFormTemplate}
errors={currentFormTemplateErrors}
onSave={handleOnSave}
toDuplicate={formTemplateDuplicate}
onClose={handleCloseFormTemplateDialog}
onMetaFieldTypeDeleted={deleteFormTemplateMetaFieldType}
onMetaFieldTypeValueDeleted={deleteFormTemplateMetaFieldTypeValue}
onMaterialDeleted={deleteFormTemplateMaterial}
/>
)}
{formTemplateFromDuplicatePopupOpen && (
<FormTemplateFromDuplicateDialog
options={tableOptions}
onClose={handleDuplicatePopupClose}
onDuplicate={handleDuplicateForm}
onSearch={handleSearch}
onSort={handleSort}
perPage={perPage}
currentPage={currentPage}
totalRows={totalFormTemplates}
onPageChange={handlePageChange}
onPerPageChange={handlePerPageChange}
formTemplates={formTemplates}
/>
)}
</div>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import {
} from "../../../utils/yup";

const FormTemplateDialog = ({
open,
onClose,
onSave,
toDuplicate = false,
Expand Down Expand Up @@ -74,9 +73,9 @@ const FormTemplateDialog = ({
if (isSaving) return;

setIsSaving(true);
Promise.resolve(onSave(finalValues))
onSave(finalValues)
Comment thread
tomrndom marked this conversation as resolved.
.then(() => {
closePopup();
onClose();
})
.catch(() => {
// keep dialog open on save error to preserve user input
Expand All @@ -96,7 +95,7 @@ const FormTemplateDialog = ({

return (
<Dialog
open={open}
open
onClose={handleClose}
maxWidth="md"
fullWidth
Expand Down Expand Up @@ -197,7 +196,6 @@ const FormTemplateDialog = ({
};

FormTemplateDialog.propTypes = {
open: PropTypes.bool.isRequired,
onClose: PropTypes.func.isRequired,
onSave: PropTypes.func.isRequired,
entity: PropTypes.object
Expand Down
Loading
Loading