Skip to content
Original file line number Diff line number Diff line change
Expand Up @@ -161,9 +161,20 @@ const FormTemplateItemListPage = ({
};

const handleArchiveItem = (item) =>
item.is_archived
(item.is_archived
? unarchiveFormTemplateItem(formTemplateId, item)
Comment thread
santipalenque marked this conversation as resolved.
: archiveFormTemplateItem(formTemplateId, item);
: archiveFormTemplateItem(formTemplateId, item)
).then(() => {
getFormTemplateItems(
formTemplateId,
term,
currentPage,
perPage,
order,
orderDir,
showArchived
);
});

const handleShowArchivedForms = (ev) => {
getFormTemplateItems(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,19 @@ const FormTemplateListPage = ({
};

const handleArchiveItem = (item) =>
item.is_archived ? unarchiveFormTemplate(item) : archiveFormTemplate(item);
(item.is_archived
? unarchiveFormTemplate(item)
: archiveFormTemplate(item)
).then(() => {
getFormTemplates(
term,
currentPage,
perPage,
order,
orderDir,
showArchived
);
});

const handleShowArchivedForms = (value) => {
getFormTemplates(
Expand Down
14 changes: 12 additions & 2 deletions src/pages/sponsors-global/inventory/inventory-list-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,9 +262,19 @@ const InventoryListPage = ({
};

const handleArchiveItem = (item) =>
item.is_archived
(item.is_archived
? unarchiveInventoryItem(item)
: archiveInventoryItem(item);
: archiveInventoryItem(item)
).then(() => {
getInventoryItems(
term,
currentPage,
perPage,
order,
orderDir,
showArchived
);
});

const columns = [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,9 +119,19 @@ const PageTemplateListPage = ({
};

const handleArchive = (item) =>
item.is_archived
(item.is_archived
? unarchivePageTemplate(item.id)
: archivePageTemplate(item.id);
: archivePageTemplate(item.id)
).then(() => {
getPageTemplates(
term,
currentPage,
perPage,
order,
orderDir,
showArchived
);
});

const handleEdit = (row) => {
getPageTemplate(row.id).then(() => setOpenPageDialog(true));
Expand Down
7 changes: 6 additions & 1 deletion src/pages/sponsors/show-pages-list-page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,12 @@ const ShowPagesListPage = ({
};

const handleArchiveItem = (item) =>
item.is_archived ? unarchiveShowPage(item.id) : archiveShowPage(item.id);
(item.is_archived
? unarchiveShowPage(item.id)
: archiveShowPage(item.id)
).then(() => {
getShowPages(term, currentPage, perPage, order, orderDir, showArchived);
});

const handleShowArchivedForms = (ev) => {
getShowPages(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ describe("InventoryPopup", () => {
);

const user = userEvent.setup();
const node = screen.getByTestId("CloseIcon");
const node = screen.getByTestId("close-dialog");
await user.click(node);

expect(onClose).toHaveBeenCalledTimes(1);
Expand Down Expand Up @@ -161,7 +161,7 @@ describe("InventoryPopup", () => {
const textNode = await screen.findByText("1 items selected");
expect(textNode.textContent).toBe("1 items selected");

const node = screen.getByTestId("CloseIcon");
const node = screen.getByTestId("close-dialog");
await user.click(node);

const textNode2 = screen.getByText("0 items selected");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,12 @@ const SponsorFormAddItemFromInventoryPopup = ({
<Typography variant="h5">
{T.translate("sponsor_form_item_list.add_from_inventory.title")}
</Typography>
<IconButton size="large" sx={{ p: 0 }} onClick={handleClose}>
<IconButton
size="large"
sx={{ p: 0 }}
onClick={handleClose}
data-testid="close-dialog"
>
<CloseIcon fontSize="large" />
</IconButton>
</DialogTitle>
Expand Down
14 changes: 12 additions & 2 deletions src/pages/sponsors/sponsor-form-item-list-page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,9 +110,19 @@ const SponsorFormItemListPage = ({
};

const handleArchiveItem = (item) =>
item.is_archived
(item.is_archived
? unarchiveSponsorFormItem(formId, item.id)
: archiveSponsorFormItem(formId, item.id);
: archiveSponsorFormItem(formId, item.id)
).then(() => {
getSponsorFormItems(
formId,
currentPage,
perPage,
order,
orderDir,
showArchived
);
});

const handleRowDelete = (itemId) => {
deleteSponsorFormItem(formId, itemId).then(() => {
Expand Down
14 changes: 12 additions & 2 deletions src/pages/sponsors/sponsor-forms-list-page/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,9 +118,19 @@ const SponsorFormsListPage = ({
};

const handleArchiveItem = (item) =>
item.is_archived
(item.is_archived
? unarchiveSponsorForm(item.id)
: archiveSponsorForm(item.id);
: archiveSponsorForm(item.id)
).then(() => {
getSponsorForms(
term,
currentPage,
perPage,
order,
orderDir,
showArchived
);
});

const handleShowArchivedForms = (ev) => {
getSponsorForms(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,9 +151,20 @@ const SponsorFormsManageItems = ({
};

const handleArchiveItem = (item) =>
item.is_archived
(item.is_archived
? unarchiveSponsorCustomizedFormItem(formId, item.id)
: archiveSponsorCustomizedFormItem(formId, item.id);
: archiveSponsorCustomizedFormItem(formId, item.id)
).then(() => {
getSponsorCustomizedFormItems(
formId,
term,
currentPage,
perPage,
order,
orderDir,
showArchived
);
Comment thread
tomrndom marked this conversation as resolved.
});

const handleShowArchivedItems = (ev) => {
getSponsorCustomizedFormItems(
Expand Down
15 changes: 13 additions & 2 deletions src/pages/sponsors/sponsor-page/tabs/sponsor-forms-tab/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,20 @@ const SponsorFormsTab = ({
};

const handleArchiveForm = (item) =>
item.is_archived
(item.is_archived
? unarchiveSponsorCustomizedForm(item.id)
: archiveSponsorCustomizedForm(item.id);
: archiveSponsorCustomizedForm(item.id)
).then(() => {
const { perPage, order, orderDir, currentPage } = customizedForms;
getSponsorCustomizedForms(
term,
currentPage,
perPage,
order,
orderDir,
showArchived
);
});

const handleCustomizedFormManageItems = (item) => {
history.push(
Expand Down
9 changes: 7 additions & 2 deletions src/reducers/sponsors/show-pages-list-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ import {
RECEIVE_SUMMIT_SPONSORSHIP_TYPES
} from "../../actions/summit-actions";
import { denormalizePageModules } from "../../utils/page-template";
import { getSafePageAfterRemove } from "../../utils/methods";

const DEFAULT_SHOW_PAGE = {
code: "",
Expand Down Expand Up @@ -109,22 +110,26 @@ const showPagesListReducer = (state = DEFAULT_STATE, action) => {
}
case SHOW_PAGE_ARCHIVED: {
const { pageId } = payload;
const { totalCount, perPage, currentPage } = state;
const pages = state.showPages.map((page) =>
page.id === pageId ? { ...page, is_archived: true } : page
);
return {
...state,
showPages: [...pages]
showPages: [...pages],
currentPage: getSafePageAfterRemove(totalCount, perPage, currentPage)
};
}
case SHOW_PAGE_UNARCHIVED: {
const { pageId } = payload;
const { totalCount, perPage, currentPage } = state;
const pages = state.showPages.map((page) =>
page.id === pageId ? { ...page, is_archived: false } : page
);
return {
...state,
showPages: [...pages]
showPages: [...pages],
currentPage: getSafePageAfterRemove(totalCount, perPage, currentPage)
};
}
case RECEIVE_SHOW_PAGE: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
RESET_SPONSOR_FORM_MANAGED_ITEM
} from "../../actions/sponsor-forms-actions";
import { SET_CURRENT_SUMMIT } from "../../actions/summit-actions";
import { getSafePageAfterRemove } from "../../utils/methods";

const DEFAULT_ITEM_ENTITY = {
code: "",
Expand Down Expand Up @@ -126,21 +127,31 @@ const sponsorCustomizedFormItemsListReducer = (
}
case SPONSOR_CUSTOMIZED_FORM_ITEM_ARCHIVED: {
const { id: itemId } = payload.response;
const { totalCount, currentPage, perPage } = state;

const items = state.items.map((item) =>
item.id === itemId ? { ...item, is_archived: true } : item
);

return { ...state, items };
return {
...state,
items,
currentPage: getSafePageAfterRemove(totalCount, perPage, currentPage)
};
}
case SPONSOR_CUSTOMIZED_FORM_ITEM_UNARCHIVED: {
const { itemId } = payload;
const { totalCount, currentPage, perPage } = state;

const items = state.items.map((item) =>
item.id === itemId ? { ...item, is_archived: false } : item
);

return { ...state, items };
return {
...state,
items,
currentPage: getSafePageAfterRemove(totalCount, perPage, currentPage)
};
}
case SPONSOR_FORM_MANAGED_ITEM_UPDATED: {
const updatedItem = payload.response;
Expand Down
15 changes: 13 additions & 2 deletions src/reducers/sponsors/sponsor-form-items-list-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
SPONSOR_FORM_ITEM_UNARCHIVED
} from "../../actions/sponsor-forms-actions";
import { SET_CURRENT_SUMMIT } from "../../actions/summit-actions";
import { getSafePageAfterRemove } from "../../utils/methods";

const DEFAULT_STATE = {
items: [],
Expand Down Expand Up @@ -117,21 +118,31 @@ const sponsorFormItemsListReducer = (state = DEFAULT_STATE, action) => {
}
case SPONSOR_FORM_ITEM_ARCHIVED: {
const { id: itemId } = payload.response;
const { totalCount, perPage, currentPage } = state;

const items = state.items.map((item) =>
item.id === itemId ? { ...item, is_archived: true } : item
);

return { ...state, items };
return {
...state,
items,
currentPage: getSafePageAfterRemove(totalCount, perPage, currentPage)
};
}
case SPONSOR_FORM_ITEM_UNARCHIVED: {
const { itemId } = payload;
const { totalCount, perPage, currentPage } = state;

const items = state.items.map((item) =>
item.id === itemId ? { ...item, is_archived: false } : item
);

return { ...state, items };
return {
...state,
items,
currentPage: getSafePageAfterRemove(totalCount, perPage, currentPage)
};
}
default:
return state;
Expand Down
15 changes: 13 additions & 2 deletions src/reducers/sponsors/sponsor-forms-list-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ import {
SET_CURRENT_SUMMIT,
RECEIVE_SUMMIT_SPONSORSHIP_TYPES
} from "../../actions/summit-actions";
import { getSafePageAfterRemove } from "../../utils/methods";

export const DEFAULT_STATE = {
sponsorForms: [],
Expand Down Expand Up @@ -152,21 +153,31 @@ const sponsorFormsListReducer = (state = DEFAULT_STATE, action) => {
}
case SPONSOR_FORM_ARCHIVED: {
const { id: formId } = payload.response;
const { totalCount, perPage, currentPage } = state;

const sponsorForms = state.sponsorForms.map((item) =>
item.id === formId ? { ...item, is_archived: true } : item
);

return { ...state, sponsorForms };
return {
...state,
sponsorForms,
currentPage: getSafePageAfterRemove(totalCount, perPage, currentPage)
};
}
case SPONSOR_FORM_UNARCHIVED: {
const { formId } = payload;
const { totalCount, perPage, currentPage } = state;

const sponsorForms = state.sponsorForms.map((item) =>
item.id === formId ? { ...item, is_archived: false } : item
);

return { ...state, sponsorForms };
return {
...state,
sponsorForms,
currentPage: getSafePageAfterRemove(totalCount, perPage, currentPage)
};
}
case SPONSOR_FORM_DELETED: {
const { formId } = payload;
Expand Down
Loading
Loading