Skip to content
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

sandbox enhancement #1411

Merged
merged 7 commits into from
Sep 20, 2024
Merged

sandbox enhancement #1411

merged 7 commits into from
Sep 20, 2024

Conversation

nabeelmd-eGov
Copy link
Contributor

  • Added CustomErrorComponent, RoleBasedEmployeeHome, css enhancement
  • added new localisation module
  • upgrade ui component version
  • adding coutn check of master
  • adding count check of master

@nabeelmd-eGov nabeelmd-eGov requested a review from a team as a code owner September 20, 2024 08:54
Copy link
Contributor

coderabbitai bot commented Sep 20, 2024

Walkthrough

Walkthrough

The changes encompass enhancements to the styling and functionality of the sandbox component within the application. New CSS classes have been introduced, existing hooks have been modified to include new functionalities, and state management has been improved in the SetupMaster.js file. The configuration for setup actions has also been updated to allow dynamic behavior based on user existence.

Changes

Files Change Summary
.../css/src/pages/employee/sandbox.scss Added new class .digit-card-component.sandboxSetupMasterInfo with child styles; modified existing .pgr-citizen-wrapper.
.../modules/sandbox/src/hooks/index.js Introduced useGetMasterDataCount hook to the sandbox object for data fetching.
.../modules/sandbox/src/hooks/useGetMasterDataCount.js Created useGetMasterDataCount hook to fetch master data count; includes error handling and configurable options.
.../modules/sandbox/src/pages/employee/applicationMgmt/SetupMaster.js Enhanced state management for user existence and filters; updated loading conditions and button labels based on user state.
.../modules/sandbox/src/pages/employee/applicationMgmt/config/setupMasterConfig.js Changed setupMasterConfig from static to a dynamic function based on existingUser.

Possibly related PRs

🐇 In the meadow, where bunnies play,
New styles bloom, brightening the day.
Hooks now gather data with ease,
User states flow like a gentle breeze.
Configuration dances, dynamic and spry,
Hooray for the changes, oh my, oh my! 🌼


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?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    -- I pushed a fix in commit <commit_id>, please review it.
    -- Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    -- @coderabbitai generate unit testing code for this file.
    -- @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    -- @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    -- @coderabbitai read src/utils.ts and generate unit testing code.
    -- @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    -- @coderabbitai help me debug CodeRabbit configuration file.

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)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between ff2e006 and d2f6a15.

Files selected for processing (5)
  • micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/sandbox.scss (2 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/hooks/index.js (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/hooks/useGetMasterDataCount.js (1 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/SetupMaster.js (6 hunks)
  • micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/config/setupMasterConfig.js (5 hunks)
Additional context used
Path-based instructions (4)
micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/hooks/index.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/hooks/useGetMasterDataCount.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/SetupMaster.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/config/setupMasterConfig.js (1)

Pattern **/*.js: check

Additional comments not posted (18)
micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/hooks/index.js (2)

4-4: LGTM!

The import statement for the useGetMasterDataCount hook follows the correct syntax and naming convention. The import path aligns with the file structure.


9-9: Looks good!

The useGetMasterDataCount hook is correctly added as a property of the sandbox object. This addition expands the functionality of the sandbox object, providing a way to retrieve the count of master data, which could be useful for various parts of the application.

micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/hooks/useGetMasterDataCount.js (2)

2-18: LGTM!

The getMasterDataCountService function is implemented correctly:

  • It makes an API call to fetch the count of master data based on the provided filter and tenantId.
  • It handles errors by throwing a custom error with the error description from the API response.
  • The function logic is clear and follows the expected behavior.

20-22: LGTM!

The useGetMasterDataCount custom hook is implemented correctly:

  • It uses the useQuery hook from the react-query library to manage the API call state.
  • It passes the necessary parameters to the getMasterDataCountService function to fetch the count of master data.
  • The hook provides a convenient way to fetch and manage the count of master data in the React components.
micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/config/setupMasterConfig.js (4)

1-1: LGTM!

The change to make setupMasterConfig a function that accepts existingUser is a valid refactoring. It allows for dynamic generation of the configuration based on the user's status while maintaining backward compatibility with the default value of false.


11-11: LGTM!

The change to conditionally set the actionText based on existingUser is a valid enhancement. It improves the user experience by displaying "EDIT_NOW" for existing users and "SETUP_NOW" for new users.


49-49: LGTM!

The change to conditionally set the actionText based on existingUser for the "HCM" setup item is consistent with the previous change for the "COMPLAINT_MANAGEMENT" setup item. It improves the user experience by displaying appropriate action text based on the user's status.


63-63: LGTM!

The change to conditionally set the actionText based on existingUser for the "HRMS" setup item is consistent with the previous changes for the "COMPLAINT_MANAGEMENT" and "HCM" setup items. It improves the user experience by displaying appropriate action text based on the user's status.

micro-ui/web/micro-ui-internals/packages/css/src/pages/employee/sandbox.scss (2)

295-306: LGTM!

The new CSS class and its child element styles are well-structured and serve a specific purpose for the sandbox setup master info component. The styles for .h1.headerFlex help in aligning the child elements horizontally with a gap, while the styles for .digit-card-header.subHeader customize the font size, weight, and color of the subheader appropriately.


388-394: Looks good!

The reformatting of the nested structure within .pgr-citizen-wrapper improves the readability and consistency of the CSS. The styles for .date-wrap and .status-highlight ensure proper alignment and centering of their child elements while maintaining the core layout and functionality. The changes enhance the code quality without altering the intended behavior.

Also applies to: 399-406

micro-ui/web/micro-ui-internals/packages/modules/sandbox/src/pages/employee/applicationMgmt/SetupMaster.js (8)

18-19: State initialization is appropriate

The initialization of filters and isUserExist state variables using useState hooks is appropriate and sets up the component state correctly.


21-22: Dependency addition to useMemo hook is correct

Including isUserExist in the dependencies of the useMemo hook ensures that the configuration updates when isUserExist changes. This is necessary for the component to respond to state changes accurately.


30-50: Data processing logic is sound

The select function within the custom MDMS hook processes moduleMasterData correctly to generate respData and moduleMasterPayload. The use of filtering and mapping is appropriate for transforming the data.


57-61: useEffect hook correctly updates filters state

The useEffect hook updates filters when moduleMasterData or moduleMasterLoading changes. This ensures that the component's state remains in sync with the fetched data.


79-83: useEffect hook properly sets isUserExist

The useEffect hook updates isUserExist based on masterCount, ensuring the component reacts appropriately to the loading state.


150-153: Button label conditionally renders based on isUserExist

The conditional rendering of the button label enhances user experience by displaying EDIT_MASTER or config.actionText accordingly. This provides clarity to the user based on their current state.


Line range hint 176-188: Data passed to the Table component is correct

Passing moduleMasterData.respData to the data prop of the Table component ensures that the table displays the correct information fetched from the server.


236-246: Conditional navigation logic is implemented correctly

The onClick handler uses isUserExist to determine whether to navigate to a different route or invoke handleSetupMaster. This conditional logic correctly handles user interaction based on the application's state.

Comment on lines +127 to 129
if (moduleMasterLoading && masterCountLoading) {
return <Loader />;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Loader condition should use logical OR

The loading condition uses logical AND (&&), which means the loader will only show if both moduleMasterLoading and masterCountLoading are true. To display the loader when either of them is loading, use logical OR (||).

Proposed fix:

- if (moduleMasterLoading && masterCountLoading) {
+ if (moduleMasterLoading || masterCountLoading) {
    return <Loader />;
}
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
if (moduleMasterLoading && masterCountLoading) {
return <Loader />;
}
if (moduleMasterLoading || masterCountLoading) {
return <Loader />;
}

Comment on lines +63 to +77
const { isLoading: masterCountLoading, data: masterCount } = Digit.Hooks.sandbox.useGetMasterDataCount({
tenantId: tenantId,
filter: filters,
config: {
enabled: Boolean(filters),
select: (data) => {
const resp = data?.MdmsRes;
const checkMasterDataCompleteness = Object.values(resp).every((category) =>
Object.values(category).every((items) => items.every((item) => parseInt(item.count) > 0))
);

return checkMasterDataCompleteness;
},
},
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Add null-check for resp before processing

In the select function of useGetMasterDataCount, if data is undefined, data?.MdmsRes will be undefined, leading to an error when calling Object.values(resp). To prevent a potential runtime error, add a null-check for resp before proceeding.

Proposed fix:

select: (data) => {
  const resp = data?.MdmsRes;
+ if (!resp) return false;
  const checkMasterDataCompleteness = Object.values(resp).every((category) =>
    Object.values(category).every((items) => items.every((item) => parseInt(item.count) > 0))
  );
  return checkMasterDataCompleteness;
},
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
const { isLoading: masterCountLoading, data: masterCount } = Digit.Hooks.sandbox.useGetMasterDataCount({
tenantId: tenantId,
filter: filters,
config: {
enabled: Boolean(filters),
select: (data) => {
const resp = data?.MdmsRes;
const checkMasterDataCompleteness = Object.values(resp).every((category) =>
Object.values(category).every((items) => items.every((item) => parseInt(item.count) > 0))
);
return checkMasterDataCompleteness;
},
},
});
const { isLoading: masterCountLoading, data: masterCount } = Digit.Hooks.sandbox.useGetMasterDataCount({
tenantId: tenantId,
filter: filters,
config: {
enabled: Boolean(filters),
select: (data) => {
const resp = data?.MdmsRes;
if (!resp) return false;
const checkMasterDataCompleteness = Object.values(resp).every((category) =>
Object.values(category).every((items) => items.every((item) => parseInt(item.count) > 0))
);
return checkMasterDataCompleteness;
},
},
});

Comment on lines +38 to +49
const moduleMasterPayload = respStructure
?.filter((i) => i.type === "common" || i.type === "module")
?.map((item) => {
return {
moduleName: item?.code?.split(".")?.[0],
masterDetails: [
{
name: item?.code?.split(".")?.[1],
},
],
};
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Optimize by avoiding repeated splitting of item.code

In the mapping function, item.code is split multiple times. To improve performance and readability, consider splitting once and storing the result in a variable.

Proposed refactor:

const moduleMasterPayload = respStructure
  ?.filter((i) => i.type === "common" || i.type === "module")
  ?.map((item) => {
+   const codeParts = item?.code?.split(".");
    return {
-     moduleName: item?.code?.split(".")?.[0],
+     moduleName: codeParts?.[0],
      masterDetails: [
        {
-         name: item?.code?.split(".")?.[1],
+         name: codeParts?.[1],
        },
      ],
    };
  });
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
const moduleMasterPayload = respStructure
?.filter((i) => i.type === "common" || i.type === "module")
?.map((item) => {
return {
moduleName: item?.code?.split(".")?.[0],
masterDetails: [
{
name: item?.code?.split(".")?.[1],
},
],
};
});
const moduleMasterPayload = respStructure
?.filter((i) => i.type === "common" || i.type === "module")
?.map((item) => {
const codeParts = item?.code?.split(".");
return {
moduleName: codeParts?.[0],
masterDetails: [
{
name: codeParts?.[1],
},
],
};
});

@jagankumar-egov jagankumar-egov merged commit 78eecd1 into develop Sep 20, 2024
2 checks passed
@jagankumar-egov jagankumar-egov deleted the sandbox-enhancement branch September 20, 2024 09:10
This was referenced Sep 20, 2024
nabeelmd-eGov added a commit that referenced this pull request Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants