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
128 changes: 128 additions & 0 deletions src/actions/sponsor-pages-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ export const RECEIVE_SPONSOR_PAGES = "RECEIVE_SPONSOR_PAGES";

export const GLOBAL_PAGE_CLONED = "GLOBAL_PAGE_CLONED";

export const REQUEST_SPONSOR_MANAGED_PAGES = "REQUEST_SPONSOR_MANAGED_PAGES";
export const RECEIVE_SPONSOR_MANAGED_PAGES = "RECEIVE_SPONSOR_MANAGED_PAGES";

export const REQUEST_SPONSOR_CUSTOMIZED_PAGES =
"REQUEST_SPONSOR_CUSTOMIZED_PAGES";
export const RECEIVE_SPONSOR_CUSTOMIZED_PAGES =
"RECEIVE_SPONSOR_CUSTOMIZED_PAGES";
Comment on lines +37 to +43
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Propagate perPage/hideArchived and request is_archived.

The reducer expects these values and the UI needs is_archived for archive labels and row state, but they’re currently missing.

🛠️ Suggested fix
-    const params = {
-      page,
-      fields: "id,code,name,kind,modules_count,allowed_add_ons",
-      per_page: perPage,
-      access_token: accessToken
-    };
+    const params = {
+      page,
+      fields: "id,code,name,kind,modules_count,allowed_add_ons,is_archived",
+      per_page: perPage,
+      access_token: accessToken
+    };
...
-      { order, orderDir, page, term, summitTZ }
+      { order, orderDir, page, perPage, term, summitTZ, hideArchived }
-    const params = {
-      page,
-      fields: "id,code,name,kind,modules_count,allowed_add_ons",
-      per_page: perPage,
-      access_token: accessToken
-    };
+    const params = {
+      page,
+      fields: "id,code,name,kind,modules_count,allowed_add_ons,is_archived",
+      per_page: perPage,
+      access_token: accessToken
+    };
...
-      { order, orderDir, page, term, summitTZ }
+      { order, orderDir, page, perPage, term, summitTZ, hideArchived }

Also applies to: 149-203, 209-263

🤖 Prompt for AI Agents
In `@src/actions/sponsor-pages-actions.js` around lines 37 - 43, The exported
action types (REQUEST_SPONSOR_MANAGED_PAGES, RECEIVE_SPONSOR_MANAGED_PAGES,
REQUEST_SPONSOR_CUSTOMIZED_PAGES, RECEIVE_SPONSOR_CUSTOMIZED_PAGES) are missing
the perPage/hideArchived values in their dispatched payloads and API requests;
update the action creators that use these constants so the dispatched REQUEST_*
and RECEIVE_* actions include perPage and hideArchived in the action.payload,
and change the API query/body param for archived filtering from whatever is
currently used to is_archived (true/false) so the reducer and UI receive
is_archived for archive labels and row state; apply the same change to the other
similar action creators referenced in the comment (lines 149-203 and 209-263) so
all sponsor-managed/customized page flows carry perPage, hideArchived and send
is_archived to the backend.


export const getSponsorPages =
(
term = "",
Expand Down Expand Up @@ -133,3 +141,123 @@ export const cloneGlobalPage =
})
.finally(() => dispatch(stopLoading()));
};

/* ************************************************************************ */
/* MANAGED PAGES */
/* ************************************************************************ */

export const getSponsorManagedPages =
(
term = "",
page = DEFAULT_CURRENT_PAGE,
perPage = DEFAULT_PER_PAGE,
order = "id",
orderDir = DEFAULT_ORDER_DIR,
hideArchived = false
) =>
async (dispatch, getState) => {
const { currentSummitState, currentSponsorState } = getState();
const { currentSummit } = currentSummitState;
const {
entity: { id: sponsorId }
} = currentSponsorState;
const accessToken = await getAccessTokenSafely();
const summitTZ = currentSummit.time_zone.name;
const filter = [];

dispatch(startLoading());

if (term) {
const escapedTerm = escapeFilterValue(term);
filter.push(`name=@${escapedTerm},code=@${escapedTerm}`);
}

const params = {
page,
fields: "id,code,name,kind,modules_count,allowed_add_ons",
per_page: perPage,
access_token: accessToken
};

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

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

// order
if (order != null && orderDir != null) {
const orderDirSign = orderDir === 1 ? "" : "-";
params.order = `${orderDirSign}${order}`;
}

return getRequest(
createAction(REQUEST_SPONSOR_MANAGED_PAGES),
createAction(RECEIVE_SPONSOR_MANAGED_PAGES),
`${window.SPONSOR_PAGES_API_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsorId}/managed-pages`,
authErrorHandler,
{ order, orderDir, page, perPage, term, hideArchived, summitTZ }
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
};

/* ************************************************************************ */
/* CUSTOMIZED PAGES */
/* ************************************************************************ */

export const getSponsorCustomizedPages =
(
term = "",
page = DEFAULT_CURRENT_PAGE,
perPage = DEFAULT_PER_PAGE,
order = "id",
orderDir = DEFAULT_ORDER_DIR,
hideArchived = false
) =>
async (dispatch, getState) => {
const { currentSummitState, currentSponsorState } = getState();
const { currentSummit } = currentSummitState;
const {
entity: { id: sponsorId }
} = currentSponsorState;
const accessToken = await getAccessTokenSafely();
const summitTZ = currentSummit.time_zone.name;
const filter = [];

dispatch(startLoading());

if (term) {
const escapedTerm = escapeFilterValue(term);
filter.push(`name=@${escapedTerm},code=@${escapedTerm}`);
}

const params = {
page,
fields: "id,code,name,kind,modules_count,allowed_add_ons",
per_page: perPage,
access_token: accessToken
};

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

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

// order
if (order != null && orderDir != null) {
const orderDirSign = orderDir === 1 ? "" : "-";
params.order = `${orderDirSign}${order}`;
}

return getRequest(
createAction(REQUEST_SPONSOR_CUSTOMIZED_PAGES),
createAction(RECEIVE_SPONSOR_CUSTOMIZED_PAGES),
`${window.SPONSOR_PAGES_API_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsorId}/sponsor-pages`,
authErrorHandler,
{ order, orderDir, page, perPage, term, hideArchived, summitTZ }
)(params)(dispatch).then(() => {
dispatch(stopLoading());
});
};
17 changes: 17 additions & 0 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -2460,6 +2460,23 @@
}
}
},
"pages_tab": {
"alert_info": "To add a Sponsor Specific Page for this show's sponsor, click Add Page button. Note: this Page will be visible only to this sponsor for this show. The General Pages can only be managed on the Show's Pages section.",
"hide_archived": "Hide archived Pages",
"using_template": "Using Template",
"new_page": "New Page",
"pages": "pages",
"managed_pages": "Managed Pages",
"sponsor_customized_pages": "Customized Sponsor Pages",
"code": "Code",
"name": "Name",
"add_ons": "Add-ons",
"info_mod": "Info Mod",
"upload_mod": "Upload Mod",
"download_mod": "Download Mod",
"archive": "Archive",
"unarchive": "Unarchive"
},
"cart_tab": {
"new_form": "New Form",
"forms": "forms",
Expand Down
8 changes: 8 additions & 0 deletions src/pages/sponsors/edit-sponsor-page.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import SponsorUsersListPerSponsorPage from "./sponsor-users-list-per-sponsor";
import SponsorFormsTab from "./sponsor-forms-tab";
import SponsorBadgeScans from "./sponsor-badge-scans";
import SponsorCartTab from "./sponsor-cart-tab";
import SponsorPagesTab from "./sponsor-pages-tab";
import SponsorFormsManageItems from "./sponsor-forms-tab/components/manage-items/sponsor-forms-manage-items";
import { SPONSOR_TABS } from "../../utils/constants";

Expand Down Expand Up @@ -235,6 +236,13 @@ const EditSponsorPage = (props) => {
<CustomTabPanel value={selectedTab} index={1}>
<SponsorUsersListPerSponsorPage sponsor={entity} />
</CustomTabPanel>
<CustomTabPanel value={selectedTab} index={2}>
<SponsorPagesTab
sponsor={entity}
summitId={currentSummit.id}
history={history}
/>
</CustomTabPanel>
<CustomTabPanel value={selectedTab} index={4}>
{sponsorFormItemRoute ? (
<SponsorFormsManageItems match={match} />
Expand Down
Loading