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

patch fix #1868

Merged
merged 3 commits into from
Nov 21, 2024
Merged

patch fix #1868

merged 3 commits into from
Nov 21, 2024

Conversation

rachana-egov
Copy link

@rachana-egov rachana-egov commented Nov 21, 2024

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced data fetching in the Choose Activity component to ensure real-time updates based on user interactions.
    • Streamlined navigation in the Plan Inbox component, improving user flow and clarity in workflow actions.
  • Bug Fixes

    • Improved loader display logic in the Pop Inbox component to better indicate data fetching states.
  • Improvements

    • Updated conditional rendering and state management in the Pop Inbox for better user experience.
    • Refined action button display logic in the Pop Inbox to ensure clarity based on user permissions.

@rachana-egov rachana-egov requested a review from a team as a code owner November 21, 2024 10:44
Copy link
Contributor

coderabbitai bot commented Nov 21, 2024

📝 Walkthrough

Walkthrough

This pull request introduces several updates across three components: ChooseActivity, PlanInbox, and PopInbox. Key changes include the addition of a refetchProcessInstance function in ChooseActivity to refresh data based on ID changes, modifications to navigation logic in PlanInbox to streamline user flow, and enhancements to rendering and state management in PopInbox. These updates collectively aim to improve data handling, user experience, and responsiveness in the application.

Changes

File Change Summary
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/ChooseActivity.js Added refetchProcessInstance to useEffect for data refresh on ID changes; updated destructuring for API hook.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js Changed navigation logic to redirect to a general employee page; modified state management for clearer user actions.
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js Updated loader rendering conditions; streamlined action button display logic; enhanced comment log handling.

Possibly related PRs

  • Added Choose Activity Home Page #1545: The changes in the ChooseActivity component are directly related to the modifications made in the same file, enhancing the functionality and interactivity of the activity cards.
  • Choose Activity - Screen Validations based on Business service workflow next actions #1640: This PR also modifies the ChooseActivity component, focusing on validations and loading states, which are relevant to the main PR's updates.
  • PO finding fixes #1843: The updates in the ActivityCard component are related to the changes in the ChooseActivity component, as both involve modifications to how activity cards are rendered and interacted with.
  • Go Back button and microplan name quotes fix #1844: The changes in the ActivityCard component regarding the microplan name are relevant to the updates in the ChooseActivity component, which also deals with displaying the microplan name.
  • Po finding fixes2 #1845: The modifications in the PlanInbox component, particularly regarding user interactions and state management, are relevant to the overall functionality being enhanced in the ChooseActivity component.
  • Plan Inbox patch fix #1847: The updates in the PlanInbox component, which include new state variables and logic for rendering, are related to the overall improvements in user interaction and data handling that are also present in the ChooseActivity component.

Suggested reviewers

  • nipunarora-eGov

🐇 "In the garden of code, we hop and play,
With ChooseActivity brightening the way.
PlanInbox now flows like a stream,
While PopInbox shines, a coder's dream.
Together we build, with joy and cheer,
Each change a step, bringing us near!" 🐇


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: 6

🧹 Outside diff range comments (7)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/ChooseActivity.js (3)

Line range hint 51-63: Optimize the process instance API hook configuration.

Consider the following improvements:

  1. Add null check for microplanId to prevent unnecessary API calls
  2. Cache the response using proper cache key
  const { isLoading:isProcessLoading, data: processData, revalidate, refetch:refetchProcessInstance } = Digit.Hooks.useCustomAPIHook({
    url: "/egov-workflow-v2/egov-wf/process/_search",
    params: {
      tenantId: tenantId,
      history: true,
      businessIds: microplanId,
    },
    config: {
-     enabled: true,
+     enabled: Boolean(microplanId),
+     cacheTime: 5000,
+     staleTime: 3000,
      select: (data) => {
        return data?.ProcessInstances;
      },
    },
  });

Line range hint 147-156: Enhance error handling in onClickCard.

The current error handling only logs errors to console. Consider:

  1. Adding user feedback for failures
  2. Implementing proper error recovery
  3. Using a centralized error handling mechanism
  const onClickCard = async (card) => {
    try {
      if(card.optionKey==="VALIDATE_N_APPROVE_POPULATION_DATA" && planObject.status==="EXECUTION_TO_BE_DONE"){
        await updatePlan({
          ...planObject,
          workflow:{
            action:"START_DATA_APPROVAL"
          }
        });
      }  
    } catch (error) {
-     console.error("ERROR_OCCURED_WHILE_UPDATING_PLAN");
-     console.error(error);
+     Digit.Utils.notificationHandler({
+       message: t("ERROR_UPDATING_PLAN"),
+       type: "error"
+     });
+     // Optionally revert any UI state changes
    }
  }

Line range hint 94-117: Clean up commented code.

There's a commented out section for GEOSPATIAL_MAP_VIEW. If this feature is no longer needed, consider removing it completely. If it's for future use, add a TODO comment explaining when it will be implemented.

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (4)

Line range hint 32-52: Consider using useReducer for complex state management

The component uses multiple useState hooks for related state (selectedRows, villagesSelected, currentPage, etc.). Consider using useReducer to manage related state together, making the code more maintainable and easier to debug.

-const [selectedRows, setSelectedRows] = useState([]);
-const [villagesSlected, setVillagesSelected] = useState(0);
-const [currentPage, setCurrentPage] = useState(1);
-const [rowsPerPage, setRowsPerPage] = useState(50);
+const [tableState, dispatch] = useReducer(tableReducer, {
+  selectedRows: [],
+  villagesSelected: 0,
+  currentPage: 1,
+  rowsPerPage: 50
+});
🧰 Tools
🪛 Biome

[error] 854-856: 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)


Line range hint 571-579: Enhance error handling for API failures

The error handling for workflow actions could be improved. Consider adding proper error boundaries and user-friendly error messages.

onError={(data) => {
  closePopUp();
-  setShowToast({ key: "error", label: t(error?.response?.data?.Errors?.[0]?.code) });
+  const errorMessage = error?.response?.data?.Errors?.[0]?.code 
+    ? t(error.response.data.Errors[0].code)
+    : t('COMMON_ERROR_UNKNOWN');
+  setShowToast({ 
+    key: "error", 
+    label: errorMessage,
+    transitionTime: 5000 
+  });
+  console.error('Workflow action failed:', error);
}
🧰 Tools
🪛 Biome

[error] 854-856: 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)


Line range hint 447-538: Optimize table column definitions using useMemo

The column definitions are recalculated on every render. Consider memoizing them to improve performance.

-const columns = [
+const columns = useMemo(() => [
  // ... column definitions
-];
+], [t, employeeNameMap, planWithCensus?.planData]);
🧰 Tools
🪛 Biome

[error] 854-856: 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)


Line range hint 1-855: Consider splitting the component into smaller, focused components

The file is quite large and handles multiple responsibilities. Consider:

  1. Extracting the data table into a separate component
  2. Moving helper functions to utility files
  3. Creating separate components for filter and action sections

This will improve maintainability and testability.

🧰 Tools
🪛 Biome

[error] 854-856: 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)

📜 Review details

Configuration used: CodeRabbit UI
Review profile: ASSERTIVE

📥 Commits

Reviewing files that changed from the base of the PR and between 427f95f and 7a61213.

📒 Files selected for processing (3)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/ChooseActivity.js (2 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1 hunks)
  • health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js (4 hunks)
🧰 Additional context used
📓 Path-based instructions (3)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/ChooseActivity.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PlanInbox.js (1)

Pattern **/*.js: check

health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js (1)

Pattern **/*.js: check

📓 Learnings (1)
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js (2)
Learnt from: rachana-egov
PR: egovernments/DIGIT-Frontend#1837
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js:559-561
Timestamp: 2024-11-15T10:15:57.370Z
Learning: In `PopInbox.js`, error handling for the `onError` callback in `WorkflowCommentPopUp` is handled within the component, so explicit error handling in the parent component is unnecessary.
Learnt from: rachana-egov
PR: egovernments/DIGIT-Frontend#1832
File: health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js:592-594
Timestamp: 2024-11-14T12:48:23.024Z
Learning: In `PopInbox.js`, when integrating the `ConfirmationPopUp` component, error handling for API failures is managed internally within the component, so explicitly passing an `onError` prop is not necessary.
🪛 Biome
health/micro-ui/web/micro-ui-internals/packages/modules/microplan/src/pages/employee/PopInbox.js

[error] 563-569: 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] 601-601: 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] 727-729: 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)

@nipunarora-eGov nipunarora-eGov merged commit d33a49a into console Nov 21, 2024
3 checks passed
@nipunarora-eGov nipunarora-eGov deleted the rachana_patch_fix_1 branch November 21, 2024 11:15
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.

2 participants