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

Moving inboxsearchcomposerv2 #51

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from

Conversation

hridya-egov
Copy link
Collaborator

@hridya-egov hridya-egov commented Apr 24, 2024

Summary by CodeRabbit

  • New Features

    • Introduced new components for enhanced UI elements such as horizontal navigation, link buttons, removable tags, and search components.
    • Added a multi-select dropdown with improved interaction and display features.
    • Enhanced mobile view components for search results and detailed card displays.
    • Implemented new form and search functionalities with advanced validation and state management.
  • Enhancements

    • Updated various UI components like checkboxes, tables, and file upload modules with better event handling and user feedback.
    • Improved form components handling with new validation techniques and dynamic field rendering based on user interactions.
  • Bug Fixes

    • Adjusted checkbox rendering logic and label placements for better usability.
    • Fixed issues related to file upload validations and error message displays.
  • Documentation

    • Updated module import paths and component dependencies for clearer and more maintainable code structure.
  • Refactor

    • Refactored several components to enhance performance and maintainability, including dropdowns, form fields, and search components.

Copy link

coderabbitai bot commented Apr 24, 2024

Walkthrough

The recent updates encompass a broad enhancement of React components and utilities across the board, focusing on improved user interactions, data handling, and UI consistency. Significant changes include the introduction of new components, enhancements in form handling and validation, and refinements in UI rendering and state management. These changes aim to provide a more robust, customizable, and user-friendly experience in web applications.

Changes

File Path Change Summary
.../src/atoms/*.js Introduced new components like CardLabelDesc, CardSectionHeader, and RemovableTagNew. Updated existing ones like CheckBox and SearchComponent for better functionality and user interaction.
.../src/hoc/*.js Enhanced form composers and search components with better state management, API interaction, and mobile responsiveness. New utilities like formUtils.js for building validation schemas.
.../src/molecules/*.js Updated and introduced components like ApiDropdown, CustomDropdown, and WorkflowStatusFilter for dynamic data handling and UI rendering based on API data.

🐰✨
In the garden of code, where the components bloom,
A rabbit hopped by, giving old files some room.
With a twitch of its nose, and a flick of its tail,
New features sprouted, ready to unveil.
Cheers to the team, for a job done right,
In the soft glow of screens, our apps shine bright! 🌟
🐰✨


Recent Review Details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits Files that changed from the base of the PR and between b946e14 and 01d9f5e.
Files ignored due to path filters (5)
  • react/example/package.json is excluded by !**/*.json
  • react/modules/Project/package.json is excluded by !**/*.json
  • react/modules/core/package.json is excluded by !**/*.json
  • react/modules/sample/package.json is excluded by !**/*.json
  • react/package.json is excluded by !**/*.json
Files selected for processing (35)
  • react/example/.eslintcache (1 hunks)
  • react/example/public/index.html (1 hunks)
  • react/ui-components/src/atoms/CardLabelDesc.js (1 hunks)
  • react/ui-components/src/atoms/CardSectionHeader.js (1 hunks)
  • react/ui-components/src/atoms/CardSubHeader.js (1 hunks)
  • react/ui-components/src/atoms/CheckBox.js (2 hunks)
  • react/ui-components/src/atoms/HorizontalNavV2.js (1 hunks)
  • react/ui-components/src/atoms/InboxSearchLinks.js (1 hunks)
  • react/ui-components/src/atoms/LinkButton.js (1 hunks)
  • react/ui-components/src/atoms/MultiSelectDropdown.js (1 hunks)
  • react/ui-components/src/atoms/RemovableTagNew.js (1 hunks)
  • react/ui-components/src/atoms/SearchComponent.js (5 hunks)
  • react/ui-components/src/atoms/SubmitBar.js (1 hunks)
  • react/ui-components/src/atoms/Table.js (8 hunks)
  • react/ui-components/src/atoms/UploadFile.js (3 hunks)
  • react/ui-components/src/hoc/FormComposerV2.js (10 hunks)
  • react/ui-components/src/hoc/InboxSearchComposer.js (3 hunks)
  • react/ui-components/src/hoc/InboxSearchComposerContext.js (1 hunks)
  • react/ui-components/src/hoc/InboxSearchComposerReducer.js (1 hunks)
  • react/ui-components/src/hoc/InboxSearchComposerV2.js (1 hunks)
  • react/ui-components/src/hoc/MobileView/MobileSearchComponent.js (7 hunks)
  • react/ui-components/src/hoc/MobileView/MobileSearchResultsV1.js (1 hunks)
  • react/ui-components/src/hoc/RemovableTags.js (1 hunks)
  • react/ui-components/src/hoc/ResultsTable.js (6 hunks)
  • react/ui-components/src/hoc/formUtils.js (1 hunks)
  • react/ui-components/src/molecules/ApiDropdown.js (3 hunks)
  • react/ui-components/src/molecules/Apicheckboxes.js (1 hunks)
  • react/ui-components/src/molecules/CustomDropdown.js (1 hunks)
  • react/ui-components/src/molecules/DateRangeNew.js (4 hunks)
  • react/ui-components/src/molecules/DetailsCard.js (2 hunks)
  • react/ui-components/src/molecules/FilterAction.js (1 hunks)
  • react/ui-components/src/molecules/MultiUploadWrapper.js (1 hunks)
  • react/ui-components/src/molecules/RenderFormFields.js (1 hunks)
  • react/ui-components/src/molecules/SearchAction.js (1 hunks)
  • react/ui-components/src/molecules/WorkflowStatusFilter.js (2 hunks)
Files not reviewed due to errors (7)
  • react/ui-components/src/atoms/CardSectionHeader.js (no review received)
  • react/ui-components/src/molecules/SearchAction.js (no review received)
  • react/ui-components/src/molecules/FilterAction.js (no review received)
  • react/ui-components/src/atoms/CardSubHeader.js (no review received)
  • react/ui-components/src/atoms/LinkButton.js (no review received)
  • react/ui-components/src/atoms/RemovableTagNew.js (no review received)
  • react/ui-components/src/hoc/formUtils.js (no review received)
Files skipped from review due to trivial changes (2)
  • react/ui-components/src/atoms/CardLabelDesc.js
  • react/ui-components/src/hoc/InboxSearchComposerContext.js
Additional comments not posted (85)
react/ui-components/src/atoms/SubmitBar.js (1)

9-15: LGTM! The updates to the SubmitBar component, including the new headerStyle prop, are well-implemented and enhance the component's flexibility.

react/example/public/index.html (1)

21-21: Ensure that the %REACT_APP_GLOBAL% is correctly replaced during the build process to avoid runtime errors.

react/ui-components/src/molecules/Apicheckboxes.js (1)

16-16: Consider adding error handling for the API call to manage scenarios where the API might fail or return an error.

react/ui-components/src/atoms/InboxSearchLinks.js (1)

6-6: The updated module import path looks correct. Ensure that all dependent components are updated to reflect this change.

react/ui-components/src/molecules/ApiDropdown.js (1)

16-18: Ensure that the custom API hook is robust and handles errors appropriately to prevent the component from breaking in case of API failures.

react/ui-components/src/atoms/HorizontalNavV2.js (1)

24-40: The conditional rendering logic for different scenarios (e.g., search components) is well-implemented. Ensure that the styles and class names are consistently applied across all scenarios for a uniform user experience.

react/ui-components/src/hoc/InboxSearchComposerReducer.js (1)

3-14: The removeObjectFromArray function is correctly implemented. Consider adding unit tests for this function to ensure it handles all edge cases correctly.

react/ui-components/src/hoc/MobileView/MobileSearchResultsV1.js (2)

36-43: This function is well-implemented using functional programming principles.


46-106: Ensure that all necessary dependencies are included in the useEffect hooks to avoid missing updates.

react/ui-components/src/molecules/DetailsCard.js (1)

56-130: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [19-127]

The component handles a wide range of functionalities and conditions. Consider simplifying to enhance readability and maintainability. Also, ensure that the dynamic link generation logic is robust against potential errors or edge cases.

react/ui-components/src/hoc/RemovableTags.js (2)

8-100: The tag generation logic in generateTagsFromFields is complex and could benefit from additional error handling to make it more robust against unexpected data structures.


154-163: Ensure that the tag removal logic correctly updates the state based on the tag configuration. Consider adding tests to verify the behavior under various scenarios.

react/ui-components/src/molecules/CustomDropdown.js (2)

66-81: The MDMS data handling using useCustomMDMS is efficiently implemented with appropriate conditional checks.


108-178: Ensure that all configurations are thoroughly tested, especially since the component can render in multiple modes (dropdown, multi-select, radio buttons). This is crucial to maintain consistent behavior across different use cases.

react/ui-components/src/molecules/MultiUploadWrapper.js (3)

12-27: The file validation logic is well-implemented, using regular expressions and size checks to ensure that only supported and appropriately sized files are processed.


119-141: The UI update logic effectively provides user feedback on the upload status, enhancing the user experience by clearly communicating progress, success, or errors.


104-110: Ensure that all potential error sources during file uploads are handled appropriately. Consider enhancing the error messages to be more informative and user-friendly.

react/ui-components/src/atoms/MultiSelectDropdown.js (3)

12-23: The use of a reducer for state management in MultiSelectDropdown is appropriate and robust, especially given the component's complexity and the need for handling dynamic changes in selection.


84-102: Review the rendering logic in MultiSelectDropdown to ensure it robustly handles all edge cases, particularly with dynamic data and rapid user interactions, to maintain a smooth user experience.


44-81: Ensure that the event handling, particularly for keyboard navigation and outside clicks, is thoroughly tested in MultiSelectDropdown to prevent usability issues and ensure consistent behavior across different user interactions.

react/ui-components/src/molecules/DateRangeNew.js (3)

14-26: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [17-44]

The date handling logic in DateRangeNew is well-implemented, using date-fns for accurate and efficient date calculations. This is crucial for the functionality of the date range selection.


146-162: Ensure that the UI interactions in DateRangeNew, particularly the handling of focus and click events for opening and closing the modal, are smooth and correctly managed to provide a seamless user experience.


44-44: The formatting of date ranges in DateRangeNew is effectively handled using date-fns, ensuring consistency and customization according to user preferences.

react/ui-components/src/atoms/UploadFile.js (2)

137-151: The file selection logic in UploadFile is correctly implemented using refs and state management, which is standard and effective for handling file inputs in React.


252-253: Ensure that all potential error conditions during file uploads are handled in UploadFile, and that the error messages are clear and informative to guide users effectively.

react/ui-components/src/hoc/MobileView/MobileSearchComponent.js (6)

12-12: Ensure that the Button component is utilized appropriately in the code, as its import has been added.


15-15: The addition of browserSession as a parameter should be accompanied by appropriate session management logic within the component.


54-54: Ensure that the default values from the session are correctly merged with uiConfig.defaultValues. This is critical for the form's initial state.


100-103: The clearSearch function's implementation should ensure that the session data is also cleared if session management is being used.


114-142: The renderHeader function's switch statement should be reviewed for consistency and correctness in handling different uiConfig.typeMobile cases.


177-230: The form submission logic should be thoroughly tested to ensure that it handles edge cases and performs as expected, especially with the dynamic session data handling.

react/ui-components/src/atoms/SearchComponent.js (8)

1-2: Ensure that the newly imported hooks useMemo and useWatch are utilized appropriately in the component to optimize performance and reactivity.


7-7: The change in the import path for LinkLabel should be verified to ensure it does not break existing functionality.


13-17: The new function setUIConf should be reviewed to ensure it correctly handles the uiConfig and integrates well with the rest of the component's logic.


19-19: The addition of new props such as activeLink, browserSession, showTab, tabData, and onTabChange should be accompanied by appropriate handling and usage within the component.


1-43: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [38-58]

The form's default values handling should be thoroughly tested, especially the integration with session data, to ensure the form initializes with the correct values.


74-100: The onSubmit function's new logic for custom validation and dispatch actions should be reviewed to ensure it behaves as expected under various scenarios.


108-119: The clearSearch function should ensure that it correctly resets the form and state, particularly with the new session management logic.


123-131: The new function setDefaultValues should be tested to ensure it correctly sets the form's default values based on the session data.

react/ui-components/src/hoc/ResultsTable.js (6)

12-12: The addition of new parameters such as type, activeLink, and browserSession should be accompanied by appropriate handling and usage within the component.


16-17: The new state variable showResultsTable should be managed correctly to ensure it controls the display of the table as intended.


38-49: The useEffect hook for managing the visibility of the results table based on the form's state should be tested to ensure it behaves as expected.


63-74: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [71-81]

The handling of column properties in the tableColumns configuration should be reviewed to ensure it supports sorting and custom cell rendering correctly.


103-222: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [89-118]

The form's default values handling, particularly the integration with session data, should be thoroughly tested to ensure the table initializes with the correct pagination settings.


170-180: The onSubmit function's implementation should be reviewed to ensure it correctly handles data submission and updates the table's state as expected.

react/ui-components/src/atoms/Table.js (7)

2-2: Ensure that the newly imported hooks from react-table are utilized appropriately to manage table state and functionality.


6-6: The addition of the SubmitBar component should be accompanied by appropriate usage within the table's UI, particularly for actions like bulk operations.


11-28: The restructuring of the IndeterminateCheckbox component should be reviewed to ensure it maintains its functionality, especially the handling of the indeterminate state.


60-71: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [30-68]

The new props such as onClickRow, rowClassName, noColumnBorder, and customPageSizesArray should be integrated correctly to enhance the table's configurability and interactivity.


110-120: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [113-130]

The integration of the checkbox column for row selection should be tested to ensure it interacts correctly with the table's data and supports bulk operations as intended.


142-160: The global filter functionality should be verified to ensure it filters the table data correctly based on user input.


228-244: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [168-275]

The rendering of the table rows and the handling of custom cell properties should be reviewed to ensure they display data correctly and support custom styles and interactions.

react/ui-components/src/hoc/InboxSearchComposer.js (12)

1-1: Ensure that the newly imported hooks useMemo are utilized appropriately to optimize component performance.


19-19: The addition of new parameters such as configs, headerLabel, and additionalConfig should be accompanied by appropriate handling and usage within the component.


22-28: The new state variables such as enable, type, and popup should be managed correctly to control the component's behavior and UI state.


31-33: The useEffect hook for updating apiDetails based on configs should be tested to ensure it behaves as expected when configs changes.


40-48: The session management logic for mobile view should be reviewed to ensure it correctly handles session data for form values.


49-75: The logic for updating apiDetails based on form data should be thoroughly tested, especially the integration with different form paths and the handling of empty values.


77-85: The useEffect hooks for form value changes and enabling based on form parameters should be reviewed to ensure they trigger the correct behaviors in the component.


87-124: The custom API hook usage should be verified to ensure it correctly fetches data based on the updated request criteria and handles loading and error states appropriately.


126-146: The error handling and refetching logic should be tested to ensure it correctly displays error messages and triggers refetches based on additionalConfig.


148-153: The cleanup function for revalidate and state reset should be reviewed to ensure it correctly cleans up component state when the component is unmounted or conditions change.


155-158: The popup handling for mobile view should be tested to ensure it correctly displays and hides the search and filter components based on user interactions.


10-300: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [161-329]

The rendering logic for various search and filter components should be reviewed to ensure they are displayed correctly based on the configurations and current application state.

react/ui-components/src/molecules/RenderFormFields.js (6)

23-23: Ensure that Digit.ComponentRegistryService.getComponent is robust against non-existent components.

Make sure that the Digit.ComponentRegistryService.getComponent function gracefully handles cases where the component does not exist. It should either return a default component or handle the error appropriately.


24-24: Validate the existence of Digit.Customizations before accessing it.

Before accessing Digit.Customizations, ensure that it is defined to avoid potential runtime errors. Consider adding a check or using optional chaining (?.) to safely access nested properties.


250-271: Ensure proper error handling in the ApiCheckboxes component.

Verify that the ApiCheckboxes component has appropriate error handling mechanisms. If it interacts with external APIs or performs operations that might fail, ensure that these failures are handled gracefully.


272-293: Check the integration of WorkflowStatusFilter with the rest of the application.

Ensure that the WorkflowStatusFilter component is properly integrated with the rest of the application, particularly in how it interacts with the inboxResponse and other props. Verify that all necessary data is passed correctly and that the component behaves as expected in all scenarios.


294-326: Review the handling of date ranges in DateRangeNew.

Carefully review how date ranges are handled in the DateRangeNew component. Ensure that all edge cases, such as leap years and timezone differences, are correctly handled. Also, verify that the commented-out code is either necessary or should be removed to clean up the codebase.


328-355: Ensure that custom components are safely rendered.

When rendering custom components dynamically, ensure that they are safe and do not introduce security vulnerabilities, such as XSS. Validate all inputs and sanitize any output as necessary.

react/ui-components/src/hoc/InboxSearchComposerV2.js (7)

37-37: Ensure that browserSession is always an array before destructuring.

Before destructuring browserSession into [session, setSession, clearSession], ensure that it is always an array. This prevents potential runtime errors if browserSession is not provided or is in an unexpected format.


66-71: Optimize the merging of state.searchForm with API details.
[PERFORMANCE]
The current implementation merges state.searchForm with API details in a potentially inefficient way. Consider optimizing this by reducing the number of operations or by using more performant data structures or algorithms.


90-90: Validate the logic that automatically sets enable based on the type of configuration.

Ensure that the logic which automatically sets the enable state based on configs.type is correct and behaves as expected in all cases. This is crucial for the correct operation of the component in different configurations.


147-153: Check the usage of dynamic hooks and ensure they are safe.

The use of eval to dynamically call hooks based on configs.customHookName can be potentially unsafe and makes the code harder to debug. Consider alternatives that do not involve eval, such as a mapping object or a switch statement.


159-166: Ensure cleanup effects are correctly implemented.

Verify that the cleanup function in the useEffect hook correctly handles all necessary cleanup tasks. This is important to prevent memory leaks or unintended behavior when the component unmounts.


174-182: Validate the logic for determining fields for removable tags.

Ensure that the logic to determine fieldsForRemovableTags correctly combines fields from both search and filter configurations. This is crucial for the correct display of removable tags in mobile views.


185-187: Confirm that the window scroll feature works as expected.

Ensure that the window.scrollTo function call in the useEffect hook correctly handles scrolling, especially when scrollPosition changes. This feature should work consistently across all browsers and devices.

react/ui-components/src/hoc/FormComposerV2.js (8)

5-34: Ensure that all imported components are utilized within the file to avoid unnecessary imports.


75-85: The enhancement for data validation using Yup schema is mentioned but it's noted that there are still some issues to solve. Ensure that these issues are tracked and addressed promptly.


108-113: The logic to clear errors when changing form categories is a good practice to prevent stale error messages. Ensure this works as expected across all form categories.


115-119: The use of error state to trigger a toast for displaying errors is a good user experience enhancement. However, ensure that the toast management logic handles all edge cases, such as rapid state changes.


639-644: The conditional rendering logic in getCombinedComponent is clear and concise. Good use of ternary operators for conditional styles.


709-758: > 📝 NOTE

This review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [680-755]

The form field rendering logic handles various conditions such as hiding fields and disabling labels effectively. However, the complexity of this function could be reduced by breaking it down into smaller components.


797-875: The navigation handling logic using HorizontalNav and conditional rendering based on the active link is well-implemented. Ensure that the active link state management is robust and handles all user interactions correctly.


878-889: The conditional rendering of action bars and buttons based on props is implemented correctly. Ensure that all props are documented and that the component's consumers are aware of how to use these features.


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>.
    • 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 generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @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.

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 as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configration 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

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

Out of diff range and nitpick comments (6)
react/ui-components/src/molecules/WorkflowStatusFilter.js (1)

45-45: Consider adding more detailed comments or documentation regarding the future enhancement for formData structure to help other developers understand the intended changes.

react/ui-components/src/hoc/MobileView/MobileSearchComponent.js (1)

5-5: Consider consolidating imports from the same directory to improve readability and reduce the number of import lines.

react/ui-components/src/molecules/RenderFormFields.js (1)

17-17: Consider using a more descriptive name for the component ApiCheckboxes.

The name ApiCheckboxes might be confusing as it suggests a specific relation to APIs, which may not be the case. Consider renaming it to something more generic like CheckboxGroup if it represents a group of checkboxes.

react/ui-components/src/hoc/InboxSearchComposerV2.js (1)

46-46: Clarify the purpose of the enable state variable.

The state variable enable is used in the component but it's not immediately clear what it controls. Consider renaming it to something more descriptive or adding a comment to clarify its purpose.

react/example/.eslintcache (1)

1-1: Ensure that the .eslintcache file is not included in version control.

Typically, cache files like .eslintcache should not be included in version control as they are generated dynamically and can vary between different environments. Consider adding this file to .gitignore to prevent it from being tracked.

react/ui-components/src/hoc/FormComposerV2.js (1)

36-38: Consider removing commented-out code if it is no longer needed to keep the codebase clean.

Comment on lines +150 to +591
return <Controller
name={`${populators.name}`}
control={control}
defaultValue={formData?.[populators.name]}
rules={{ required: populators?.isMandatory, ...populators.validation }}
render={(props) => {
return (
<div style={{ display: "grid", gridAutoFlow: "row" }}>
array
</div>
);
}}
/>
case "locationdropdown":
return (
<Controller
name={`${populators.name}`}
control={control}
defaultValue={formData?.[populators.name]}
rules={{ required: populators?.isMandatory, ...populators.validation }}
render={(props) => {
return (
<div style={{ display: "grid", gridAutoFlow: "row" }}>
<LocationDropdownWrapper
props={props}
populators={populators}
formData={formData}
inputRef={props.ref}
errors={errors}
setValue={setValue}
/>
</div>
);
}}
/>
);

case "apidropdown":
return (
<Controller
name={`${populators.name}`}
control={control}
defaultValue={formData?.[populators.name]}
rules={{ required: populators?.isMandatory, ...populators.validation }}
render={(props) => {
return (
<div style={{ display: "grid", gridAutoFlow: "row" }}>
<ApiDropdown
props={props}
populators={populators}
formData={formData}
inputRef={props.ref}
errors={errors}
t={t}
label={config?.label}
type={type}
onBlur={props.onBlur}
value={props.value}
onChange={props.onChange}
config={populators}
disable={config?.disable}
errorStyle={errors?.[populators.name]}
/>
</div>
);
}}
/>
);
case "multiselectdropdown":
return (
<Controller
name={`${populators.name}`}
control={control}
defaultValue={formData?.[populators.name]}
rules={{ required: isMandatory }}
render={(props) => {
return (
<div style={{ display: "grid", gridAutoFlow: "row" }}>
<MultiSelectDropdown
options={populators?.options}
optionsKey={populators?.optionsKey}
props={props}
isPropsNeeded={true}
onSelect={(e) => {
props.onChange(e?.map(row=>{return row?.[1] ? row[1] : null}).filter(e=>e))
}}
selected={props?.value || []}
defaultLabel={t(populators?.defaultText)}
defaultUnit={t(populators?.selectedText)}
config={populators}
/>
</div>
);
}}
/>
);
default:
return populators?.dependency !== false ? populators : null;
}
};
Copy link

Choose a reason for hiding this comment

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

The fieldSelector function is quite large and handles many different cases. Consider refactoring this into smaller, more manageable functions or components to improve readability and maintainability.

Comment on lines +666 to +673
//remove Toast from 3s
useEffect(()=>{
if(showErrorToast){
setTimeout(()=>{
closeToast();
},3000)
}
},[showErrorToast])
Copy link

Choose a reason for hiding this comment

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

The logic to automatically close the toast after 3 seconds is a nice touch for user experience. However, consider making the timeout duration configurable through props to enhance flexibility.

Comment on lines +5 to +67
const CheckBox = ({ onChange, label, value, disable, ref, checked, inputRef, pageType, style, index, isLabelFirst,customLabelMarkup, ...props }) => {
const { t } = useTranslation()
const userType = pageType || Digit.SessionStorage.get("userType");
let wrkflwStyle = props.styles;
if (isLabelFirst) {
return (
<div className="checkbox-wrap" style={wrkflwStyle ? wrkflwStyle : {}}>
<p style={style ? style : null}> {index+1}.</p>
<p className="label" style={{maxWidth: "80%", marginLeft: "10px"}}>
{label}
</p>
<div>
<input
type="checkbox"
className={userType === "employee" ? "input-emp" : ""}
onChange={onChange}
style={{ cursor: "pointer", left: "90%" }}
value={value || label}
{...props}
ref={inputRef}
disabled={disable}
checked={checked}
/>
<p className={userType === "employee" ? "custom-checkbox-emp" : "custom-checkbox"} style={disable ? { opacity: 0.5 } : {left: "90%"}}>
<CheckSvg />
</p>
</div>
</div>
{!isLabelFirst ? (
<p className="label" style={{ maxWidth: "100%", width: "100%",marginRight:"0rem" }}>
{customLabelMarkup ? (
<>
<span>{t("COMMON_CERTIFY_ONE")}</span>
<br />
<span>
<b> {t("ES_COMMON_NOTE")}</b>
{t("COMMON_CERTIFY_TWO")}
</span>
</>
) : (
sentenceCaseLabel
)}
);
} else {
return (
<div className="checkbox-wrap" style={wrkflwStyle ? wrkflwStyle : {}}>
<div>
<input
type="checkbox"
className={userType === "employee" ? "input-emp" : ""}
onChange={onChange}
style={{ cursor: "pointer" }}
value={value || label}
{...props}
ref={inputRef}
disabled={disable}
// {(checked ? (checked = { checked }) : null)}
checked={checked}
/>
<p className={userType === "employee" ? "custom-checkbox-emp" : "custom-checkbox"} style={disable ? { opacity: 0.5 } : (props?.checkboxWidth ? {...props?.checkboxWidth} : null)}>
{/* <img src={check} alt="" /> */}
<CheckSvg />
</p>
</div>
<p className="label" style={style ? style : null}>
{customLabelMarkup ?
<>
<p>{t("COMMON_CERTIFY_ONE")}</p>
<br />
<p>
<b> {t("ES_COMMON_NOTE")}</b>{t("COMMON_CERTIFY_TWO")}
</p>
</> : label}
</p>
) : null}
</div>
);
</div>
);
}
Copy link

Choose a reason for hiding this comment

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

The modifications to support different label and checkbox placements based on the isLabelFirst prop are well-implemented. Consider optimizing the prop handling to minimize unnecessary re-renders and improve performance.

const { t } = useTranslation();
const { fields, control, formData, errors, register, setValue, getValues, setError, clearErrors, apiDetails} = props

const fieldSelector = (type, populators, isMandatory, disable = false, component, config) => {
Copy link

Choose a reason for hiding this comment

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

Refactor fieldSelector to improve readability and maintainability.

The fieldSelector function is quite large and handles many different cases. Consider breaking it down into smaller, more manageable functions. Each case in the switch statement could potentially be a separate function. This would improve readability and maintainability.

Comment on lines +28 to +35
//uiConfig.type === filter || sort
//we need to sync browsersession and mobileSearchSession
// const mobileSearchSession = Digit.Hooks.useSessionStorage(`MOBILE_SEARCH_MODAL_FORM_${uiConfig?.type}_${fullConfig?.label}`,
// {...uiConfig?.defaultValues}
// );

// const [sessionFormData, setSessionFormData, clearSessionFormData] = mobileSearchSession;
const [session,setSession,clearSession] = browserSession || []
Copy link

Choose a reason for hiding this comment

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

The commented-out session management code should either be removed or implemented if it's intended to be used. Leaving commented code can lead to confusion and clutter.

Comment on lines +29 to +31
config.columns.map((column,idx) => {
resultantObj[t(column.label)] = column.additionalCustomization ? Digit?.Customizations?.[apiDetails?.masterName]?.[apiDetails?.moduleName]?.additionalCustomizations(row,column?.label,column, _.get(row,column.jsonPath,""),t, searchResult) : String(_.get(row,column.jsonPath,"") ? column.translate? t(Digit.Utils.locale.getTransformedLocale(column.prefix?`${column.prefix}${_.get(row,column.jsonPath,"")}`:_.get(row,column.jsonPath,""))) : _.get(row,column.jsonPath,"") : t("ES_COMMON_NA"));
})
Copy link

Choose a reason for hiding this comment

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

Consider refactoring the nested ternary operations in convertRowToDetailCardData to improve readability and maintainability.

Comment on lines +108 to +178
})
.filter((e) => e)
)
: onChange(
e
?.map((row) => {
return row?.[1] ? row[1] : null;
})
.filter((e) => e)
);
}}
disabled={disabled}
selectedOption={value}
defaultValue={value}
t={t}
errorStyle={errorStyle}
additionalWrapperClass={additionalWrapperClass}
innerStyles={config?.innerStyles}
selected={props?.value || value}
defaultLabel={t(config?.defaultText) }
defaultUnit={t(config?.selectedText) || t("COMMON_SELECTED")}
config={config}
disable={disable}
optionsDisable={config?.optionsDisable}
/>
);
default:
return null;
}
};
return <React.Fragment key={config.name}>{renderField()}</React.Fragment>;
};

CustomDropdown.propTypes = {
t: PropTypes.func.isRequired,
config: PropTypes.shape({
mdmsConfig: PropTypes.shape({
masterName: PropTypes.string,
moduleName: PropTypes.string,
filter: PropTypes.object,
select: PropTypes.string,
localePrefix: PropTypes.string,
}),
name: PropTypes.string,
optionsKey: PropTypes.string,
styles: PropTypes.object,
innerStyles: PropTypes.object,
options: PropTypes.array,
defaultValue: PropTypes.string,
optionsCustomStyle: PropTypes.object,
required: PropTypes.bool,
}),
inputRef: PropTypes.object,
label: PropTypes.string,
onChange: PropTypes.func,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.array]),
errorStyle: PropTypes.object,
disabled: PropTypes.bool,
type: PropTypes.string,
additionalWrapperClass: PropTypes.string,
</div> : type === "radio" ? (
<RadioButtons
inputRef={inputRef}
style={{ display: "flex", justifyContent: "flex-start", gap: "3rem", ...config.styles }}
options={data || config?.options || []}
key={config.name}
optionsKey={config?.optionsKey}
value={value}
onSelect={(e) => {
onChange(e, config.name);
}}
disable={disable}
selectedOption={value}
defaultValue={value}
t={t}
errorStyle={errorStyle}
additionalWrapperClass={additionalWrapperClass}
innerStyles={config?.innerStyles}
/>
) : (
<Dropdown
inputRef={inputRef}
style={{ display: "flex", justifyContent: "space-between", ...config.styles }}
option={data || config?.options || []}
key={config.name}
optionKey={config?.optionsKey}
value={value}
select={(e) => {
onChange(e, config.name);
}}
disable={disable}
selected={value || config.defaultValue}
defaultValue={value || config.defaultValue}
t={t}
errorStyle={errorStyle}
optionCardStyles={config?.optionsCustomStyle}
/>
)
}
</React.Fragment>
Copy link

Choose a reason for hiding this comment

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

Consider simplifying the event handling logic to make it more maintainable and less prone to errors, especially given the component's flexibility in rendering different types.

Copy link
Collaborator

@jagankumar-egov jagankumar-egov left a comment

Choose a reason for hiding this comment

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

Some of the new components were replaced with old can u check with i h


const getIconComponent = (iconName="")=>{
return require("@egovernments/digit-ui-svg-components")?.[iconName];
return require("@egovernments/digit-ui-react-components")?.[iconName];
Copy link
Collaborator

Choose a reason for hiding this comment

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

Keep as svg

disabled,
variant,
}) => {
const MultiSelectDropdown = ({ options, optionsKey, selected = [], onSelect, defaultLabel = "", defaultUnit = "",BlockNumber=1,isOBPSMultiple=false,props={},isPropsNeeded=false,ServerStyle={}, isSurvey=false,placeholder, disable=false,config}) => {
const [active, setActive] = useState(false);
const [searchQuery, setSearchQuery] = useState();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Revert to old component

<div className="digit-tag-container">
{alreadyQueuedSelectedState.length > 0 &&
alreadyQueuedSelectedState.map((value, index) => {
if (!value.propsData[1]?.options) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

There were too many changes

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