for (let part of parts) {
const cleaned = cleanText(part);
if (cleaned === "condition set 1") {
currentSet = set1;
continue;
}
if (cleaned === "condition set 2") {
currentSet = set2;
continue;
}
if (!currentSet) currentSet = set1;
function extractText(htmlString) {
if (!htmlString || typeof htmlString !== "string") return "";
let text = htmlString.replace(/<[^>]+>/g, "").trim();
code
if (text.toLowerCase().startsWith("if ")) {
text = text.substring(3).trim();
}
// console.log("Actual Text :", text);
return text; // do not convert to lowercase here
}
function generateSummary(summary) {
if (!summary) return "";
if (typeof summary === "string") {
return summary;
}
let conditionTexts = [];
if (summary.conditions) {
for (const setKey in summary.conditions) {
if (Object.prototype.hasOwnProperty.call(summary.conditions, setKey)) {
const conditionsVal = summary.conditions[setKey];
const conditionsArray = Array.isArray(conditionsVal) ? conditionsVal : [conditionsVal];
const cleanConditions = conditionsArray.map(extractText);
conditionTexts.push(cleanConditions.join(", "));
}
}
}
const conditionsStr = conditionTexts.join(", ");
let actionsStr = "";
if (summary.actions && Array.isArray(summary.actions)) {
const cleanActions = summary.actions.map(extractText);
actionsStr = cleanActions.join(", ");
}
if (conditionsStr && actionsStr) {
return if ${conditionsStr}, then ${actionsStr};
} else if (conditionsStr) {
return if ${conditionsStr};
} else if (actionsStr) {
return actionsStr;
}
return "";
}
const duplicateGroupsMap = useMemo(() => {
// groups: array of arrays of duplicate rules with length > 1
let allRules = [];
if (activeTab === "ticketcreate") allRules = ticketCreationRules;
else if (activeTab === "ticketupdate") allRules = ticketUpdateRules;
else if (activeTab === "hourly") allRules = hourlyTriggerRules;
code
// group duplicates, filtered active only
const groups = groupDuplicates(allRules).filter((g) => g.length > 1);
// Map rule_id -> isFirstInGroup flag (true only for first rule of each duplicate group)
const firstRuleIds = new Set();
groups.forEach((group) => {
if (group.length > 0) {
firstRuleIds.add(group[0].id);
}
});
// Return structure for lookup: firstRuleIds set + flattened set of all duplicate IDs
const duplicateRuleIds = new Set(groups.flat().map((r) => r.id));
return { firstRuleIds, duplicateRuleIds };
// if (activeTab === "ticketcreate") groups = ticketCreationRuleGroups;
// else if (activeTab === "ticketupdate") groups = ticketUpdateRuleGroups;
// else if (activeTab === "hourly") groups = hourlyRuleGroups;
// // exact count of items on current page
// const count = flattenGroups(groupsToShow).length;
// console.log([Pagination] Duplicate mode per-page on tab '${activeTab}' page ${pageIndex + 1}: ${count});
// return count;
// };
// const getPaginationTotalCount = () => {
// if (ruleViewFilter.value === "duplicate_rules") {
// let groups = [];
// if (activeTab === "ticketcreate") groups = ticketCreationRuleGroups;
// else if (activeTab === "ticketupdate") groups = ticketUpdateRuleGroups;
// else if (activeTab === "hourly") groups = hourlyRuleGroups;
// if (activeTab === "ticketcreate") groups = ticketCreationRuleGroups;
// else if (activeTab === "ticketupdate") groups = ticketUpdateRuleGroups;
// else if (activeTab === "hourly") groups = hourlyRuleGroups;
let groups = [];
if (activeTab === "ticketcreate") groups = ticketCreationRuleGroups;
else if (activeTab === "ticketupdate") groups = ticketUpdateRuleGroups;
else if (activeTab === "hourly") groups = hourlyRuleGroups;
const paginatedGroups = paginateDuplicateGroups(groups, rulesPerPage, searchQuery);
const pageIndex = currentPage[activeTab] - 1;
let startItem = 1;
for (let i = 0; i < pageIndex; i++) {
const groupsToShow = paginatedGroups[i];
if (groupsToShow && groupsToShow.length > 0) {
startItem += flattenGroups(groupsToShow).length;
}
}
return startItem;
};
const getCurrentPageItemCount = (totalItems) => {
code
if (ruleViewFilter.value !== "duplicate_rules") {
const calculatedEnd = currentPage[activeTab] * rulesPerPage;
return Math.min(calculatedEnd, totalItems);
}
let groups = [];
if (activeTab === "ticketcreate") groups = ticketCreationRuleGroups;
else if (activeTab === "ticketupdate") groups = ticketUpdateRuleGroups;
else if (activeTab === "hourly") groups = hourlyRuleGroups;
const paginatedGroups = paginateDuplicateGroups(groups, rulesPerPage, searchQuery);
const pageIndex = currentPage[activeTab] - 1;
let cumulativeCount = 0;
for (let i = 0; i <= pageIndex; i++) {
const groupsToShow = paginatedGroups[i];
if (groupsToShow && groupsToShow.length > 0) {
cumulativeCount += flattenGroups(groupsToShow).length;
}
}
return cumulativeCount;
};
// const getCurrentPageItemCount = () => {
// if (ruleViewFilter.value !== "duplicate_rules") {
// return rulesPerPage;
// }
// let groups = [];
// if (activeTab === "ticketcreate") groups = ticketCreationRuleGroups;
// else if (activeTab === "ticketupdate") groups = ticketUpdateRuleGroups;
// else if (activeTab === "hourly") groups = hourlyRuleGroups;
// // Correct usage: Paginate the flattened list of items instead of the groups
// const currentPageIndex = currentPage[activeTab];
// const paginatedItems = paginateGroups(groups, rulesPerPage, currentPageIndex);
// // console.log("paginatedItems on groups :",JSON.stringify(paginatedItems,null,2))
// return paginatedItems.length; // Return the count of the items on the current page
// };
const getPaginationTotalCount = () => {
if (ruleViewFilter.value === "duplicate_rules") {
let groups = [];
if (activeTab === "ticketcreate") groups = ticketCreationRuleGroups;
else if (activeTab === "ticketupdate") groups = ticketUpdateRuleGroups;
else if (activeTab === "hourly") groups = hourlyRuleGroups;
let totalItemCount = 0;
for (const group of groups) {
const filteredGroup = group.filter(
(rule) =>
!searchQuery.trim() ||
rule.name?.toLowerCase().includes(searchQuery.toLowerCase()) ||
rule.description?.toLowerCase().includes(searchQuery.toLowerCase())
);
totalItemCount += filteredGroup.length;
}
return totalItemCount;
} else {
return getCurrentTotalCount();
}
};
// Helper function to paginate a single group of items
const paginateGroup = (group, itemsPerPage, currentPage) => {
const startIndex = (currentPage - 1) * itemsPerPage;
const endIndex = Math.min(startIndex + itemsPerPage, group.length);
return group.slice(startIndex, endIndex);
};
// Helper function to paginate groups (assuming groups are an array of arrays)
const paginateGroups = (groups, itemsPerPage, currentPage) => {
// Flatten the groups to paginate them as a single list
let allItems = [];
for (const group of groups) {
allItems = allItems.concat(group);
}
const startIndex = (currentPage - 1) * itemsPerPage;
const endIndex = Math.min(startIndex + itemsPerPage, allItems.length);
const pageItems = allItems.slice(startIndex, endIndex);
// Reconstruct the page based on the original group structure
const pageGroups = [];
let currentIndex = 0;
for (const group of groups) {
let groupIndex = 0;
while (groupIndex < group.length && pageItems.includes(group[groupIndex])) {
if (!pageGroups[pageGroups.length - 1] || pageGroups[pageGroups.length - 1].length >= itemsPerPage) {
pageGroups.push([]);
}
pageGroups[pageGroups.length - 1].push(group[groupIndex]);
groupIndex++;
}
currentIndex += group.length;
}
return pageItems;
};
in this code, now im in ticket update and im in Recent Data,
now if i delete a rule, make sure entity's of that tab should be sent to delete rule and find rule.id with rule.id of recent data so that i can confirm both rules
Assistant
To ensure that when you delete a rule in the "Recent Data" (fetchFromApi===true) mode for the current tab (say, "ticketupdate"), you correctly delete the entity from the DB and properly find the matching record to confirm the rule id, you need to be sure that:
You look up the entity record in the entity DB (newRulePloadDB6) by the matching rule id that corresponds to the rule id in recent data.
Then perform the deletion on that entity.
Right now, the deleteRule function finds the record like this:
So every record in recent loaded data has a display_id property, which you should use to delete the record from newRulePloadDB6.
User
ok that finding will work in fetchapi (recent data) now i need entity of ticket update, but if im in entity it should
Assistant
If I understand you correctly, you want the deleteRule function to:
In "Recent Data" mode (fetchFromApi === true):
Find the entity to delete using the rule's display_id (that came via recent data), and delete it from the entity DB (newRulePloadDB6).
In "Entity Data" mode (fetchFromApi === false):
You're working directly with the rules from the entity DB (the cached DB entries). In this case, the rule itself may be from the entity DB, so you may not need to look up by display_id separately—just delete it using the matching display_id or key available in the rule itself.
How to do that?
You want to make sure the delete logic covers both scenarios:
Recent Data: Find matched record by rule.id in allRulesList and delete by display_id.
Entity Data: rule itself is an entity record, so you can just delete by rule.display_id directly.
Here's a way to adjust your delete logic accordingly:
js
User
will that workin duplicate tab to
Assistant
Great question!
Will this approach work in the Duplicate Rules view/tab?
Short answer:
Yes, but with some clarifications and steps to ensure it behaves correctly.
Why special consideration for Duplicate Rules tab?
The Duplicate Rules view doesn't contain a flat list of rules but an array of groups (arrays) of rules detected as duplicates.
When you click delete on a rule inside a duplicate group, you still want to delete the exact item both in the UI and in the entity DB.
The list you pass to deleteRule must include those detailed rules, ideally flattened.
How to make sure it works?
Pass the correct allRulesList parameter to the deleteRule function:
In all_rules view: pass the flat filtered rules list.
In duplicate_rules view: pass the flattened groups of duplicates currently displayed.
For example, if you're rendering duplicate groups like:
In your deleteRule logic, use the same approach to find the display_id by matching rule.id in that allRulesList.
Update the groups and UI after deletion to remove the deleted rule from the grouped duplicates state.
Recap: Here's how you can integrate it
Rendering duplicate groups:
js
User
i need like this : on deleteing rule from recent api, it should send its active tab's entity data to delete rule and add console.log()
Assistant
Got it! You want this behavior:
When deleting a rule while viewing recent API data (fetchFromApi === true), instead of deleting only that single rule in isolation, you want to:
Send ALL the entity data of that active tab (i.e., the full list from entity DB - newRulePloadDB6) for that tab's automation type to the delete operation (or to your backend delete API).
Also add console.log() to log this entity data during delete for debugging purposes.
How to achieve this:
Step 1: Inside your deleteRule, detect if fetchFromApi === true.
Step 2: If yes, fetch the entire entity data for the active tab (from your entity DB ref newRulePloadDB6) and send that entity data to the delete API invocation (or just log as needed).
Example modification of deleteRule:
js
User
no use existing filtered values for separate tab as already done
Assistant
Got it! You want to reuse the existing entity data arrays (ticketUpdateRules, ticketCreationRules, or hourlyTriggerRules) in state for the active tab when deleting from recent data rather than fetching again.
So in deleteRule, if fetchFromApi is true (recent data mode), before calling delete API, you want to:
Use the existing entity data state corresponding to the active tab.
console.log() that entity data for the active tab.
Then proceed to delete the single rule.
How to do that:
Modify your deleteRule to accept another parameter: the entity data for the active tab, say entityDataForTab. Then inside deleteRule:
for (let part of parts) {
const cleaned = cleanText(part);
if (cleaned === "condition set 1") {
currentSet = set1;
continue;
}
if (cleaned === "condition set 2") {
currentSet = set2;
continue;
}
if (!currentSet) currentSet = set1;
const actionDetails = Array.isArray(rule.actions)
? rule.actions.map((a) => a.field_name?.toString().toLowerCase() || '').join(' ')
: ""; // or handle if it's string or other type if needed
Additionally, you can improve robustness by handling string action too, for example:
When calling deleteRule, ensure you're passing the correct list where each rule has a display_id.
Improving deleteRule for recent data:
To make sure deletion aligns properly between recent data and the entity DB, here is what you can do:
1. Detect if you are in "Recent Data" mode (fetchFromApi === true)
Inside your deleteRule function, add a check on fetchFromApi. Since this flag is in your component, either pass it into deleteRule or lift it as a ref or state.
If you are in recent data mode (fetchFromApi true), your list has display_id.
You find the exact entity record by display_id and delete the entity accordingly.
Then you invoke the backend deletion and update your state/UI accordingly.
If you want, I can help you with a complete updated snippet or integration. But essentially, pass fetchFromApi flag to your delete handler and ensure you delete the entity by display_id from your entity DB.
const deleteRule = async (rule, allRulesList, isRecentData) => {
const { id, display_id } = rule;
// ... get currentRules, setRulesFunc etc based on activeTab
if (newRulePloadDB6.current) {
let targetDisplayId = null;
if (isRecentData) {
const matchedRecord = allRulesList.find((rec) => rec.id === id);
targetDisplayId = matchedRecord?.display_id || null;
} else {
targetDisplayId = display_id || null;
}
if (targetDisplayId) {
try {
await newRulePloadDB6.current.delete(targetDisplayId);
} catch (err) {
console.error("Failed to delete from entity DB", err);
}
}
}
// Proceed with backend deletion and update UI state
// ... same as before
// For duplicate_rules view, recompute groups after deletion to update the UI:
if (ruleViewFilter.value === "duplicate_rules") {
const updatedGroups = groupDuplicates(updatedRules)
.filter((g) => g.length > 1)
.sort((a, b) => b.length - a.length);
groupSetterFunc(updatedGroups);
} else {
groupSetterFunc([]);
}
}
Bottom line
Your delete logic handles both recent data and entity data modes correctly.
For duplicate tab, pass the flattened list of duplicates on the current page as the allRulesList parameter to ensure the lookup by id and access to display_id works.
After deletion, correctly update both the flat state arrays and the grouped duplicates arrays to keep UI consistent.
If you want, I can help create a snippet that wraps your current paginated duplicate groups and delete handler fully integrated. Just ask!
const deleteRule = async (rule, allRulesList, isRecentData) => {
const { id, display_id } = rule;
let automationTypeId;
let currentRules,
setRulesFunc,
groupSetterFunc,
currentTabPage,
tabKey;
switch (activeTab) {
case "ticketcreate":
automationTypeId = ticketCreate;
currentRules = ticketCreationRules;
setRulesFunc = setTicketCreationRules;
groupSetterFunc = setTicketCreationRuleGroups;
currentTabPage = currentPage.ticketcreate;
tabKey = "ticketcreate";
break;
case "ticketupdate":
automationTypeId = ticketUpdate;
currentRules = ticketUpdateRules;
setRulesFunc = setTicketUpdateRules;
groupSetterFunc = setTicketUpdateRuleGroups;
currentTabPage = currentPage.ticketupdate;
tabKey = "ticketupdate";
break;
case "hourly":
automationTypeId = hourlyTriggers;
currentRules = hourlyTriggerRules;
setRulesFunc = setHourlyTriggerRules;
groupSetterFunc = setHourlyRuleGroups;
currentTabPage = currentPage.hourly;
tabKey = "hourly";
break;
default:
return;
}
// Read ALL entity data for this tab from the DB entity (only if fetchFromApi mode)
let allEntitiesForTab = null;
if (isRecentData && newRulePloadDB6.current) {
try {
// Query entity DB for all records with this automationTypeId
// You have a function for this Filterrecords - reuse it
allEntitiesForTab = await Filterrecords(automationTypeId, newRulePloadDB6.current);
console.log(`Deleting rule from recent API mode. Sending whole entity data for "${tabKey}":`, allEntitiesForTab);
} catch (err) {
console.error("Failed to fetch entity data during delete:", err);
}
}
// Delete entity record for the specific rule
if (newRulePloadDB6.current) {
let targetDisplayId = null;
if (isRecentData) {
// recent data: find record with display_id from allRulesList
const matchedRecord = allRulesList.find((rec) => rec.id === id);
targetDisplayId = matchedRecord?.display_id || null;
} else {
// entity mode: rule itself should have display_id
targetDisplayId = display_id || null;
}
if (targetDisplayId) {
try {
await newRulePloadDB6.current.delete(targetDisplayId);
} catch (err) {
console.error("Failed to delete from entity DB", err);
}
}
}
// Invoke backend API for deleting a single rule
try {
const response = await client.request.invokeTemplate("deleterule", {
context: {
automationid: automationTypeId,
ruleid: id,
// optionally send the full entity data too
fullEntityData: allEntitiesForTab, // only meaningful if backend expects it
},
});
if (response.status === 204) {
// Update UI and groups same as before
const updatedRules = currentRules.filter((r) => r.id !== id);
setRulesFunc(updatedRules);
if (ruleViewFilter.value === "duplicate_rules") {
const updatedGroups = groupDuplicates(updatedRules)
.filter((g) => g.length > 1)
.sort((a, b) => b.length - a.length);
groupSetterFunc(updatedGroups);
} else {
groupSetterFunc([]);
}
toast.current.trigger({ type: "success", content: "Rule deleted successfully!" });
} else {
toast.current.trigger({ type: "error", content: "Failed to delete rule." });
}
} catch (error) {
console.error(error);
toast.current.trigger({ type: "error", content: "Error deleting rule." });
}
};
function extractText(htmlString) {
if (!htmlString || typeof htmlString !== "string") return "";
let text = htmlString.replace(/<[^>]+>/g, "").trim();
code
if (text.toLowerCase().startsWith("if ")) {
text = text.substring(3).trim();
}
// console.log("Actual Text :", text);
return text; // do not convert to lowercase here
}
function generateSummary(summary) {
if (!summary) return "";
if (typeof summary === "string") {
return summary;
}
let conditionTexts = [];
if (summary.conditions) {
for (const setKey in summary.conditions) {
if (Object.prototype.hasOwnProperty.call(summary.conditions, setKey)) {
const conditionsVal = summary.conditions[setKey];
const conditionsArray = Array.isArray(conditionsVal) ? conditionsVal : [conditionsVal];
const cleanConditions = conditionsArray.map(extractText);
conditionTexts.push(cleanConditions.join(", "));
}
}
}
const conditionsStr = conditionTexts.join(", ");
let actionsStr = "";
if (summary.actions && Array.isArray(summary.actions)) {
const cleanActions = summary.actions.map(extractText);
actionsStr = cleanActions.join(", ");
}
if (conditionsStr && actionsStr) {
return if ${conditionsStr}, then ${actionsStr};
} else if (conditionsStr) {
return if ${conditionsStr};
} else if (actionsStr) {
return actionsStr;
}
return "";
}
const duplicateGroupsMap = useMemo(() => {
// groups: array of arrays of duplicate rules with length > 1
let allRules = [];
if (activeTab === "ticketcreate") allRules = ticketCreationRules;
else if (activeTab === "ticketupdate") allRules = ticketUpdateRules;
else if (activeTab === "hourly") allRules = hourlyTriggerRules;
code
// group duplicates, filtered active only
const groups = groupDuplicates(allRules).filter((g) => g.length > 1);
// Map rule_id -> isFirstInGroup flag (true only for first rule of each duplicate group)
const firstRuleIds = new Set();
groups.forEach((group) => {
if (group.length > 0) {
firstRuleIds.add(group[0].id);
}
});
// Return structure for lookup: firstRuleIds set + flattened set of all duplicate IDs
const duplicateRuleIds = new Set(groups.flat().map((r) => r.id));
return { firstRuleIds, duplicateRuleIds };
// if (activeTab === "ticketcreate") groups = ticketCreationRuleGroups;
// else if (activeTab === "ticketupdate") groups = ticketUpdateRuleGroups;
// else if (activeTab === "hourly") groups = hourlyRuleGroups;
// // exact count of items on current page
// const count = flattenGroups(groupsToShow).length;
// console.log([Pagination] Duplicate mode per-page on tab '${activeTab}' page ${pageIndex + 1}: ${count});
// return count;
// };
// const getPaginationTotalCount = () => {
// if (ruleViewFilter.value === "duplicate_rules") {
// let groups = [];
// if (activeTab === "ticketcreate") groups = ticketCreationRuleGroups;
// else if (activeTab === "ticketupdate") groups = ticketUpdateRuleGroups;
// else if (activeTab === "hourly") groups = hourlyRuleGroups;
// if (activeTab === "ticketcreate") groups = ticketCreationRuleGroups;
// else if (activeTab === "ticketupdate") groups = ticketUpdateRuleGroups;
// else if (activeTab === "hourly") groups = hourlyRuleGroups;
let groups = [];
if (activeTab === "ticketcreate") groups = ticketCreationRuleGroups;
else if (activeTab === "ticketupdate") groups = ticketUpdateRuleGroups;
else if (activeTab === "hourly") groups = hourlyRuleGroups;
const paginatedGroups = paginateDuplicateGroups(groups, rulesPerPage, searchQuery);
const pageIndex = currentPage[activeTab] - 1;
let startItem = 1;
for (let i = 0; i < pageIndex; i++) {
const groupsToShow = paginatedGroups[i];
if (groupsToShow && groupsToShow.length > 0) {
startItem += flattenGroups(groupsToShow).length;
}
}
return startItem;
};
const getCurrentPageItemCount = (totalItems) => {
code
if (ruleViewFilter.value !== "duplicate_rules") {
const calculatedEnd = currentPage[activeTab] * rulesPerPage;
return Math.min(calculatedEnd, totalItems);
}
let groups = [];
if (activeTab === "ticketcreate") groups = ticketCreationRuleGroups;
else if (activeTab === "ticketupdate") groups = ticketUpdateRuleGroups;
else if (activeTab === "hourly") groups = hourlyRuleGroups;
const paginatedGroups = paginateDuplicateGroups(groups, rulesPerPage, searchQuery);
const pageIndex = currentPage[activeTab] - 1;
let cumulativeCount = 0;
for (let i = 0; i <= pageIndex; i++) {
const groupsToShow = paginatedGroups[i];
if (groupsToShow && groupsToShow.length > 0) {
cumulativeCount += flattenGroups(groupsToShow).length;
}
}
return cumulativeCount;
};
// const getCurrentPageItemCount = () => {
// if (ruleViewFilter.value !== "duplicate_rules") {
// return rulesPerPage;
// }
// let groups = [];
// if (activeTab === "ticketcreate") groups = ticketCreationRuleGroups;
// else if (activeTab === "ticketupdate") groups = ticketUpdateRuleGroups;
// else if (activeTab === "hourly") groups = hourlyRuleGroups;
// // Correct usage: Paginate the flattened list of items instead of the groups
// const currentPageIndex = currentPage[activeTab];
// const paginatedItems = paginateGroups(groups, rulesPerPage, currentPageIndex);
// // console.log("paginatedItems on groups :",JSON.stringify(paginatedItems,null,2))
// return paginatedItems.length; // Return the count of the items on the current page
// };
const getPaginationTotalCount = () => {
if (ruleViewFilter.value === "duplicate_rules") {
let groups = [];
if (activeTab === "ticketcreate") groups = ticketCreationRuleGroups;
else if (activeTab === "ticketupdate") groups = ticketUpdateRuleGroups;
else if (activeTab === "hourly") groups = hourlyRuleGroups;
let totalItemCount = 0;
for (const group of groups) {
const filteredGroup = group.filter(
(rule) =>
!searchQuery.trim() ||
rule.name?.toLowerCase().includes(searchQuery.toLowerCase()) ||
rule.description?.toLowerCase().includes(searchQuery.toLowerCase())
);
totalItemCount += filteredGroup.length;
}
return totalItemCount;
} else {
return getCurrentTotalCount();
}
};
// Helper function to paginate a single group of items
const paginateGroup = (group, itemsPerPage, currentPage) => {
const startIndex = (currentPage - 1) * itemsPerPage;
const endIndex = Math.min(startIndex + itemsPerPage, group.length);
return group.slice(startIndex, endIndex);
};
// Helper function to paginate groups (assuming groups are an array of arrays)
const paginateGroups = (groups, itemsPerPage, currentPage) => {
// Flatten the groups to paginate them as a single list
let allItems = [];
for (const group of groups) {
allItems = allItems.concat(group);
}
const startIndex = (currentPage - 1) * itemsPerPage;
const endIndex = Math.min(startIndex + itemsPerPage, allItems.length);
const pageItems = allItems.slice(startIndex, endIndex);
// Reconstruct the page based on the original group structure
const pageGroups = [];
let currentIndex = 0;
for (const group of groups) {
let groupIndex = 0;
while (groupIndex < group.length && pageItems.includes(group[groupIndex])) {
if (!pageGroups[pageGroups.length - 1] || pageGroups[pageGroups.length - 1].length >= itemsPerPage) {
pageGroups.push([]);
}
pageGroups[pageGroups.length - 1].push(group[groupIndex]);
groupIndex++;
}
currentIndex += group.length;
}
return pageItems;
};
AutomationTabs.js:710 Uncaught TypeError: (rule.actions || []).map is not a function
at AutomationTabs.js:710:14
at Array.filter ()
at AutomationTabs.js:660:15
at Array.map ()
at paginateDuplicateGroups (AutomationTabs.js:659:8)
at renderRulesOrGroups (AutomationTabs.js:1132:29)
at AutomationTabs (AutomationTabs.js:2398:14)
react-dom.development.js:20085 The above error occurred in the component:
code
at AutomationTabs (http://localhost:10001/iframe/agent/scripts/main.15ba9862.js:1258:22)
at div
at div
at App (http://localhost:10001/iframe/agent/scripts/main.15ba9862.js:51:21)
at Root (http://localhost:10001/iframe/agent/scripts/main.15ba9862.js:4683:21)
Consider adding an error boundary to your tree to customize error handling behavior.
Visit https://reactjs.org/link/error-boundaries to learn more about error boundaries.
react-dom.development.js:11340 Uncaught TypeError: (rule.actions || []).map is not a function
at AutomationTabs.js:710:14
at Array.filter ()
at AutomationTabs.js:660:15
at Array.map ()
at paginateDuplicateGroups (AutomationTabs.js:659:8)
at renderRulesOrGroups (AutomationTabs.js:1132:29)
at AutomationTabs (AutomationTabs.js:2398:14)
Applying similar safety elsewhere
Anywhere you use .map(), wrap the array with Array.isArray() check.
Summary of fix:
Change paginateDuplicateGroups function lines around 710 from: