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: 49 additions & 1 deletion src/actions/sponsor-pages-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,17 @@ import {
import T from "i18n-react/dist/i18n-react";
import { getAccessTokenSafely } from "../utils/methods";
import { snackbarErrorHandler, snackbarSuccessHandler } from "./base-actions";
import { DEFAULT_CURRENT_PAGE, DEFAULT_ORDER_DIR, DEFAULT_PER_PAGE } from "../utils/constants";
import {
DEFAULT_CURRENT_PAGE,
DEFAULT_ORDER_DIR,
DEFAULT_PER_PAGE
} from "../utils/constants";

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 SPONSOR_MANAGED_PAGE_ADDED = "SPONSOR_MANAGED_PAGE_ADDED";

export const REQUEST_SPONSOR_CUSTOMIZED_PAGES =
"REQUEST_SPONSOR_CUSTOMIZED_PAGES";
Expand Down Expand Up @@ -135,6 +140,49 @@ export const getSponsorManagedPages =
});
};

export const saveSponsorManagedPage =
(entity) => async (dispatch, getState) => {
const { currentSummitState, currentSponsorState } = getState();
const { currentSummit } = currentSummitState;
const {
entity: { id: sponsorId }
} = currentSponsorState;
const accessToken = await getAccessTokenSafely();

dispatch(startLoading());

const normalizedEntity = normalizeSponsorManagedPage(entity);

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

return postRequest(
null,
createAction(SPONSOR_MANAGED_PAGE_ADDED),
`${window.SPONSOR_PAGES_API_URL}/api/v1/summits/${currentSummit.id}/sponsors/${sponsorId}/managed-pages`,
normalizedEntity,
snackbarErrorHandler
)(params)(dispatch).finally(() => {
dispatch(stopLoading());
});
};

const normalizeSponsorManagedPage = (entity) => {
const normalizedEntity = {
show_page_ids: entity.pages,
allowed_add_ons: entity.add_ons.map((a) => a.id),
apply_to_all_add_ons: false
};

if (entity.add_ons.includes("all")) {
normalizedEntity.apply_to_all_add_ons = true;
normalizedEntity.allowed_add_ons = [];
}

return normalizedEntity;
};
/* ************************************************************************ */
/* CUSTOMIZED PAGES */
/* ************************************************************************ */
Expand Down
124 changes: 76 additions & 48 deletions src/components/mui/formik-inputs/mui-formik-select-group.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const MuiFormikSelectGroup = ({
selectAllLabel = "Select All",
getOptionLabel = (item) => item.name,
getOptionValue = (item) => item.id,
noOptionsLabel = "No items",
getGroupId = null,
getGroupLabel = null,
disabled = false
Expand Down Expand Up @@ -213,6 +214,79 @@ const MuiFormikSelectGroup = ({
.flat()
.filter(Boolean);

const renderMenuContent = () => {
if (loading) {
return (
<MenuItem disabled>
<CircularProgress size={20} />
</MenuItem>
);
}

if (options.length === 0) {
return (
<MenuItem disabled>
<ListItemText
primary={noOptionsLabel}
slotProps={{
primary: {
sx: {
fontSize: "16px",
color: "#00000061"
}
}
}}
/>
</MenuItem>
);
}

return (
<>
{showSelectAll && (
<>
<MenuItem
value="selectAll"
sx={{
backgroundColor: "#fafafa",
"&:hover": {
backgroundColor: "#f0f0f0"
}
}}
onClick={() => {
// custom event value to select all
handleChange({ target: { value: ["selectAll"] } });
}}
>
<Checkbox
checked={isAllSelected}
indeterminate={selectedValues.length > 0 && !isAllSelected}
sx={{
p: 1,
"& svg": {
fontSize: 24
}
}}
/>
<ListItemText
primary={selectAllLabel}
slotProps={{
primary: {
sx: {
fontSize: "16px"
}
}
}}
/>
</MenuItem>
<Divider />
</>
)}
{renderGroupedOptions()}
</>
);
};

const IconWithLoading = useMemo(() => getCustomIcon(loading), [loading]);

return (
Expand Down Expand Up @@ -243,54 +317,7 @@ const MuiFormikSelectGroup = ({
error={Boolean(error)}
IconComponent={IconWithLoading}
>
{loading ? (
<MenuItem disabled>
<CircularProgress size={20} />
</MenuItem>
) : (
<>
{showSelectAll && options.length > 0 && (
<>
<MenuItem
value="selectAll"
sx={{
backgroundColor: "#fafafa",
"&:hover": {
backgroundColor: "#f0f0f0"
}
}}
onClick={() => {
// custom event value to select all
handleChange({ target: { value: ["selectAll"] } });
}}
>
<Checkbox
checked={isAllSelected}
indeterminate={selectedValues.length > 0 && !isAllSelected}
sx={{
p: 1,
"& svg": {
fontSize: 24
}
}}
/>
<ListItemText
primary={selectAllLabel}
slotProps={{
primary: {
sx: {
fontSize: "16px"
}
}
}}
/>
</MenuItem>
<Divider />
</>
)}
{renderGroupedOptions()}
</>
)}
{renderMenuContent()}
</Select>
{error && (
<div
Expand Down Expand Up @@ -318,6 +345,7 @@ MuiFormikSelectGroup.propTypes = {
getOptionValue: PropTypes.func,
getGroupId: PropTypes.func,
getGroupLabel: PropTypes.func,
noOptionsLabel: PropTypes.string,
disabled: PropTypes.bool
};

Expand Down
15 changes: 12 additions & 3 deletions src/i18n/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"user_not_authz": "Hold on. Your user is not authorized!.",
"user_not_set": "Hold on. Can not get any valid user.",
"session_expired": "Hold on. Your session expired!.",
"empty_list": "there not are any item that match your criteria.",
"empty_list": "there not are any {item} that match your criteria.",
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix grammar in the errors.empty_list message.

Line [6] currently reads unnaturally: "there not are any {item} that match your criteria.".

✍️ Proposed fix
-    "empty_list": "there not are any {item} that match your criteria.",
+    "empty_list": "There are no {item} that match your criteria.",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"empty_list": "there not are any {item} that match your criteria.",
"empty_list": "There are no {item} that match your criteria.",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/i18n/en.json` at line 6, Update the errors.empty_list message string in
en.json to correct the grammar; replace the current text ("there not are any
{item} that match your criteria.") with a natural sentence such as "There are no
{item} that match your criteria." keeping the {item} placeholder intact and
preserving JSON string formatting and punctuation/capitalization.

"server_error": "There was a problem with our server, please contact admin.",
"empty_list_schedule_events": "Please select a Day and a Location ...",
"not_allowed": "You are not allowed here, please login with another user to access this page.",
Expand Down Expand Up @@ -75,6 +75,9 @@
"error": "Error!",
"unarchive": "Unarchive",
"archive": "Archive",
"sort_by": "Sort By",
"sort_asc_label": "A-Z",
"sort_desc_label": "Z-A",
"placeholders": {
"search_speakers": "Search Speakers by Name, Email, Speaker Id or Member Id",
"select_acceptance_criteria": "Select acceptance criteria",
Expand All @@ -95,7 +98,8 @@
"date": "Wrong date format.",
"after": "'{field1}' must be after '{field2}'.",
"boolean": "Must be a boolean.",
"mib_aligned": "Must be a MiB aligned value"
"mib_aligned": "Must be a MiB aligned value",
"add_on_required": "Select at least one add-on"
},
"landing": {
"os_summit_admin": "Show Admin",
Expand Down Expand Up @@ -2476,7 +2480,12 @@
"upload_mod": "Upload Mod",
"download_mod": "Download Mod",
"archive": "Archive",
"unarchive": "Unarchive"
"unarchive": "Unarchive",
"items_selected": "items selected",
"no_add_ons": "No Add-ons Available",
"no_pages": "There is no pages that match the criteria",
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Fix grammar in sponsor pages empty-state copy.

Line [2486] should use plural agreement (are + pages) for correct UX copy.

✍️ Proposed fix
-      "no_pages": "There is no pages that match the criteria",
+      "no_pages": "There are no pages that match the criteria",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"no_pages": "There is no pages that match the criteria",
"no_pages": "There are no pages that match the criteria",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/i18n/en.json` at line 2486, The i18n string "no_pages" currently reads
"There is no pages that match the criteria" and uses incorrect singular verb;
update the value for the "no_pages" key to use plural agreement—e.g., change it
to "There are no pages that match the criteria" (or "There are no pages matching
the criteria") so the copy is grammatically correct.

"add_page_using_template": "Add Page Template",
"add_selected_page_template": "Add Selected Page Template"
},
"cart_tab": {
"new_form": "New Form",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,18 @@ const AddFormTemplateItemDialog = ({
// onClick: () => handleSort("date", "+")
// },
// { label: "Newest", onClick: () => handleSort("date", "+") },
{ label: "A-Z", onClick: () => handleSort("name", 1) },
{ label: "Z-A", onClick: () => handleSort("name", 0) }
{
label: T.translate("general.sort_asc_label"),
onClick: () => handleSort("name", 1)
},
{
label: T.translate("general.sort_desc_label"),
onClick: () => handleSort("name", 0)
}
]}
>
<SwapVertIcon fontSize="large" sx={{ mr: 1 }} /> sort by
<SwapVertIcon fontSize="large" sx={{ mr: 1 }} />{" "}
{T.translate("general.sort_by")}
</MenuButton>
</Grid2>
<Grid2 size={8}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,18 @@ const FormTemplateFromDuplicateDialog = ({
buttonSx={{ color: "#000" }}
menuItems={[
// { label: "Newest", onClick: () => handleSort("+date") },
{ label: "A-Z", onClick: () => handleSort("name", 1) },
{ label: "Z-A", onClick: () => handleSort("name", 0) }
{
label: T.translate("general.sort_asc_label"),
onClick: () => handleSort("name", 1)
},
{
label: T.translate("general.sort_desc_label"),
onClick: () => handleSort("name", 0)
}
]}
>
<SwapVertIcon fontSize="large" sx={{ mr: 1 }} /> sort by
<SwapVertIcon fontSize="large" sx={{ mr: 1 }} />{" "}
{T.translate("general.sort_by")}
</MenuButton>
</Grid2>
<Grid2 size={8}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -227,11 +227,18 @@ const AddSponsorFormTemplatePopup = ({
buttonId="sort-button"
menuId="sort-menu"
menuItems={[
{ label: "A-Z", onClick: () => handleSort("name", 1) },
{ label: "Z-A", onClick: () => handleSort("name", 0) }
{
label: T.translate("general.sort_asc_label"),
onClick: () => handleSort("name", 1)
},
{
label: T.translate("general.sort_desc_label"),
onClick: () => handleSort("name", 0)
}
]}
>
<SwapVertIcon fontSize="large" sx={{ mr: 1 }} /> sort by
<SwapVertIcon fontSize="large" sx={{ mr: 1 }} />{" "}
{T.translate("general.sort_by")}
</MenuButton>
</Grid2>
<Grid2 size={8}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,8 @@ const SponsorFormItemFromInventoryPopup = ({
}
]}
>
<SwapVertIcon fontSize="large" sx={{ mr: 1 }} /> sort by
<SwapVertIcon fontSize="large" sx={{ mr: 1 }} />{" "}
{T.translate("general.sort_by")}
</MenuButton>
</Grid2>
<Grid2 size={9}>
Expand Down
Loading