-
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
fix the setup master , edit master button rendring logic #1940
base: develop
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughThe changes in this pull request primarily focus on the Changes
Possibly related PRs
Suggested reviewers
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 (
|
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: 0
🧹 Outside diff range comments (3)
micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/SetupMaster.js (3)
Line range hint
89-106
: Enhance error handling inhandleSetupMaster
The error handling in the
onError
callback could be improved:
- Console logging isn't helpful for users
- The error message shown to users is generic and doesn't include specific error details
Consider this improvement:
onError: (error, variables) => { - console.log(error); setShowPopUp({ key: "error", alertHeading: "DEFAULT_MASTER_SETUP_ERROR", - description: "DEFAULT_MASTER_SETUP_ERROR_DESC", + description: error?.message || "DEFAULT_MASTER_SETUP_ERROR_DESC", subHeading: "DEFAULT_MASTER_SETUP_ERROR_SUBH", heading: "DEFAULT_MASTER_SETUP_ERROR_HEAD", secondaryText: "DEFAULT_MASTER_SETUP_ERROR_TEXT", iconFill: "red", customIcon: "", buttonLabel: "DEFAULT_MASTER_SETUP_ERROR_BUTTON_LABEL", }); + Digit.Utils.notificationHandler.error(error?.message || "DEFAULT_MASTER_SETUP_ERROR_DESC"); },
Line range hint
192-236
: Remove commented codeThere are commented-out code sections that should be removed to maintain code cleanliness:
- Commented table column configuration
- Commented icon prop in Button component
Apply this cleanup:
- // { - // Header: "Type", - // accessor: "type", - // id: "type", - // }, { Header: "Description", accessor: "description", id: "description", }, className="actionButton" label={isUserExist ? t("EDIT_MASTER") : t("SETUP_MASTER")} variation={"primary"} - // icon="ArrowForward" isSuffix={true}
Line range hint
19-21
: Consider using a reducer for popup state managementThe current popup state management using
useState
could be improved for better maintainability. The popup configurations are repeated in both success and error handlers.Consider using a reducer to manage popup states:
const popupReducer = (state, action) => { switch (action.type) { case 'SHOW_SUCCESS': return { key: "success", alertHeading: "DEFAULT_MASTER_SETUP_SUCCESS_ALERT", description: "DEFAULT_MASTER_SETUP_SUCCESS_DESC", subHeading: "DEFAULT_MASTER_SETUP_SUCCESS_SUBH", heading: "DEFAULT_MASTER_SETUP_SUCCESS_HEAD", secondaryText: "DEFAULT_MASTER_SETUP_SUCCESS_TEXT", iconFill: "green", customIcon: "CheckCircle", buttonLabel: "DEFAULT_MASTER_SUCCESS_BUTTON_LABEL", }; case 'SHOW_ERROR': return { key: "error", alertHeading: "DEFAULT_MASTER_SETUP_ERROR", description: action.payload?.message || "DEFAULT_MASTER_SETUP_ERROR_DESC", subHeading: "DEFAULT_MASTER_SETUP_ERROR_SUBH", heading: "DEFAULT_MASTER_SETUP_ERROR_HEAD", secondaryText: "DEFAULT_MASTER_SETUP_ERROR_TEXT", iconFill: "red", customIcon: "", buttonLabel: "DEFAULT_MASTER_SETUP_ERROR_BUTTON_LABEL", }; case 'HIDE': return null; default: return state; } };Then use it in your component:
-const [showPopUp, setShowPopUp] = useState(null); +const [showPopUp, dispatch] = useReducer(popupReducer, null); // In error handler: -setShowPopUp({...}) +dispatch({ type: 'SHOW_ERROR', payload: error }) // In success handler: -setShowPopUp({...}) +dispatch({ type: 'SHOW_SUCCESS' })Also applies to: 89-126
📜 Review details
Configuration used: CodeRabbit UI
Review profile: ASSERTIVE
📒 Files selected for processing (1)
micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/SetupMaster.js
(1 hunks)
🧰 Additional context used
📓 Path-based instructions (1)
micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/SetupMaster.js (1)
Pattern **/*.js
: check
🔇 Additional comments (1)
micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/SetupMaster.js (1)
134-136
: Verify the necessity of checking isUserExist === null
The loading condition has been expanded to include isUserExist === null
. Let's verify if this additional check is necessary:
isUserExist
is initialized asnull
and updated in theuseEffect
hook whenmasterCount
data is available- The check prevents premature rendering before we know if master data exists
- This is a valid addition as it ensures the UI doesn't flicker between states
✅ Verification successful
Loading check for isUserExist === null
is correctly implemented
The verification confirms that the loading check is necessary and properly implemented:
isUserExist
is initialized asnull
and updated in auseEffect
hook whenmasterCount
data becomes available- The value is used to determine UI state (edit vs. setup buttons) and configuration through
setupMasterConfig
- The loading check prevents rendering before we know the master data status, avoiding UI flicker and potential errors
- The implementation follows React best practices for handling async data loading states
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash
# Search for other components that might depend on isUserExist
ast-grep --pattern 'isUserExist = $_'
Length of output: 39
Script:
#!/bin/bash
# Let's try a different approach to find usages of isUserExist
rg "isUserExist" -A 3 -B 3
Length of output: 5461
Script:
#!/bin/bash
# Let's check where isUserExist is being set
rg "setIsUserExist\(" -A 5 -B 5
Length of output: 1460
Summary by CodeRabbit
New Features
Bug Fixes