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
2 changes: 1 addition & 1 deletion src/actions/__tests__/sponsor-forms-actions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ describe("Sponsor Forms Actions", () => {
expect.anything(),
expect.anything(),
{
hideArchived: false,
showArchived: false,
order: "id",
orderDir: 1,
currentPage: 2,
Expand Down
6 changes: 3 additions & 3 deletions src/actions/form-template-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const getFormTemplates =
perPage = DEFAULT_PER_PAGE,
order = "id",
orderDir = DEFAULT_ORDER_DIR,
hideArchived = false
showArchived = false
) =>
async (dispatch) => {
const accessToken = await getAccessTokenSafely();
Expand All @@ -97,7 +97,7 @@ export const getFormTemplates =
access_token: accessToken
};

if (hideArchived) filter.push("is_archived==0");
filter.push(`is_archived==${showArchived ? 1 : 0}`);

if (filter.length > 0) {
params["filter[]"] = filter;
Expand All @@ -114,7 +114,7 @@ export const getFormTemplates =
createAction(RECEIVE_FORM_TEMPLATES),
`${window.INVENTORY_API_BASE_URL}/api/v1/form-templates`,
authErrorHandler,
{ order, orderDir, page, perPage, term, hideArchived }
{ order, orderDir, page, perPage, term, showArchived }
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
Expand Down
8 changes: 4 additions & 4 deletions src/actions/form-template-item-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export const getFormTemplateItems =
perPage = DEFAULT_PER_PAGE,
order = "id",
orderDir = DEFAULT_ORDER_DIR,
hideArchived = false
showArchived = false
) =>
async (dispatch) => {
const accessToken = await getAccessTokenSafely();
Expand All @@ -101,12 +101,12 @@ export const getFormTemplateItems =
access_token: accessToken
};

filter.push(`is_archived==${showArchived ? 1 : 0}`);

if (filter.length > 0) {
params["filter[]"] = filter;
}

if (hideArchived) filter.push("is_archived==0");

// order
if (order != null && orderDir != null) {
const orderDirSign = orderDir === 1 ? "" : "-";
Expand All @@ -118,7 +118,7 @@ export const getFormTemplateItems =
createAction(RECEIVE_FORM_TEMPLATE_ITEMS),
`${window.INVENTORY_API_BASE_URL}/api/v1/form-templates/${formTemplateId}/items`,
authErrorHandler,
{ order, orderDir, page, term, hideArchived }
{ order, orderDir, page, term, showArchived }
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
Expand Down
48 changes: 29 additions & 19 deletions src/actions/inventory-item-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ export const getInventoryItems =
perPage = DEFAULT_PER_PAGE,
order = "id",
orderDir = DEFAULT_ORDER_DIR,
hideArchived = false
showArchived = false
) =>
async (dispatch) => {
const accessToken = await getAccessTokenSafely();
Expand All @@ -115,7 +115,7 @@ export const getInventoryItems =
filter.push(`name=@${escapedTerm},code=@${escapedTerm}`);
}

if (hideArchived) filter.push("is_archived==0");
filter.push(`is_archived==${showArchived ? 1 : 0}`);

const params = {
page,
Expand All @@ -141,31 +141,41 @@ export const getInventoryItems =
createAction(RECEIVE_INVENTORY_ITEMS),
`${window.INVENTORY_API_BASE_URL}/api/v1/inventory-items`,
authErrorHandler,
{ order, orderDir, page, perPage, term, hideArchived }
{ order, orderDir, page, perPage, term, showArchived }
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
};

export const getInventoryItem = (inventoryItemId) => async (dispatch) => {
const accessToken = await getAccessTokenSafely();
export const getInventoryItem =
(inventoryItemId, showArchived = false) =>
async (dispatch) => {
const accessToken = await getAccessTokenSafely();

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

const params = {
access_token: accessToken,
expand: "images,meta_fields,meta_fields.values"
};
const filter = [];

return getRequest(
null,
createAction(RECEIVE_INVENTORY_ITEM),
`${window.INVENTORY_API_BASE_URL}/api/v1/inventory-items/${inventoryItemId}`,
authErrorHandler
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
};
filter.push(`is_archived==${showArchived ? 1 : 0}`);

const params = {
access_token: accessToken,
expand: "images,meta_fields,meta_fields.values"
};

if (filter.length > 0) {
params["filter[]"] = filter;
}

return getRequest(
null,
createAction(RECEIVE_INVENTORY_ITEM),
`${window.INVENTORY_API_BASE_URL}/api/v1/inventory-items/${inventoryItemId}`,
authErrorHandler
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
};

export const deleteInventoryItem = (inventoryItemId) => async (dispatch) => {
const accessToken = await getAccessTokenSafely();
Expand Down
6 changes: 3 additions & 3 deletions src/actions/page-template-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export const getPageTemplates =
perPage = DEFAULT_PER_PAGE,
order = "id",
orderDir = DEFAULT_ORDER_DIR,
hideArchived = false
showArchived = false
) =>
async (dispatch) => {
const accessToken = await getAccessTokenSafely();
Expand All @@ -76,7 +76,7 @@ export const getPageTemplates =
access_token: accessToken
};

if (hideArchived) filter.push("is_archived==0");
filter.push(`is_archived==${showArchived ? 1 : 0}`);

if (filter.length > 0) {
params["filter[]"] = filter;
Expand All @@ -93,7 +93,7 @@ export const getPageTemplates =
createAction(RECEIVE_PAGE_TEMPLATES),
`${window.SPONSOR_PAGES_API_URL}/api/v1/page-templates`,
authErrorHandler,
{ order, orderDir, page, perPage, term, hideArchived }
{ order, orderDir, page, perPage, term, showArchived }
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
Expand Down
34 changes: 17 additions & 17 deletions src/actions/sponsor-forms-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export const getSponsorForms =
perPage = DEFAULT_PER_PAGE,
order = "id",
orderDir = DEFAULT_ORDER_DIR,
hideArchived = false,
showArchived = false,
sponsorshipTypesId = []
) =>
async (dispatch, getState) => {
Expand All @@ -134,7 +134,7 @@ export const getSponsorForms =
access_token: accessToken
};

if (hideArchived) filter.push("is_archived==0");
filter.push(`is_archived==${showArchived ? 1 : 0}`);

if (sponsorshipTypesId?.length > 0) {
const formattedSponsorships = sponsorshipTypesId.join("&&");
Expand All @@ -157,7 +157,7 @@ export const getSponsorForms =
createAction(RECEIVE_SPONSOR_FORMS),
`${window.PURCHASES_API_URL}/api/v1/summits/${currentSummit.id}/show-forms`,
authErrorHandler,
{ order, orderDir, currentPage, perPage, term, hideArchived }
{ order, orderDir, currentPage, perPage, term, showArchived }
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
Expand Down Expand Up @@ -257,7 +257,7 @@ export const getGlobalTemplates =
perPage = DEFAULT_PER_PAGE,
order = "id",
orderDir = DEFAULT_ORDER_DIR,
hideArchived = false
showArchived = false
) =>
async (dispatch) => {
const accessToken = await getAccessTokenSafely();
Expand All @@ -278,7 +278,7 @@ export const getGlobalTemplates =
access_token: accessToken
};

if (hideArchived) filter.push("is_archived==0");
filter.push(`is_archived==${showArchived ? 1 : 0}`);

if (filter.length > 0) {
params["filter[]"] = filter;
Expand Down Expand Up @@ -479,7 +479,7 @@ export const getSponsorManagedForms =
perPage = DEFAULT_PER_PAGE,
order = "id",
orderDir = DEFAULT_ORDER_DIR,
hideArchived = false
showArchived = false
) =>
async (dispatch, getState) => {
const { currentSummitState, currentSponsorState } = getState();
Expand All @@ -506,7 +506,7 @@ export const getSponsorManagedForms =
access_token: accessToken
};

if (hideArchived) filter.push("is_archived==0");
filter.push(`is_archived==${showArchived ? 1 : 0}`);

if (filter.length > 0) {
params["filter[]"] = filter;
Expand All @@ -523,7 +523,7 @@ export const getSponsorManagedForms =
createAction(RECEIVE_SPONSOR_MANAGED_FORMS),
`${window.PURCHASES_API_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsorId}/managed-forms`,
authErrorHandler,
{ order, orderDir, page, term, summitTZ }
{ order, orderDir, page, term, summitTZ, showArchived }
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
Expand Down Expand Up @@ -586,7 +586,7 @@ export const getSponsorCustomizedForms =
perPage = DEFAULT_PER_PAGE,
order = "id",
orderDir = DEFAULT_ORDER_DIR,
hideArchived = false
showArchived = false
) =>
async (dispatch, getState) => {
const { currentSummitState, currentSponsorState } = getState();
Expand All @@ -613,7 +613,7 @@ export const getSponsorCustomizedForms =
access_token: accessToken
};

if (hideArchived) filter.push("is_archived==0");
filter.push(`is_archived==${showArchived ? 1 : 0}`);

if (filter.length > 0) {
params["filter[]"] = filter;
Expand All @@ -630,7 +630,7 @@ export const getSponsorCustomizedForms =
createAction(RECEIVE_SPONSOR_CUSTOMIZED_FORMS),
`${window.PURCHASES_API_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsorId}/sponsor-forms`,
authErrorHandler,
{ order, orderDir, page, term, summitTZ }
{ order, orderDir, page, term, summitTZ, showArchived }
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
Expand Down Expand Up @@ -671,7 +671,7 @@ export const getSponsorCustomizedFormItems =
perPage = DEFAULT_PER_PAGE,
order = "id",
orderDir = DEFAULT_ORDER_DIR,
hideArchived = false
showArchived = false
) =>
async (dispatch, getState) => {
const { currentSummitState, currentSponsorState } = getState();
Expand All @@ -695,7 +695,7 @@ export const getSponsorCustomizedFormItems =
access_token: accessToken
};

if (hideArchived) filter.push("is_archived==0");
filter.push(`is_archived==${showArchived ? 1 : 0}`);

if (filter.length > 0) {
params["filter[]"] = filter;
Expand All @@ -712,7 +712,7 @@ export const getSponsorCustomizedFormItems =
createAction(RECEIVE_SPONSOR_CUSTOMIZED_FORM_ITEMS),
`${window.PURCHASES_API_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsorId}/sponsor-forms/${formId}/items`,
authErrorHandler,
{ term, order, orderDir, page, perPage, hideArchived }
{ term, order, orderDir, page, perPage, showArchived }
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
Expand Down Expand Up @@ -951,7 +951,7 @@ export const getSponsorFormItems =
perPage = DEFAULT_PER_PAGE,
order = "id",
orderDir = DEFAULT_ORDER_DIR,
hideArchived = false
showArchived = false
) =>
async (dispatch, getState) => {
const { currentSummitState } = getState();
Expand All @@ -970,7 +970,7 @@ export const getSponsorFormItems =
access_token: accessToken
};

if (hideArchived) filter.push("is_archived==0");
filter.push(`is_archived==${showArchived ? 1 : 0}`);

if (filter.length > 0) {
params["filter[]"] = filter;
Expand All @@ -987,7 +987,7 @@ export const getSponsorFormItems =
createAction(RECEIVE_SPONSOR_FORM_ITEMS),
`${window.PURCHASES_API_URL}/api/v1/summits/${currentSummit.id}/show-forms/${formId}/items`,
authErrorHandler,
{ order, orderDir, page, hideArchived }
{ order, orderDir, page, showArchived }
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
Expand Down
6 changes: 3 additions & 3 deletions src/actions/sponsor-pages-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ export const getSponsorPages =
perPage = DEFAULT_PER_PAGE,
order = "id",
orderDir = DEFAULT_ORDER_DIR,
hideArchived = false,
showArchived = false,
sponsorshipTypesId = []
) =>
async (dispatch, getState) => {
Expand All @@ -68,7 +68,7 @@ export const getSponsorPages =
expand: "sponsorship_types"
};

if (hideArchived) filter.push("is_archived==0");
filter.push(`is_archived==${showArchived ? 1 : 0}`);

if (sponsorshipTypesId?.length > 0) {
const formattedSponsorships = sponsorshipTypesId.join("&&");
Expand All @@ -91,7 +91,7 @@ export const getSponsorPages =
createAction(RECEIVE_SPONSOR_PAGES),
`${window.SPONSOR_PAGES_API_URL}/api/v1/summits/${currentSummit.id}/show-pages`,
authErrorHandler,
{ order, orderDir, page, term, hideArchived }
{ order, orderDir, page, term, showArchived }
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe("SelectPageTemplateDialog", () => {

renderWithStore();

expect(getPageTemplates).toHaveBeenCalledWith("", 1, 10, "id", 1, true);
expect(getPageTemplates).toHaveBeenCalledWith("", 1, 10, "id", 1);
});

test("displays initial selection count as 0", () => {
Expand Down Expand Up @@ -305,8 +305,7 @@ describe("SelectPageTemplateDialog", () => {
1,
10,
"id",
1,
true
1
);
});
});
Expand Down Expand Up @@ -363,7 +362,7 @@ describe("SelectPageTemplateDialog", () => {
renderWithStore();

// Initial call on mount
expect(getPageTemplates).toHaveBeenCalledWith("", 1, 10, "id", 1, true);
expect(getPageTemplates).toHaveBeenCalledWith("", 1, 10, "id", 1);

// The actual sort interaction would be handled by MuiInfiniteTable
// This test verifies the component is initialized with correct sort params
Expand Down
Loading