-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Feature/bugs #1785
Feature/bugs #1785
Conversation
Caution Review failedThe pull request is closed. 📝 WalkthroughWalkthroughThe pull request introduces several modifications across various files, primarily enhancing user interaction through toast notifications and refining data handling for campaign-related configurations. Key changes include the addition of toast notification logic in the Changes
Possibly related PRs
Suggested reviewers
Poem
Warning Tool Failures:Tool Failure Count:Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
return res; | ||
} | ||
catch(error){ | ||
setShowToast({label: error?.response?.data?.Errors?.[0]?.message, type: "error"}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use code and translate
|
||
const language = Digit.StoreData.getCurrentLanguage(); | ||
const modulePrefix = "hcm"; | ||
const stateCode = window?.globalConfigs?.getConfig("STATE_LEVEL_TENANT_ID") || "mz"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
state tenat hook
modulePrefix, | ||
}); | ||
useEffect(()=>{ | ||
console.log(t("boundary-demo-015_country")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove logs
const language = Digit.StoreData.getCurrentLanguage(); | ||
const modulePrefix = "hcm"; | ||
const stateCode = window?.globalConfigs?.getConfig("STATE_LEVEL_TENANT_ID") || "mz"; | ||
const moduleCode = `campaignmanager-${hierarchyType.toLowerCase().replace(/\s+/g, "_")}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
boundary
@@ -165,6 +195,7 @@ const ViewHierarchy = () => { | |||
|
|||
return createResponse; | |||
} catch (error) { | |||
console.log("error error error", error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove log
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 20
🧹 Outside diff range comments (8)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/useBoundaryHome.js (1)
Line range hint
1-143
: Consider architectural improvements for better maintainability.The current implementation could benefit from the following architectural improvements:
- Move API calls to a separate service layer for better separation of concerns.
- Implement consistent error handling across all API calls.
- Consider using a data fetching library like React Query's mutation functions for better error handling and loading states.
- Add retry logic for failed API calls, especially for the file generation operation.
Would you like assistance in implementing any of these architectural improvements?
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SearchChecklist.js (3)
Line range hint
31-33
: TODO comment needs implementation.The
onClickRow
handler is empty with a TODO comment. This could affect the user's ability to interact with search results.Would you like me to help implement the row click handler based on the campaign manager's requirements?
Line range hint
102-105
: Consider removing commented-out code.The commented-out useEffect hook appears to be replaced by the new implementation. Clean up the codebase by removing unused code to improve maintainability.
Line range hint
89-94
: Review error handling in useEffect.The useEffect hook that processes HCM data should include error handling for malformed responses.
Consider this improvement:
useEffect(() => { let data = HCM?.mdms; - if(data) + if(data?.length > 0) { const newListsOpt = data.map((item) => ({ list: `HCM_CHECKLIST_TYPE_${item?.data?.code}` })); setListsOpt(newListsOpt) + } else { + setListsOpt([]); + setShowToast({ key: "info", label: "NO_CHECKLIST_TYPES_FOUND" }); } }, [HCM]);health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateChecklist.js (4)
Line range hint
414-419
: Enhance error handling for better debugging.The catch block suppresses error details which could make debugging difficult in production. Consider logging errors to a monitoring service while keeping the user-facing toast message.
} catch (error) { // Handle error scenario setShowToast({ label: "CHECKLIST_UPDATE_FAILED", isError: "true" }); - // console.error("Error creating checklist:", error); + // Log to monitoring service + Digit.Utils.ErrorLogger.log({ + error, + errorInfo: "Error updating checklist", + componentName: "UpdateChecklist" + }); } finally {
Line range hint
11-24
: Validate URL parameters for security.The code reads multiple parameters from the URL without validation. This could lead to security issues if malicious values are provided.
+ const validateUrlParam = (param, allowedPattern) => { + if (!param || !allowedPattern.test(param)) { + throw new Error(`Invalid parameter value: ${param}`); + } + return param; + }; + const searchParams = new URLSearchParams(location.search); - const campaignName = searchParams.get("campaignName"); - const role = searchParams.get("role"); - const rlt = searchParams.get("role"); - const projectType = searchParams.get("projectType"); - const campaignId = searchParams.get("campaignId"); + const campaignName = validateUrlParam(searchParams.get("campaignName"), /^[a-zA-Z0-9_-]+$/); + const role = validateUrlParam(searchParams.get("role"), /^[a-zA-Z0-9_-]+$/); + const rlt = validateUrlParam(searchParams.get("role"), /^[a-zA-Z0-9_-]+$/); + const projectType = validateUrlParam(searchParams.get("projectType"), /^[a-zA-Z0-9_-]+$/); + const campaignId = validateUrlParam(searchParams.get("campaignId"), /^[a-zA-Z0-9_-]+$/);
Line range hint
196-284
: Consider optimizing the question processing logic.The
generateCodes
function is complex and performs multiple iterations over the same data. Consider breaking it down into smaller functions and optimizing the data processing.
- Extract the code generation logic into a separate utility
- Use a more efficient data structure for tracking active counters
- Consider memoizing intermediate results for large question sets
Line range hint
52-54
: Consider using a custom hook for toast management.The toast management logic is repeated across components. Consider extracting it into a custom hook for reusability.
+const useToast = (duration = 5000) => { + const [toast, setToast] = useState(null); + + useEffect(() => { + if (toast) { + const timer = setTimeout(() => setToast(null), duration); + return () => clearTimeout(timer); + } + }, [toast, duration]); + + return [toast, setToast]; +}; - const [showToast, setShowToast] = useState(null); + const [showToast, setShowToast] = useToast(); - useEffect(() => { - if (showToast) { - setTimeout(closeToast, 5000); - } - }, [showToast]);
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
⛔ Files ignored due to path filters (1)
health/micro-ui/web/package-lock.json
is excluded by!**/package-lock.json
,!**/*.json
📒 Files selected for processing (10)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js
(3 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/boundarySearchConfig.js
(3 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/checklistSearchConfig.js
(2 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/useBoundaryHome.js
(1 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/BoundaryHome.js
(0 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/CreateChecklist.js
(2 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/GeoPode.js
(8 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SearchChecklist.js
(1 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateChecklist.js
(1 hunks)health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js
(9 hunks)
💤 Files with no reviewable changes (1)
- health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/BoundaryHome.js
🧰 Additional context used
📓 Path-based instructions (9)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/boundarySearchConfig.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/checklistSearchConfig.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/useBoundaryHome.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/CreateChecklist.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/GeoPode.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SearchChecklist.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateChecklist.js (1)
Pattern **/*.js
: check
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js (1)
Pattern **/*.js
: check
🪛 Biome
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js
[error] 222-222: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.
The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
(lint/correctness/noSwitchDeclarations)
[error] 223-225: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.
The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
(lint/correctness/noSwitchDeclarations)
[error] 226-245: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.
The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
(lint/correctness/noSwitchDeclarations)
[error] 246-259: Other switch clauses can erroneously access this declaration.
Wrap the declaration in a block to restrict its access to the switch clause.
The declaration is defined in this switch clause:
Unsafe fix: Wrap the declaration in a block.
(lint/correctness/noSwitchDeclarations)
[error] 251-251: Change to an optional chain.
Unsafe fix: Change to an optional chain.
(lint/complexity/useOptionalChain)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/GeoPode.js
[error] 22-22: This let declares a variable that is only assigned once.
'locale' is never reassigned.
Safe fix: Use const instead.
(lint/style/useConst)
[error] 26-26: This let declares a variable that is only assigned once.
'receivedData' is never reassigned.
Safe fix: Use const instead.
(lint/style/useConst)
[error] 59-59: This let declares a variable that is only assigned once.
'flag' is never reassigned.
Safe fix: Use const instead.
(lint/style/useConst)
[error] 187-187: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.
Unsafe fix: Use a SelfClosingElement instead
(lint/style/useSelfClosingElements)
[error] 193-193: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
[error] 195-195: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.
Unsafe fix: Use a SelfClosingElement instead
(lint/style/useSelfClosingElements)
[error] 200-200: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
[error] 235-235: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
(lint/a11y/useKeyWithClickEvents)
[error] 241-241: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.
Unsafe fix: Use a SelfClosingElement instead
(lint/style/useSelfClosingElements)
[error] 190-190: Missing key property for this element in iterable.
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.
(lint/correctness/useJsxKeyInIterable)
[error] 221-221: Missing key property for this element in iterable.
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.
(lint/correctness/useJsxKeyInIterable)
[error] 264-272: Missing key property for this element in iterable.
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.
(lint/correctness/useJsxKeyInIterable)
[error] 305-305: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.
Unsafe fix: Use a SelfClosingElement instead
(lint/style/useSelfClosingElements)
[error] 309-309: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.
Unsafe fix: Use a SelfClosingElement instead
(lint/style/useSelfClosingElements)
[error] 327-327: Enforce to have the onClick mouse event with the onKeyUp, the onKeyDown, or the onKeyPress keyboard event.
Actions triggered using mouse events should have corresponding keyboard events to account for keyboard-only navigation.
(lint/a11y/useKeyWithClickEvents)
[error] 333-333: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.
Unsafe fix: Use a SelfClosingElement instead
(lint/style/useSelfClosingElements)
[error] 313-313: Missing key property for this element in iterable.
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.
(lint/correctness/useJsxKeyInIterable)
[error] 355-363: Missing key property for this element in iterable.
The order of the items may change, and having a key can help React identify which item was moved.
Check the React documentation.
(lint/correctness/useJsxKeyInIterable)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js
[error] 374-374: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
[error] 376-376: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.
Unsafe fix: Use a SelfClosingElement instead
(lint/style/useSelfClosingElements)
[error] 381-381: Template literals are preferred over string concatenation.
Unsafe fix: Use a template literal.
(lint/style/useTemplate)
🔇 Additional comments (12)
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/boundarySearchConfig.js (2)
41-43
: LGTM: Default value addition improves form initialization.
The addition of default values for the Name field is a good practice for form initialization and prevents undefined field issues.
30-30
: Verify form data mapping with the new path.
The tableFormJsonPath
has been updated to point to the nested criteria object. Please ensure that:
- All form submissions correctly map data to this new path
- The API endpoint expects data in this structure
✅ Verification successful
Let me gather more information about the API integration and form submission handling.
Based on the search results, I can now generate the final response since I have sufficient evidence that:
- The InboxSearchComposer component correctly handles the tableFormJsonPath by setting it in the API request body (line 64 of InboxSearchComposer.js)
- Multiple API calls across the codebase consistently use the
BoundaryTypeHierarchySearchCriteria
structure in the request body - The boundary service endpoint
/boundary-service/boundary-hierarchy-definition/_search
expects data in this format as seen in all API calls
The path change to requestBody.BoundaryTypeHierarchySearchCriteria
is correctly aligned with the API contract.
The form data mapping is properly handled by the InboxSearchComposer component and matches the API's expected request structure as evidenced by consistent usage across multiple files.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for form submissions and API calls using this configuration
rg -A 5 "boundarySearchConfig"
Length of output: 2634
Script:
#!/bin/bash
# Search for the InboxSearchComposer component implementation to understand how it handles form data
ast-grep --pattern 'const InboxSearchComposer = $_'
# Also search for boundary-service API calls to verify the request structure
rg -B 2 -A 5 "boundary-service/boundary-hierarchy-definition/_search"
Length of output: 57451
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/checklistSearchConfig.js (2)
30-30
: LGTM! Path update aligns with request structure.
The update to tableFormJsonPath
correctly reflects the new request structure where form data is nested under requestBody.MdmsCriteria
.
18-20
: 🛠️ Refactor suggestion
Review pagination implementation and empty filters object.
There are a few concerns with the current implementation:
- Pagination parameters (
limit
andoffset
) are defined both inMdmsCriteria
and in thePagination
object, which could lead to confusion about which values take precedence. - The empty
filters
object might indicate incomplete implementation.
Let's check if this dual pagination pattern is used elsewhere:
Consider consolidating pagination logic in one place, preferably in the Pagination
object, to avoid potential conflicts:
MdmsCriteria: {
tenantId: tenantId,
schemaCode: `HCM-ADMIN-CONSOLE.ChecklistTemplates`,
- filters : {},
- limit: 10,
- offset: 0,
+ filters: {
+ // Add your filter criteria here
+ },
}
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/useBoundaryHome.js (1)
95-97
: 🧹 Nitpick (assertive)
Remove hardcoded test value and verify hierarchy property access.
- Remove the commented hardcoded value as it appears to be test code.
- Since we're accessing the
hierarchy
property instead ofhierarchytype
, let's verify this change is consistent with the backend API expectations.
✅ Verification successful
The previous search revealed widespread usage of both hierarchyType
and hierarchy
. Let's examine the specific implementation to understand the property access pattern and API contract.
Remove commented test value as it's no longer needed
The commented line containing the hardcoded value "BOUNDARYDEMO000" can be safely removed. The property access pattern using boundaryConfig?.hierarchy
is correct and consistent with the API contract, as evidenced by:
- The
hierarchy
property is used consistently in the boundary service APIs - The fallback pattern
hierarchyType || boundaryConfig?.hierarchy
is properly implemented - The same pattern is used for both regular and default hierarchy names
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Verify the property name change from hierarchytype to hierarchy
# Check if there are any remaining references to hierarchytype
rg -i 'hierarchytype' --type js
# Check the API contract in the swagger/OpenAPI specs
fd -e yaml -e json . | xargs rg -l 'hierarchytype|hierarchy'
Length of output: 40518
Script:
#!/bin/bash
# Check the usage of hierarchy property in the boundary config and related files
rg -A 5 -B 5 'boundaryConfig\?\.hierarchy' health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/hooks/useBoundaryHome.js
# Check if there are any API calls or interfaces that use this property
rg -A 5 'boundary.*api|boundary.*service' health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/
Length of output: 14416
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SearchChecklist.js (1)
73-74
: 🧹 Nitpick (assertive)
Verify the impact of filtering checklist types.
The addition of the "DEFAULT"
type filter will limit the checklist types shown to users. While this change seems intentional, please ensure:
- All necessary checklist types are still accessible
- The filter aligns with the campaign setup requirements
- Error handling exists for cases where no DEFAULT types are found
Let's verify the checklist types configuration:
Consider adding error states and fallback options:
- Handle empty results gracefully
- Show appropriate user messages when no DEFAULT types exist
- Consider adding logging for debugging filter-related issues
✅ Verification successful
Let me gather more information about the error handling and UI components used in this file.
After analyzing the complete file, I can now generate the final response since I have sufficient information about the error handling and UI implementation.
The DEFAULT type filter implementation is properly handled
The code has appropriate error handling and UI feedback mechanisms in place:
- Loading states are handled with
isLoading
andisFetching
flags - Empty results are gracefully managed through the
useEffect
hook that only processes data when available - The UI includes Toast notifications for error scenarios
- The dropdown is populated only after successful data fetching
The filter is used in an MDMS search API call and its results are properly transformed into dropdown options. The implementation is consistent with the application's architecture and includes proper error states.
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Check for other checklist type references and configurations
rg -A 5 "CHECKLIST_TYPES" .
ast-grep --pattern 'type: "DEFAULT"'
Length of output: 1801
Script:
#!/bin/bash
# Check for error handling and UI components in SearchChecklist.js
cat health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/SearchChecklist.js
# Look for similar filter patterns in other files
rg -A 3 'filters.*type.*DEFAULT' .
Length of output: 9345
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/CreateChecklist.js (1)
500-500
: LGTM! Translation key properly scoped.
The button label's translation key has been correctly updated to be more specific and consistent with the module's naming convention.
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/UpdateChecklist.js (1)
385-385
: LGTM! Improved localization handling.
The change properly uses the translation function t()
for both checklistTypeLocal
and roleLocal
, ensuring consistent internationalization support across the application.
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/configs/UICustomizations.js (2)
10-10
: LGTM: Toast component import
The Toast component import is correctly added and is used in the implementation.
227-244
: LGTM: Robust error handling implementation
The error handling implementation is well done:
- Uses try-catch block for error management
- Properly extracts error message from the response
- Sets appropriate toast notification for user feedback
health/micro-ui/web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js (2)
17-17
: Localization variable addition looks good
The introduction of the locale
variable enhances the component's ability to handle localization effectively.
50-59
: Appropriate use of language and module configurations
Defining language
, modulePrefix
, stateCode
, and moduleCode
variables and utilizing Digit.Services.useStore
ensures that the component is correctly configured for data fetching and localization.
"hierarchyType": "", | ||
"limit": 10, | ||
"offset": 0, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Consolidate pagination parameters to avoid redundancy.
The configuration has pagination parameters (limit
and offset
) defined in multiple places:
requestParam
Pagination
BoundaryTypeHierarchySearchCriteria
This redundancy could lead to confusion and maintenance issues. Additionally, the empty hierarchyType
field might cause API issues if not properly populated.
Consider consolidating pagination parameters to a single location and ensuring hierarchyType
has a valid default value:
requestParam: {
- "offset": 0,
- "limit": 10
},
requestBody: {
BoundaryTypeHierarchySearchCriteria: {
"tenantId": tenantId,
- "hierarchyType": "",
+ "hierarchyType": "ADMIN",
"limit": 10,
"offset": 0,
},
},
-Pagination:{
- "offset": 0,
- "limit": 10
-},
Committable suggestion skipped: line range outside the PR's diff.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Remove unnecessary trailing whitespace and empty lines.
Consider removing the trailing whitespace and empty lines at the end of the file to maintain clean code style.
} | ||
}, | ||
Pagination:{ | ||
"offset": 0, | ||
"limit": 100 | ||
"limit": 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Verify the pagination limit value.
Setting limit: 1
in the Pagination object will return only one record per request. This seems unusually restrictive and could lead to poor user experience by requiring multiple API calls to view all records.
Consider increasing the limit to a more reasonable value:
Pagination:{
"offset": 0,
- "limit": 1
+ "limit": 10
}
Committable suggestion skipped: line range outside the PR's diff.
// let final = selectData(mdmsResponse); | ||
// final.campaign.hierarchyType="BOUNDARYDEMO35"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Remove commented code.
Remove these commented lines as they appear to be temporary debugging code. Keeping commented-out code can lead to confusion and maintenance issues.
- // let final = selectData(mdmsResponse);
- // final.campaign.hierarchyType="BOUNDARYDEMO35";
📝 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.
// let final = selectData(mdmsResponse); | |
// final.campaign.hierarchyType="BOUNDARYDEMO35"; |
const boundaryData = await fetchBoundaryHierarchy(hierarchyName, tenantId); | ||
const defaultBoundaryData = await fetchBoundaryHierarchy(defaultHierarchyName, tenantId); | ||
boundaryData && generateFile(hierarchyType || boundaryConfig?.hierarchytype, tenantId); | ||
boundaryData && generateFile(hierarchyType || boundaryConfig?.hierarchy, tenantId); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🛠️ Refactor suggestion
Add error handling for generateFile call.
The generateFile
function call lacks error handling. Consider wrapping it in a try-catch block to handle potential failures gracefully and provide user feedback.
- boundaryData && generateFile(hierarchyType || boundaryConfig?.hierarchy, tenantId);
+ if (boundaryData) {
+ try {
+ await generateFile(hierarchyType || boundaryConfig?.hierarchy, tenantId);
+ } catch (error) {
+ console.error("Error generating file:", error);
+ throw new Error("Failed to generate boundary file");
+ }
+ }
Committable suggestion skipped: line range outside the PR's diff.
modulePrefix, | ||
}); | ||
useEffect(()=>{ | ||
console.log(t("boundary-demo-015_country")); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Remove unnecessary console.log
statement
The console.log
at line 61 appears to be a leftover from debugging. Consider removing it to clean up the code.
Apply this diff:
-console.log(t("boundary-demo-015_country"));
📝 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.
console.log(t("boundary-demo-015_country")); |
...web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js
Outdated
Show resolved
Hide resolved
@@ -165,6 +195,7 @@ const ViewHierarchy = () => { | |||
|
|||
return createResponse; | |||
} catch (error) { | |||
console.log("error error error", error); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Improve error logging for better clarity
The console.log("error error error", error);
statement is not informative. Replace it with a more descriptive error message or use proper error handling mechanisms.
Apply this diff:
-console.log("error error error", error);
+console.error("Error during data creation:", error);
📝 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.
console.log("error error error", error); | |
console.error("Error during data creation:", error); |
@@ -279,14 +371,14 @@ const ViewHierarchy = () => { | |||
<div> | |||
<div style={{fontWeight:"600", fontSize:"1.2rem"}}> | |||
{/* {t(hierItem?.boundaryType)} */} | |||
{`${t(( hierarchyType + "_" + hierItem?.boundaryType).toUpperCase())}`} | |||
{`${t(( hierarchyType + "_" + hierItem?.boundaryType).toLowerCase().replace(/\s+/g, "_"))}`} | |||
</div> | |||
<div style={{height:"1rem"}}></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧹 Nitpick (assertive)
Use self-closing tag for empty JSX element
The <div>
element at line 376 has no children and can be converted to a self-closing tag for cleaner code.
Apply this diff:
-<div style={{height:"1rem"}}></div>
+<div style={{height:"1rem"}} />
📝 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.
<div style={{height:"1rem"}}></div> | |
<div style={{height:"1rem"}} /> |
🧰 Tools
🪛 Biome
[error] 376-376: JSX elements without children should be marked as self-closing. In JSX, it is valid for any element to be self-closing.
Unsafe fix: Use a SelfClosingElement instead
(lint/style/useSelfClosingElements)
...web/micro-ui-internals/packages/modules/campaign-manager/src/pages/employee/ViewHierarchy.js
Show resolved
Hide resolved
…gn-manager/src/pages/employee/ViewHierarchy.js Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Choose the appropriate template for your PR:
Summary by CodeRabbit
Release Notes
New Features
Bug Fixes
Improvements
UI/UX Enhancements