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 #46

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

Moving inboxsearchcomposerV2 #46

wants to merge 2 commits into from

Conversation

hridya-egov
Copy link
Collaborator

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

Summary by CodeRabbit

  • New Features

    • Introduced HorizontalNavV2 for enhanced horizontal navigation.
    • Added RemovableTagNew and MobileSearchResultsV1 components for improved UI interaction.
    • New ApiCheckboxes component that fetches and displays checkboxes dynamically based on API data.
  • Enhancements

    • Updated SearchComponent, MultiSelectDropdown, and UploadFile components with enhanced functionality and user interaction.
    • Enhanced InboxSearchComposerV2 with better search and filtering capabilities.
    • Improved mobile responsiveness and interaction through updates to MobileSearchComponent.
  • Bug Fixes

    • Fixed issues in MultiUploadWrapper and WorkflowStatusFilter components for better stability and performance.
  • Documentation

    • Updated script inclusion in index.html for global configuration.
  • Refactor

    • Major refactoring in components like CheckBox, Table, and SubmitBar to improve performance and maintainability.
    • Updated various components to use new versions of dependencies for better compatibility and features.
  • Style

    • Applied new styles and class names adjustments across various UI components for a more consistent and polished look.

Copy link

coderabbitai bot commented Apr 22, 2024

Walkthrough

The updates involve significant changes across various React components and configuration files within a project. Key changes include version updates for dependencies, the introduction of new components like InboxSearchComposerV2 and HorizontalNavV2, and extensive modifications to existing components to enhance functionality, improve user interaction, and refine the API integration. These adjustments aim to streamline user experiences and expand the capabilities of the UI components used throughout the project.

Changes

File Path Change Summary
react/example/.eslintcache Added file for caching linting results.
react/**/package.json Updated dependency versions.
react/example/public/index.html Uncommented a script tag for global configuration.
react/modules/.../index.js Replaced InboxSearchComposer with InboxSearchComposerV2.
react/ui-components/src/atoms/*.js Major updates and new components like HorizontalNavV2, RemovableTagNew.
react/ui-components/src/hoc/*.js Introduced InboxSearchComposerV2, updated InboxSearchComposer, added mobile view components.
react/ui-components/src/molecules/*.js Significant functionality changes in components like ApiCheckboxes, CustomDropdown.

🐰✨
Oh, what a day! Code hops away,
Changes galore, updates and more.
With every file, a new style,
Components dance, in a coder's trance.
Celebrate we do, with a carrot or two! 🥕🎉
🐰✨


Recent Review Details

Configuration used: CodeRabbit UI

Commits Files that changed from the base of the PR and between b946e14 and 2dcca0d.
Files selected for processing (39)
  • react/example/.eslintcache (1 hunks)
  • react/example/package.json (1 hunks)
  • react/example/public/index.html (1 hunks)
  • react/modules/Project/package.json (1 hunks)
  • react/modules/Project/src/pages/employee/ProjectSearch/index.js (2 hunks)
  • react/modules/Project/src/pages/employee/ProjectSearchAndInbox/index.js (2 hunks)
  • react/modules/Project/src/pages/employee/ProjectWMSSearch/index.js (2 hunks)
  • react/modules/core/package.json (1 hunks)
  • react/modules/sample/package.json (1 hunks)
  • react/package.json (1 hunks)
  • react/ui-components/package.json (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 (2 hunks)
  • react/ui-components/src/atoms/MultiSelectDropdown.js (4 hunks)
  • react/ui-components/src/atoms/RemovableTagNew.js (1 hunks)
  • react/ui-components/src/atoms/SearchComponent.js (3 hunks)
  • react/ui-components/src/atoms/SubmitBar.js (1 hunks)
  • react/ui-components/src/atoms/Table.js (6 hunks)
  • react/ui-components/src/atoms/UploadFile.js (3 hunks)
  • react/ui-components/src/hoc/InboxSearchComposer.js (3 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/MobilSearchResultsV1.js (1 hunks)
  • react/ui-components/src/hoc/MobileView/MobileSearchComponent.js (1 hunks)
  • react/ui-components/src/hoc/RemovableTags.js (1 hunks)
  • react/ui-components/src/hoc/ResultsTable.js (5 hunks)
  • react/ui-components/src/hoc/index.js (1 hunks)
  • react/ui-components/src/index.js (3 hunks)
  • react/ui-components/src/molecules/ApiCheckboxes.js (1 hunks)
  • react/ui-components/src/molecules/ApiDropdown.js (3 hunks)
  • react/ui-components/src/molecules/CustomDropdown.js (1 hunks)
  • react/ui-components/src/molecules/DateRangeNew.js (6 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 (1)
  • react/ui-components/src/hoc/MobileView/MobilSearchResultsV1.js (no review received)
Files skipped from review due to trivial changes (5)
  • react/example/.eslintcache
  • react/example/public/index.html
  • react/modules/core/package.json
  • react/modules/sample/package.json
  • react/ui-components/package.json
Additional comments not posted (60)
react/ui-components/src/hoc/index.js (1)

14-14: Ensure that all dependent modules have been updated to use the new InboxSearchComposerV2 where InboxSearchComposer was previously used.

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

9-9: Ensure that the new class names (submit-bar-disabled, submit-bar) are correctly styled in the corresponding CSS files.


15-15: Good use of the headerStyle prop to allow custom styles for the header. Ensure that all usages of SubmitBar pass appropriate styles if needed.

react/modules/Project/package.json (1)

21-22: Ensure that the updated versions of @egovernments/digit-ui-react-components and @egovernments/digit-ui-components are compatible with the rest of the project.

react/example/package.json (1)

13-19: Ensure that the updated versions of dependencies are compatible with the rest of the project and do not introduce breaking changes.

react/modules/Project/src/pages/employee/ProjectSearchAndInbox/index.js (1)

29-29: Ensure that InboxSearchComposerV2 is fully compatible and integrates well with the existing functionalities of the ProjectSearchAndInboxComponent.

react/ui-components/src/molecules/ApiCheckboxes.js (5)

14-14: Ensure that Digit is defined or imported in this file.


16-16: Verify that useCustomAPIHook is a valid hook provided by Digit.Hooks and that it handles the API call as expected.


22-22: Good use of conditional rendering to handle loading states.


26-41: Ensure that the onChange handler correctly updates the state and that the value and checked properties are correctly derived from props and formData.


46-46: Good practice to export the component for reuse.

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

5-5: Verify that the require statement correctly imports the icon component based on the name. Consider using ES6 import if possible for consistency and better bundling.


39-39: Good practice to export the component for reuse.

react/ui-components/src/molecules/WorkflowStatusFilter.js (4)

9-19: Ensure that the transformation of inboxResponse.statusMap in the useEffect hook correctly handles cases where statusMap might be undefined or not an array.


21-21: Good use of conditional rendering to handle loading states and absence of data.


39-54: > 📝 NOTE

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

Check that the CheckBox component is used correctly with all props properly passed and handled, especially the dynamic label construction.


54-54: Good practice to export the component for reuse.

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

16-16: Verify that useCustomAPIHook is a valid hook provided by Digit.Hooks and that it handles the API call as expected.


41-44: Ensure that the MultiSelectDropdown component is used correctly with all props properly passed and handled, especially the onSelect handler.


69-69: Good practice to export the component for reuse.

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

5-5: Ensure that the setActiveLink function is correctly passed and used to update the active link state.


56-56: Good practice to export the component for reuse.

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

5-59: Verify that the CheckBox component handles all props correctly, especially the conditional rendering based on isLabelFirst and the handling of userType.


78-78: Good practice to export the component for reuse.

react/modules/Project/src/pages/employee/ProjectSearch/index.js (1)

72-72: Ensure that InboxSearchComposerV2 is correctly imported and used with the appropriate configurations.

react/modules/Project/src/pages/employee/ProjectWMSSearch/index.js (1)

75-75: Ensure that InboxSearchComposerV2 is correctly imported and used with the appropriate configurations.

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

15-22: Initial state structure looks clean and well-organized.


24-86: Ensure proper handling of default cases in reducer switch statements.

It's good practice to handle default cases in switch statements within reducers to ensure that all action types are accounted for, even if it's just returning the current state.

react/package.json (1)

78-80: Updated package versions to align with project dependencies.

Ensure that all dependent modules are compatible with these new versions to avoid runtime issues.

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

7-28: Ensure proper prop handling and default values in CustomDropdown.

Check that all new props are correctly passed and have sensible defaults to prevent runtime errors.

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

51-139: > 📝 NOTE

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

Review the conditional rendering and prop handling in DetailsCard.

Ensure that all conditions and new props are correctly handled to prevent any rendering issues. Pay special attention to the new SubmitBar component integration.

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

106-158: Component structure and state management in RemovableTags look well-implemented.

Ensure that the component is thoroughly tested, especially the dynamic tag generation and removal functionality.

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

1-125: > 📝 NOTE

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

Refactor SearchComponent to improve readability and maintainability.

This component is quite complex with multiple hooks and conditional rendering. Consider breaking it down into smaller components or using custom hooks to encapsulate some of the logic.

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

43-122: Ensure robust error handling and state management in MultiUploadWrapper.

This component involves complex state management with file uploads. Ensure that all edge cases are handled and that state updates are robust to prevent any issues during file upload or removal.

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

5-5: The component now accepts new props isSurvey, placeholder, and disable. Ensure that these props are documented and their usage is clear in the component's API.


15-17: The reducer function has been modified to handle new actions for managing selected options. Ensure that these changes are tested, especially edge cases where options might not have the expected structure.


27-27: The useEffect hook now depends on selected. Ensure that this dependency correctly reflects changes in the selected items, especially when items are dynamically added or removed.


45-45: The use of Digit.Hooks.useClickOutside suggests dependency on a custom hook from a library. Verify that this hook is available and properly imported in the project.

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

11-11: The new function getCitizenStyles introduces styles based on the value parameter. Ensure that this function is covered by unit tests to verify that it returns the correct styles for different inputs.


119-119: The extraStyles variable is used to apply styles conditionally. Verify that these styles are correctly applied and do not cause any layout shifts or styling issues.


127-127: The handleEmpty function is intended to clear the input if no files are selected. Ensure that this function is triggered in the appropriate component lifecycle and does not lead to unexpected behavior.

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

14-14: The component now accepts a populators prop. Ensure that this prop is documented and its usage is clear in the component's API.


19-20: The logic to convert date strings to Date objects has been added. Ensure that this conversion handles different date formats and time zones correctly.


40-40: The title variable is constructed using date formatting. Verify that the date format used (dd/MM/yyyy) matches the application's locale settings and user expectations.

react/ui-components/src/index.js (1)

209-209: The export of InboxSearchComposerV2 replaces InboxSearchComposer. Verify that all references to the old component have been updated throughout the project to prevent any broken imports.

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

14-14: The component now accepts a browserSession prop. Ensure that this prop is documented and its usage is clear in the component's API.


45-47: The onSubmit function has been updated to close the modal on submission. Verify that this behavior is consistent with the user experience requirements and does not disrupt the user's workflow.


49-55: The clearSearch function has been updated to reset the form values. Ensure that this function correctly resets all form fields and does not leave any residual values that could affect subsequent searches.

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

11-11: The component now accepts new props type, activeLink, and browserSession. Ensure that these props are documented and their usage is clear in the component's API.


15-16: The state management for showing/hiding the results table has been updated. Verify that the logic correctly reflects the user's actions and the table visibility is controlled as expected.


25-36: The useEffect hook has been added to manage the visibility of the results table based on the search form parameters. Ensure that this hook does not cause unnecessary re-renders or affect the performance of the component.


55-68: > 📝 NOTE

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

The table columns generation logic has been refactored. Verify that all columns are correctly generated and that sorting and filtering functionalities work as expected.


136-146: The onSubmit function has been updated to handle form submission and state updates. Ensure that this function correctly updates the state and triggers the necessary API calls or actions.

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

1-1: The component now uses several hooks from react-table. Verify that these hooks are correctly utilized and that the table functionality (sorting, pagination, etc.) works as expected.


20-20: The component accepts several new props such as disableSort, autoSort, manualPagination, etc. Ensure that these props are documented and their usage is clear in the component's API.


64-81: > 📝 NOTE

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

The state management for pagination and sorting has been updated. Verify that these changes correctly handle user interactions and that the table updates as expected when sorting or changing pages.

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

28-31: Ensure that setApiDetails is necessary in both the initial state and the useEffect. This might be redundant if configs.apiDetails does not change often.


122-125: Ensure that the toast for displaying errors is tested thoroughly, especially the auto-hide functionality.

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

18-368: Ensure proper error handling in API calls.

The component makes use of API calls (e.g., Digit.ComponentRegistryService.getComponent). Ensure that there is proper error handling for these API calls to manage scenarios where the API might fail or return unexpected results.

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

1-372: Ensure consistent use of localization.

The component uses the t function from useTranslation for localization. Ensure that all user-facing text is properly localized using this function to maintain consistency and support multiple languages.


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

@@ -1,6 +1,6 @@
import React, { useEffect, useReducer, useState, useMemo } from "react";
import React, { useEffect, useReducer, useState,useMemo } from "react";
Copy link

Choose a reason for hiding this comment

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

Consider removing unused imports to keep the code clean.

Comment on lines +48 to +65
if (Object.keys(state.searchForm)?.length >= 0) {
const result = { ..._.get(apiDetails, apiDetails?.searchFormJsonPath, {}), ...state.searchForm }
Object.keys(result).forEach(key => {
if (!result[key]) delete result[key]
});
_.set(apiDetails, apiDetails?.searchFormJsonPath, result)
}
if (Object.keys(state.filterForm)?.length >= 0) {
const result = { ..._.get(apiDetails, apiDetails?.filterFormJsonPath, {}), ...state.filterForm }
Object.keys(result).forEach(key => {
if (!result[key] || result[key]?.length===0) delete result[key]
});
_.set(apiDetails, apiDetails?.filterFormJsonPath, result)
}

if(Object.keys(state.tableForm)?.length >= 0) {
_.set(apiDetails, apiDetails?.tableFormJsonPath, { ..._.get(apiDetails, apiDetails?.tableFormJsonPath, {}),...state.tableForm })
}
Copy link

Choose a reason for hiding this comment

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

Optimize the handling of form data in state updates to avoid potential performance issues with large data sets.

Comment on lines +107 to +114
const updatedReqCriteria = Digit?.Customizations?.[apiDetails?.masterName]?.[apiDetails?.moduleName]?.preProcess ? Digit?.Customizations?.[apiDetails?.masterName]?.[apiDetails?.moduleName]?.preProcess(requestCriteria,configs.additionalDetails) : requestCriteria

if(configs.customHookName){
var { isLoading, data, revalidate,isFetching,refetch,error } = eval(`Digit.Hooks.${configs.customHookName}(updatedReqCriteria)`);
}
if (Object.keys(state.filterForm)?.length >= 0) {
const result = { ..._.get(apiDetails, apiDetails?.filterFormJsonPath, {}), ...state.filterForm };
Object.keys(result).forEach((key) => {
if (!result[key] || result[key]?.length === 0) delete result[key];
});
_.set(apiDetails, apiDetails?.filterFormJsonPath, result);
else {
var { isLoading, data, revalidate,isFetching,error } = Digit.Hooks.useCustomAPIHook(updatedReqCriteria);

Copy link

Choose a reason for hiding this comment

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

Consider handling errors from the custom hook more robustly, especially in production environments.

@@ -1,346 +1,368 @@
import React from "react";
import React from 'react';
Copy link

Choose a reason for hiding this comment

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

Use consistent import quotes.

Please ensure that all import statements use single quotes for consistency as per the project's coding standards.

Comment on lines +22 to +344
t={t}
setValue={setValue}
onSelect={setValue}
config={config}
data={formData}
formData={formData}
register={register}
errors={errors}
props={props}
setError={setError}
clearErrors={clearErrors}
onBlur={props.onBlur}
control={control}
getValues={getValues}
responseData={data}
populators={populators}
/>
)}
name={config?.key}
control={control}
/>
);
}}
/>
);
case "dateRange":
return (
<Controller
render={(props) => (
<DateRangeNew
t={t}
values={formData?.[populators?.name]?.range}
name={populators?.name}
onFilterChange={props.onChange}
inputRef={props.ref}
errorStyle={errors?.[populators?.name]}
/>
)}
rules={{ required: isMandatory, ...populators.validation }}
defaultValue={formData?.[populators?.name]}
name={populators?.name}
control={control}
/>
);

case "component":
return (
<Controller
render={(props) => (
<Component
userType={"employee"}
t={t}
setValue={setValue}
onSelect={setValue}
config={config}
data={formData}
formData={formData}
register={register}
errors={errors}
props={props}
setError={setError}
clearErrors={clearErrors}
onBlur={props.onBlur}
control={control}
getValues={getValues}
responseData={data}
/>
)}
name={config?.key}
control={control}
/>
);

default:
return populators?.dependency !== false ? populators : null;
}
};

return (
<React.Fragment>
{fields?.map((item, index) => {
return (
<LabelFieldPair key={index} style={{ display: "flex", flexDirection: "column" ,alignItems:"flex-start"}}>
{item.label && (
<CardLabel style={{ ...props.labelStyle, marginBottom: "0.4rem" }}>
{t(item.label)}
{item?.isMandatory ? " * " : null}
</CardLabel>
)}

{fieldSelector(item.type, item.populators, item.isMandatory, item?.disable, item?.component, item)}

{item?.populators?.name && errors && errors[item?.populators?.name] && Object.keys(errors[item?.populators?.name]).length ? (
<CardLabelError style={{ fontSize: "12px", marginTop: "-20px" }}>{t(item?.populators?.error)}</CardLabelError>
) : null}

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.

Refactor fieldSelector for maintainability.

The fieldSelector function is quite lengthy and handles many cases, which can make it difficult to maintain and extend. Consider breaking it down into smaller, more manageable functions, each handling a specific field type. This will improve readability and maintainability.

- const fieldSelector = (type, populators, isMandatory, disable = false, component, config) => {
+ const handleTextInput = (type, populators, isMandatory, disable, component, config) => {
+   // Logic for text input
+ }
+ const handleTextArea = (type, populators, isMandatory, disable, component, config) => {
+   // Logic for textarea
+ }
+ const fieldSelector = (type, populators, isMandatory, disable = false, component, config) => {
+   switch (type) {
+     case "text":
+     case "number":
+     case "password":
+     case "time":
+       return handleTextInput(type, populators, isMandatory, disable, component, config);
+     case "textarea":
+       return handleTextArea(type, populators, isMandatory, disable, component, config);
+     // other cases
+   }
+ }

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.

Suggested change
const fieldSelector = (type, populators, isMandatory, disable = false, component, config) => {
const Component = typeof component === "string" ? Digit.ComponentRegistryService.getComponent(component) : component;
let customValidations = config?.additionalValidation ? Digit?.Customizations?.[apiDetails?.masterName]?.[apiDetails?.moduleName]?.additionalValidations(config?.additionalValidation?.type, formData, config?.additionalValidation?.keys) : null
const customRules = customValidations ? { validate: customValidations} : {}
switch (type) {
case "date":
case "text":
case "number":
case "password":
case "time":
return (
<Controller
defaultValue={formData?.[populators.name]}
render={({ onChange, ref, value }) => (
<TextInput
value={formData?.[populators.name]}
type={type}
name={populators.name}
onChange={onChange}
inputRef={ref}
errorStyle={errors?.[populators.name]}
max={populators.max}
disable={disable}
style={type === "date" ? { paddingRight: "3px" } : populators?.style ? {...populators?.style} : {}}
maxlength={populators?.validation?.maxlength}
minlength={populators?.validation?.minlength}
/>
)}
name={populators.name}
rules={{required: isMandatory, ...populators.validation, ...customRules }}
control={control}
/>
);
case "textarea":
return (
<Controller
defaultValue={formData?.[populators.name]}
render={({ onChange, ref, value }) => (
<TextArea
className="field"
value={formData?.[populators.name]}
type={type}
name={populators.name}
onChange={onChange}
inputRef={ref}
disable={disable}
errorStyle={errors?.[populators.name]}
/>
)}
name={populators.name}
rules={{ required: isMandatory, ...populators.validation }}
control={control}
/>
)}
name={populators?.name}
rules={{ required: isMandatory, ...populators.validation, ...customRules }}
control={control}
/>
);
case "textarea":
return (
<Controller
defaultValue={formData?.[populators?.name]}
render={({ onChange, ref, value }) => (
<TextArea
className="field"
value={formData?.[populators?.name]}
type={type}
);
case "mobileNumber":
return (
<Controller
render={(props) => (
<MobileNumber
inputRef={props.ref}
className="field fullWidth"
onChange={props.onChange}
value={props.value}
disable={disable}
{...props}
errorStyle={errors?.[populators.name]}
/>
)}
defaultValue={populators.defaultValue}
name={populators?.name}
onChange={onChange}
inputRef={ref}
disabled={disable}
errorStyle={errors?.[populators?.name]}
/>
)}
name={populators?.name}
rules={{ required: isMandatory, ...populators.validation }}
control={control}
/>
);
case "mobileNumber":
return (
<Controller
render={(props) => (
<MobileNumber
inputRef={props.ref}
className="field fullWidth"
onChange={props.onChange}
value={props.value}
disable={disable}
{...props}
errorStyle={errors?.[populators?.name]}
rules={{ required: isMandatory, ...populators.validation }}
control={control}
/>
)}
defaultValue={populators.defaultValue}
name={populators?.name}
rules={{ required: isMandatory, ...populators.validation }}
control={control}
/>
);
case "multiupload":
return (
<Controller
name={`${populators?.name}`}
control={control}
rules={{ required: false }}
render={({ onChange, ref, value = [] }) => {
function getFileStoreData(filesData) {
const numberOfFiles = filesData.length;
let finalDocumentData = [];
if (numberOfFiles > 0) {
filesData.forEach((value) => {
finalDocumentData.push({
fileName: value?.[0],
fileStoreId: value?.[1]?.fileStoreId?.fileStoreId,
documentType: value?.[1]?.file?.type,
});
});
}
onChange(numberOfFiles > 0 ? filesData : []);
}
);
case "multiupload":
return (
<Controller
name={`${populators.name}`}
control={control}
rules={{ required: false }}
render={({ onChange, ref, value = [] }) => {
function getFileStoreData(filesData) {
const numberOfFiles = filesData.length;
let finalDocumentData = [];
if (numberOfFiles > 0) {
filesData.forEach((value) => {
finalDocumentData.push({
fileName: value?.[0],
fileStoreId: value?.[1]?.fileStoreId?.fileStoreId,
documentType: value?.[1]?.file?.type,
});
});
}
onChange(numberOfFiles>0?filesData:[]);
}
return (
<MultiUploadWrapper
t={t}
module="works"
tenantId={Digit.ULBService.getCurrentTenantId()}
getFormState={getFileStoreData}
showHintBelow={populators?.showHintBelow ? true : false}
setuploadedstate={value}
allowedFileTypesRegex={populators.allowedFileTypes}
allowedMaxSizeInMB={populators.allowedMaxSizeInMB}
hintText={populators.hintText}
maxFilesAllowed={populators.maxFilesAllowed}
extraStyleName={{ padding: "0.5rem" }}
customClass={populators?.customClass}
/>
);
}}
/>
);
case "custom":
return (
<Controller
render={(props) => populators.component({ ...props, setValue }, populators.customProps)}
defaultValue={populators.defaultValue}
name={populators?.name}
control={control}
/>
);
case "radio":
case "dropdown":
return (
<Controller
render={(props) => (
<CustomDropdown
t={t}
label={config?.label}
type={type}
onBlur={props.onBlur}
value={props.value}
inputRef={props.ref}
onChange={props.onChange}
config={populators}
disable={config?.disable}
errorStyle={errors?.[populators.name]}
mdmsv2={populators.mdmsv2 ? populators.mdmsv2 : false }
props={props}
/>
)}
rules={{ required: isMandatory, ...populators.validation }}
defaultValue={formData?.[populators.name]}
name={populators?.name}
control={control}
/>
);
case "multiselectdropdown":
return (
<MultiUploadWrapper
t={t}
module="works"
tenantId={Digit.ULBService.getCurrentTenantId()}
getFormState={getFileStoreData}
showHintBelow={populators?.showHintBelow ? true : false}
setuploadedstate={value}
allowedFileTypesRegex={populators.allowedFileTypes}
allowedMaxSizeInMB={populators.allowedMaxSizeInMB}
hintText={populators.hintText}
maxFilesAllowed={populators.maxFilesAllowed}
extraStyleName={{ padding: "0.5rem" }}
customClass={populators?.customClass}
<Controller
name={`${populators.name}`}
control={control}
defaultValue={formData?.[populators.name]}
rules={{ required: populators?.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>
);
}}
/>
);
}}
/>
);
case "custom":
return (
<Controller
render={(props) => populators.component({ ...props, setValue }, populators.customProps)}
defaultValue={populators.defaultValue}
name={populators?.name}
control={control}
/>
);
case "radio":
case "dropdown":
return (
<Controller
render={(props) => (
<CustomDropdown
t={t}
label={config?.label}
type={type}
onBlur={props.onBlur}
value={props.value}
inputRef={props.ref}
onChange={props.onChange}
config={populators}
disable={config?.disable}
errorStyle={errors?.[populators?.name]}
/>
)}
rules={{ required: isMandatory, ...populators.validation }}
defaultValue={formData?.[populators?.name]}
name={populators?.name}
control={control}
/>
);
case "multiselectdropdown":
return (
<Controller
name={`${populators?.name}`}
control={control}
defaultValue={formData?.[populators?.name]}
rules={{ required: populators?.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)
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>
);
}}
selected={props?.value}
defaultLabel={t(populators?.defaultText)}
defaultUnit={t(populators?.selectedText)}
config={populators}
/>
</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" ,width:"100%"}}>
<LocationDropdownWrapper
props={props}
populators={populators}
formData={formData}
inputRef={props.ref}
errors={errors}
setValue={setValue}
);
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}
/>
</div>
);
}}
/>
</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} />
</div>
);
}}
/>
);
case "workflowstatesfilter":
return (
<Controller
name={`${populators?.name}`}
control={control}
defaultValue={formData?.[populators?.name]}
rules={{ required: populators?.isMandatory }}
render={(props) => {
);
case "apicheckboxes":
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" }}>
<ApiCheckboxes
props={props}
populators={populators}
formData={formData}
inputRef={props.ref}
errors={errors}
/>
</div>
);
}}
/>
);
case "workflowstatesfilter":
return (
<Controller
name={`${populators.name}`}
control={control}
defaultValue={formData?.[populators.name]}
rules={{ required: populators?.isMandatory }}
render={(props) => {
return (
<div style={{ display: "grid", gridAutoFlow: "row" }}>
<WorkflowStatusFilter
inboxResponse={data}
props={props}
populators={populators}
t={t}
formData={formData}
/>
</div>
);
}}
/>
);
case "dateRange":
return (
<Controller
render={(props) => (
<DateRangeNew
t={t}
values={formData?.[populators.name]?.range}
name={populators.name}
onFilterChange={props.onChange}
inputRef={props.ref}
errorStyle={errors?.[populators.name]}
populators={populators}
/>
)}
rules={{ required: isMandatory, ...populators.validation }}
defaultValue={formData?.[populators.name]}
name={populators?.name}
control={control}
/>
);
case "component":
return (
<div style={{ display: "grid", gridAutoFlow: "row" }}>
<WorkflowStatusFilter inboxResponse={data} props={props} populators={populators} t={t} formData={formData} />
</div>
<Controller
render={(props) => (
<Component
userType={"employee"}
t={t}
setValue={setValue}
onSelect={setValue}
config={config}
data={formData}
formData={formData}
register={register}
errors={errors}
props={props}
setError={setError}
clearErrors={clearErrors}
onBlur={props.onBlur}
control={control}
getValues={getValues}
responseData={data}
populators={populators}
/>
)}
name={config?.key}
control={control}
/>
);
}}
/>
);
case "dateRange":
return (
<Controller
render={(props) => (
<DateRangeNew
t={t}
values={formData?.[populators?.name]?.range}
name={populators?.name}
onFilterChange={props.onChange}
inputRef={props.ref}
errorStyle={errors?.[populators?.name]}
/>
)}
rules={{ required: isMandatory, ...populators.validation }}
defaultValue={formData?.[populators?.name]}
name={populators?.name}
control={control}
/>
);
case "component":
return (
<Controller
render={(props) => (
<Component
userType={"employee"}
t={t}
setValue={setValue}
onSelect={setValue}
config={config}
data={formData}
formData={formData}
register={register}
errors={errors}
props={props}
setError={setError}
clearErrors={clearErrors}
onBlur={props.onBlur}
control={control}
getValues={getValues}
responseData={data}
/>
)}
name={config?.key}
control={control}
/>
);
default:
return populators?.dependency !== false ? populators : null;
}
};
return (
<React.Fragment>
{fields?.map((item, index) => {
return (
<LabelFieldPair key={index} style={{ display: "flex", flexDirection: "column" ,alignItems:"flex-start"}}>
{item.label && (
<CardLabel style={{ ...props.labelStyle, marginBottom: "0.4rem" }}>
{t(item.label)}
{item?.isMandatory ? " * " : null}
</CardLabel>
)}
{fieldSelector(item.type, item.populators, item.isMandatory, item?.disable, item?.component, item)}
{item?.populators?.name && errors && errors[item?.populators?.name] && Object.keys(errors[item?.populators?.name]).length ? (
<CardLabelError style={{ fontSize: "12px", marginTop: "-20px" }}>{t(item?.populators?.error)}</CardLabelError>
) : null}
default:
return populators?.dependency !== false ? populators : null;
}
};
const handleTextInput = (type, populators, isMandatory, disable, component, config) => {
// Logic for text input
}
const handleTextArea = (type, populators, isMandatory, disable, component, config) => {
// Logic for textarea
}
const fieldSelector = (type, populators, isMandatory, disable = false, component, config) => {
switch (type) {
case "text":
case "number":
case "password":
case "time":
return handleTextInput(type, populators, isMandatory, disable, component, config);
case "textarea":
return handleTextArea(type, populators, isMandatory, disable, component, config);
// other cases
}
}

Comment on lines +108 to +121
<div className={`multi-select-dropdown-wrap ${disable ? "disabled" : ""}`} ref={dropdownRef}>
<div className={`master${active ? `-active` : ``} ${disable ? "disabled" : ""}`}>
<input className="cursorPointer" type="text" onKeyDown={keyChange} onFocus={() => setActive(true)} value={searchQuery} onChange={onSearch} placeholder={t(placeholder)} />
<div className="label"></div>
<p>{alreadyQueuedSelectedState.length > 0 ? `${isSurvey ? alreadyQueuedSelectedState?.filter((ob) => ob?.i18nKey !== undefined).length : alreadyQueuedSelectedState.length} ${defaultUnit}` : defaultLabel}</p>
<ArrowDown disable={disable} />
</div>
{config?.isDropdownWithChip ? (
<div className="digit-tag-container">
{alreadyQueuedSelectedState.length > 0 &&
alreadyQueuedSelectedState.map((value, index) => {
if (!value.propsData[1]?.options) {
const translatedText = t(value.code);
const replacedText = replaceDotWithColon(translatedText);
return (
<RemoveableTag
key={index}
text={replacedText.length > 64 ? `${replacedText.slice(0, 64)}...` : replacedText}
onClick={
variant === "treemultiselect"
? () => onSelectToAddToQueue([value])
: isPropsNeeded
? (e) => onSelectToAddToQueue(e, value, props)
: (e) => onSelectToAddToQueue(e, value)
}
className="multiselectdropdown-tag"
/>
);
}
return null;
})}
{alreadyQueuedSelectedState.length > 0 && (
<Button
label={t(config?.clearLabel ? config?.clearLabel : "Clear All")}
onClick={handleClearAll}
variation=""
style={{
height: "2rem",
minWidth: "4.188rem",
minHeight: "2rem",
padding: "0.5rem",
justifyContent: "center",
alignItems: "center",
borderRadius: "3.125rem",
border: "1px solid #F47738",
background: "#FAFAFA",
}}
textStyles={{ height: "auto", fontSize: "0.875rem", fontWeight: "400", width: "100%", lineHeight: "16px", color: "#F47738" }}
/>
)}
</div>
) : null}
{active ?
(
<div className="server" id="jk-dropdown-unique" style={ServerStyle ? ServerStyle : {}}>
<Menu />
</div>
) : null
}
Copy link

Choose a reason for hiding this comment

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

The main return block of the component is complex and includes inline conditional logic. Simplify this by breaking down into smaller components or using more descriptive helper functions.

Comment on lines +145 to +146
{showHint && <p className="cell-text">{t(props?.hintText)}</p>}
<div className={`upload-file ${user_type === "employee" ? "" : "upload-file-max-width"} ${props.disabled ? " disabled" : ""}`} style={extraStyles?.uploadFile ? extraStyles?.uploadFile : {}}>
Copy link

Choose a reason for hiding this comment

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

The rendering logic in the return statement is complex and includes multiple conditional renderings. Consider simplifying this by breaking it down into smaller components or using more descriptive helper functions.

Comment on lines +136 to +154
<div className="options-card date-range" style={{ overflow: "visible", width: "unset"}}>
<DateRange
className="pickerShadow"
focusedRange={focusedRange}
ranges={[selectionRange]}
rangeColors={["#F47738"]}
onChange={handleSelect}
onRangeFocusChange={setFocusedRange}
retainEndDateOnFirstSelection={true}
showSelectionPreview={true}
staticRanges={staticRanges}
inputRanges={[]}
weekStartsOn={1}
maxDate={populators?.maxDate}
minDate={populators?.minDate}
startDatePlaceholder={t("EVENTS_START_DATE_LABEL")}
endDatePlaceholder={t("EVENTS_END_DATE_LABEL")}
/>
</div>
Copy link

Choose a reason for hiding this comment

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

The rendering logic for the modal component is complex and includes inline conditional logic. Consider simplifying this by breaking it down into smaller components or using more descriptive helper functions.

Comment on lines +57 to +99
const renderHeader = () => {
switch (uiConfig?.typeMobile) {
case "filter": {
return (
<div className="popup-label" style={{ display: "flex", paddingBottom: "20px" }}>
<span className="header" style={{ display: "flex" }}>
<span className="icon" style={{ marginRight: "12px", marginTop: "5px", paddingBottom: "3px" }}><FilterIcon /></span>
<span style={{ fontSize: "1.5rem", fontWeight: "700", marginRight: "12px" }}>{t(`${uiConfig?.headerLabel || "TQM_INBOX_SORTBY"}`)}</span>
<span className="clear-search refresh-icon-container" onClick={clearSearch}><RefreshIcon /></span>
</span>
<span onClick={onClose}>
<CloseSvg />
</span>
</div>
);
}
case "sort": {
return (
<div className="popup-label" style={{ display: "flex", paddingBottom: "20px" }}>
<span className="header" style={{ display: "flex" }}>
<span className="icon" style={{ marginRight: "12px", marginTop: "5px", paddingBottom: "3px" }}><SortSvg /></span>
<span style={{ fontSize: "1.5rem", fontWeight: "700", marginRight: "12px" }}>{t(`${uiConfig?.headerLabel || "TQM_INBOX_SORTBY"}`)}</span>
<span className="clear-search refresh-icon-container" onClick={clearSearch}><RefreshIcon /></span>
</span>
<span onClick={onClose}>
<CloseSvg />
</span>
</div>
);
}
case "search": {
return (
<div className="popup-label" style={{ display: "flex", paddingBottom: "20px" }}>
<span className="header" style={{ display: "flex" }}>
<span className="icon" style={{ marginRight: "12px", marginTop: "5px" }}><SearchIcon /></span>
<span style={{ fontSize: "large" }}>{t(`${uiConfig?.headerLabel || "TQM_INBOX_SORTBY"}`)}</span>
</span>
<span onClick={onClose}>
<CloseSvg />
</span>
</div>
);
}
Copy link

Choose a reason for hiding this comment

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

The renderHeader function includes complex conditional rendering based on the uiConfig.typeMobile. Consider refactoring this to simplify the logic and improve readability.

- switch (uiConfig?.typeMobile) {
+ const headerDetails = getHeaderDetails(uiConfig?.typeMobile);
+ return (
+   <div className="popup-label" style={{ display: "flex", paddingBottom: "20px" }}>
+     <span className="header" style={{ display: "flex" }}>
+       <span className="icon" style={{ marginRight: "12px", marginTop: "5px", paddingBottom: "3px" }}>{headerDetails.icon}</span>
+       <span style={{ fontSize: "1.5rem", fontWeight: "700", marginRight: "12px" }}>{t(headerDetails.label)}</span>
+       <span className="clear-search refresh-icon-container" onClick={clearSearch}><RefreshIcon /></span>
+     </span>
+     <span onClick={onClose}>
+       <CloseSvg />
+     </span>
+   </div>
+ );

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.

Suggested change
const renderHeader = () => {
switch (uiConfig?.typeMobile) {
case "filter": {
return (
<div className="popup-label" style={{ display: "flex", paddingBottom: "20px" }}>
<span className="header" style={{ display: "flex" }}>
<span className="icon" style={{ marginRight: "12px", marginTop: "5px", paddingBottom: "3px" }}><FilterIcon /></span>
<span style={{ fontSize: "1.5rem", fontWeight: "700", marginRight: "12px" }}>{t(`${uiConfig?.headerLabel || "TQM_INBOX_SORTBY"}`)}</span>
<span className="clear-search refresh-icon-container" onClick={clearSearch}><RefreshIcon /></span>
</span>
<span onClick={onClose}>
<CloseSvg />
</span>
</div>
);
}
case "sort": {
return (
<div className="popup-label" style={{ display: "flex", paddingBottom: "20px" }}>
<span className="header" style={{ display: "flex" }}>
<span className="icon" style={{ marginRight: "12px", marginTop: "5px", paddingBottom: "3px" }}><SortSvg /></span>
<span style={{ fontSize: "1.5rem", fontWeight: "700", marginRight: "12px" }}>{t(`${uiConfig?.headerLabel || "TQM_INBOX_SORTBY"}`)}</span>
<span className="clear-search refresh-icon-container" onClick={clearSearch}><RefreshIcon /></span>
</span>
<span onClick={onClose}>
<CloseSvg />
</span>
</div>
);
}
case "search": {
return (
<div className="popup-label" style={{ display: "flex", paddingBottom: "20px" }}>
<span className="header" style={{ display: "flex" }}>
<span className="icon" style={{ marginRight: "12px", marginTop: "5px" }}><SearchIcon /></span>
<span style={{ fontSize: "large" }}>{t(`${uiConfig?.headerLabel || "TQM_INBOX_SORTBY"}`)}</span>
</span>
<span onClick={onClose}>
<CloseSvg />
</span>
</div>
);
}
const renderHeader = () => {
const headerDetails = getHeaderDetails(uiConfig?.typeMobile);
return (
<div className="popup-label" style={{ display: "flex", paddingBottom: "20px" }}>
<span className="header" style={{ display: "flex" }}>
<span className="icon" style={{ marginRight: "12px", marginTop: "5px", paddingBottom: "3px" }}>{headerDetails.icon}</span>
<span style={{ fontSize: "1.5rem", fontWeight: "700", marginRight: "12px" }}>{t(headerDetails.label)}</span>
<span className="clear-search refresh-icon-container" onClick={clearSearch}><RefreshIcon /></span>
</span>
<span onClick={onClose}>
<CloseSvg />
</span>
</div>
);
}

Comment on lines +108 to +199
: {}
}
>
<span className={customTableWrapperClassName}>
{tableTopComponent ? tableTopComponent : null}
<table
className={className}
{...getTableProps()}
style={styles}
ref={tableRef}
>
<thead>
{headerGroups.map((headerGroup) => (
<tr {...headerGroup.getHeaderGroupProps()}>
{showAutoSerialNo && (
<th style={{ verticalAlign: 'top' }}>
{showAutoSerialNo && typeof showAutoSerialNo == 'string'
? t(showAutoSerialNo)
: t('TB_SNO')}
</th>
)}
{headerGroup.headers.map((column) => (
<th
{...column.getHeaderProps(column.getSortByToggleProps())}
style={{ verticalAlign: 'top' }}
>
{column.render('Header')}
<span>
{column.isSorted ? (
column.isSortedDesc ? (
<SortDown />
) : (
<SortUp />
)
) : (
''
)}
</span>
</th>
))}
</tr>
);
})}
</tbody>
</table>
</span>
{isPaginationRequired && (
<div className="pagination dss-white-pre">
{`${t("CS_COMMON_ROWS_PER_PAGE")} :`}
<select
className="cp"
value={manualPagination ? pageSizeLimit : pageSize}
style={{ marginRight: "15px" }}
onChange={manualPagination ? onPageSizeChange : (e) => setPageSize(Number(e.target.value))}
))}
</thead>
<tbody {...getTableBodyProps()}>
{page.map((row, i) => {
// rows.slice(0, 10).map((row, i) => {
prepareRow(row);
return (
<tr {...row.getRowProps()}>
{showAutoSerialNo && <td>{i + 1}</td>}
{row.cells.map((cell) => {
return (
<td
// style={{ padding: "20px 18px", fontSize: "16px", borderTop: "1px solid grey", textAlign: "left", verticalAlign: "middle" }}
{...cell.getCellProps([
// {
// className: cell.column.className,
// style: cell.column.style,
// },
// getColumnProps(cell.column),
getCellProps(cell),
])}
>
{cell.attachment_link ? (
<a
style={{ color: '#1D70B8' }}
href={cell.attachment_link}
>
{cell.render('Cell')}
</a>
) : (
<React.Fragment>
{' '}
{cell.render('Cell')}{' '}
</React.Fragment>
)}
</td>
);
})}
</tr>
);
})}
</tbody>
</table>
</span>
</div>
{isPaginationRequired && (
Copy link

Choose a reason for hiding this comment

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

The rendering logic for the table and pagination controls is complex and includes multiple conditional renderings. Consider simplifying this by breaking it down into smaller components or using more descriptive helper functions.

Copy link

@nipunarora-eGov nipunarora-eGov left a comment

Choose a reason for hiding this comment

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

Also make sure you export newly added components, and update versions properly. Also assuming you've copy pasted components code from develop branch of digit properly @hridya-egov.

@@ -1,6 +1,7 @@
import React, { useEffect, useMemo } from "react";
import { useTranslation } from "react-i18next";
import {InboxSearchComposer, Loader, Button ,AddFilled} from "@egovernments/digit-ui-components";
import {Loader, Button ,AddFilled} from "@egovernments/digit-ui-components";

Choose a reason for hiding this comment

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

Check import

@@ -68,7 +69,7 @@ const ProjectSearch = () => {
)}
</div>
<div className="inbox-search-wrapper">
<InboxSearchComposer configs={configs}></InboxSearchComposer>
<InboxSearchComposerV2 configs={configs}></InboxSearchComposerV2>

Choose a reason for hiding this comment

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

Browsersession is required in v2

@@ -1,6 +1,7 @@
import React from "react";
import { useTranslation } from "react-i18next";
import { Header, Loader,InboxSearchComposer} from "@egovernments/digit-ui-components";
import { Header, Loader} from "@egovernments/digit-ui-components";
import InboxSearchComposerV2 from "../../../../../../ui-components/src/hoc/InboxSearchComposerV2";

Choose a reason for hiding this comment

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

Import here

@@ -25,7 +26,7 @@ const ProjectSearchAndInboxComponent = () => {
<React.Fragment>
<Header styles={{ fontSize: "32px" }}>{t(configs?.label)}</Header>
<div className="inbox-search-wrapper">
<InboxSearchComposer configs={configs}></InboxSearchComposer>
<InboxSearchComposerV2 configs={configs}></InboxSearchComposerV2>

Choose a reason for hiding this comment

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

Browser session?

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