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
25 changes: 11 additions & 14 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;
})
.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 @@ -174,7 +174,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 @@ -199,7 +198,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
8 changes: 4 additions & 4 deletions src/actions/sponsor-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -1126,7 +1126,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 @@ -1138,14 +1138,14 @@ 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(
return postRequest(
createAction(UPDATE_SUMMIT_SPONSORSHIP),
createAction(SUMMIT_SPONSORSHIP_ADDED),
`${window.API_BASE_URL}/api/v1/summits/${currentSummit.id}/sponsorships-types`,
Expand All @@ -1155,7 +1155,7 @@ export const saveSummitSponsorship = (entity) => async (dispatch, getState) => {
)(params)(dispatch).then(() => {
dispatch(showMessage(success_message));
});
}

};

export const uploadSponsorshipBadgeImage =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ const FormTemplateItemListPage = ({
);
};

const handleFormTemplateSave = (item) => {
const handleFormTemplateSave = (item) =>
saveFormTemplateItem(formTemplateId, item).then(() =>
getFormTemplateItems(
formTemplateId,
Expand All @@ -189,8 +189,6 @@ const FormTemplateItemListPage = ({
showArchived
)
);
setShowInventoryItemModal(false);
};

const columns = [
{
Expand Down
20 changes: 10 additions & 10 deletions src/pages/sponsors-global/form-templates/form-template-list-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,17 +212,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
)
);
};

return (
<div className="container">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,9 @@ const FormTemplateDialog = ({
if (isSaving) return;

setIsSaving(true);
Promise.resolve(onSave(finalValues))
onSave(finalValues)
.then(() => {
closePopup();
onClose();
})
.catch(() => {
// keep dialog open on save error to preserve user input
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ const SponsorItemDialog = ({
onMetaFieldTypeValueDeleted,
entity: initialEntity
}) => {
const [isSaving, setIsSaving] = useState(false);

const formik = useFormik({
initialValues: {
...initialEntity,
Expand All @@ -65,7 +67,13 @@ const SponsorItemDialog = ({
quantity_limit_per_show: positiveNumberValidation(),
meta_fields: formMetafieldsValidation()
}),
onSubmit: (values) => onSave(values)
onSubmit: (values) => {
if (isSaving) return;
setIsSaving(true);
onSave(values)
.then(() => onClose())
.finally(() => setIsSaving(false));
}
});

const mediaType = {
Expand All @@ -79,6 +87,7 @@ const SponsorItemDialog = ({
useScrollToError(formik);

const handleClose = () => {
if (isSaving) return;
formik.resetForm();
onClose();
};
Expand All @@ -92,12 +101,18 @@ const SponsorItemDialog = ({
disableEnforceFocus
disableAutoFocus
disableRestoreFocus
disableEscapeKeyDown={isSaving}
>
<DialogTitle sx={{ display: "flex", justifyContent: "space-between" }}>
{initialEntity.id
? T.translate("edit_inventory_item.edit_item")
: T.translate("edit_inventory_item.new_item")}
<IconButton size="small" onClick={handleClose} sx={{ mr: 1 }}>
<IconButton
size="small"
onClick={handleClose}
sx={{ mr: 1 }}
disabled={isSaving}
>
<CloseIcon fontSize="small" />
</IconButton>
</DialogTitle>
Expand Down Expand Up @@ -227,7 +242,12 @@ const SponsorItemDialog = ({
</DialogContent>
<Divider />
<DialogActions>
<Button type="submit" fullWidth variant="contained">
<Button
type="submit"
fullWidth
variant="contained"
disabled={isSaving}
>
{T.translate("edit_inventory_item.save_changes")}
</Button>
</DialogActions>
Expand Down
23 changes: 10 additions & 13 deletions src/pages/sponsors-global/inventory/inventory-list-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -246,20 +246,17 @@ const InventoryListPage = ({
setOpen(true);
};

const handleInventorySave = (item) => {
saveInventoryItem(item)
.then(() =>
getInventoryItems(
term,
currentPage,
perPage,
order,
orderDir,
showArchived
)
const handleInventorySave = (item) =>
saveInventoryItem(item).then(() =>
getInventoryItems(
term,
currentPage,
perPage,
order,
orderDir,
showArchived
)
.finally(() => setOpen(false));
};
);
Comment thread
coderabbitai[bot] marked this conversation as resolved.

const handleArchiveItem = (item) =>
item.is_archived
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,17 @@ const PageTemplateListPage = ({
setOpenCloneDialog(true);
};

const handleSavePageTemplate = (entity) => {
savePageTemplate(entity).then(() => setOpenPageDialog(false));
};
const handleSavePageTemplate = (entity) =>
savePageTemplate(entity).then(() =>
getPageTemplates(
term,
DEFAULT_CURRENT_PAGE,
perPage,
order,
orderDir,
showArchived
)
);
Comment thread
coderabbitai[bot] marked this conversation as resolved.

const handleArchive = (item) =>
item.is_archived
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from "react";
import React, { useState } from "react";
import T from "i18n-react/dist/i18n-react";
import PropTypes from "prop-types";
import {
Expand Down Expand Up @@ -43,6 +43,7 @@ const PageTemplatePopup = ({
sponsorshipIds,
title
}) => {
const [isSaving, setIsSaving] = useState(false);
const popupTitle =
title ??
(pageTemplate?.id
Expand Down Expand Up @@ -129,14 +130,17 @@ const PageTemplatePopup = ({
}),
modules: yup.array().of(moduleSchema)
}),
enableReinitialize: true,
onSubmit: (values) => {
if (isSaving) return;
setIsSaving(true);
const modulesWithOrder = values.modules.map((m, idx) => ({
...m,
custom_order: idx
}));

onSave({ ...values, modules: modulesWithOrder });
onSave({ ...values, modules: modulesWithOrder })
.then(() => onClose())
.finally(() => setIsSaving(false));
}
});

Expand Down Expand Up @@ -179,11 +183,27 @@ const PageTemplatePopup = ({
});
};

const handleClose = () => {
if (isSaving) return;
onClose();
};

return (
<Dialog open onClose={onClose} maxWidth="md" fullWidth>
<Dialog
open
onClose={handleClose}
maxWidth="md"
fullWidth
disableEscapeKeyDown={isSaving}
>
<DialogTitle sx={{ display: "flex", justifyContent: "space-between" }}>
<Typography fontSize="1.5rem">{popupTitle}</Typography>
<IconButton size="small" onClick={onClose} sx={{ mr: 1 }}>
<IconButton
size="small"
onClick={handleClose}
sx={{ mr: 1 }}
disabled={isSaving}
>
<CloseIcon fontSize="small" />
</IconButton>
</DialogTitle>
Expand Down Expand Up @@ -306,7 +326,12 @@ const PageTemplatePopup = ({
</DialogContent>
<Divider />
<DialogActions>
<Button type="submit" fullWidth variant="contained">
<Button
type="submit"
fullWidth
variant="contained"
disabled={isSaving}
>
{T.translate("page_template_list.page_crud.save")}
</Button>
</DialogActions>
Expand Down
Loading
Loading