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

fix #1391

Merged
merged 6 commits into from
Sep 17, 2024
Merged

fix #1391

merged 6 commits into from
Sep 17, 2024

Conversation

aaradhya-egov
Copy link
Contributor

No description provided.

@aaradhya-egov aaradhya-egov requested a review from a team as a code owner September 16, 2024 09:38
Copy link
Contributor

coderabbitai bot commented Sep 16, 2024

Walkthrough

Walkthrough

The changes involve modifications to the UserProfile.js, OTPInput.js, and Localities.js files. In UserProfile.js, conditional logic is introduced for input field properties based on the result of Digit.Utils.getMultiRootTenant(), affecting user interaction in multi-tenant scenarios. In OTPInput.js, the input type is changed from "number" to "text," and validation logic is refined to ensure only valid numeric input is accepted. Additionally, in Localities.js, the behavior of the ADMIN_CODE function is adjusted to conditionally return values based on the tenant check. These adjustments enhance the responsiveness and flexibility of user inputs within the application.

Changes

File Path Change Summary
micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Home/UserProfile.js Introduced conditional logic for disable and disabled properties of input fields based on getMultiRootTenant(). Adjusted rendering of the change password button.
micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/OTPInput.js Changed input type from "number" to "text" and updated validation logic to accept single digits. Modified input handling to manage empty string cases.
micro-ui/web/micro-ui-internals/packages/libraries/src/services/elements/Localities.js Added conditional check in ADMIN_CODE function to return hierarchyType.code based on getMultiRootTenant().

Possibly related PRs

Poem

🐰 In fields of code, we hop and play,
With inputs bright, we pave the way.
A tenant's call, we heed with care,
For numbers and text, we freely share.
A change of heart, a button's grace,
In this rabbit's world, we find our place! 🌟


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

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

Other keywords and placeholders

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

CodeRabbit Configuration File (.coderabbit.yaml)

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

Documentation and Community

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

We are currently testing the following features in early access:

  • OpenAI o1 for code reviews: OpenAI's new o1 model is being tested for generating code suggestions in code reviews.

Note:

  • You can enable or disable early access features from the CodeRabbit UI or by updating the CodeRabbit configuration file.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 17dff87 and 3a6cf15.

Files selected for processing (2)
  • micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Home/UserProfile.js (3 hunks)
  • micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/OTPInput.js (3 hunks)
Additional context used
Path-based instructions (2)
micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/OTPInput.js (1)

Pattern **/*.js: check

micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Home/UserProfile.js (1)

Pattern **/*.js: check

Biome
micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Home/UserProfile.js

[error] 727-727: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)

Additional comments not posted (6)
micro-ui/web/micro-ui-internals/packages/react-components/src/atoms/OTPInput.js (4)

21-21: Ensure validation logic is updated to handle non-numeric input.

Changing the input type to "text" allows for a broader range of input handling, including the ability to accept empty strings. This change is significant as it alters how user input is processed, enabling the input to accept non-numeric characters.

Please ensure that the validation logic is updated accordingly to handle non-numeric input and prevent any unintended behavior.


32-32: LGTM!

The updated validation logic using the regular expression /^[0-9]$/ ensures that only valid numeric input (single digit) is accepted. This change aligns with the updated input type and refines the validation process.


63-67: LGTM!

The updated inputChange function handles the case where the input is valid (single digit) by updating the OTP value using the changeCodeAtFocus function and moving the focus to the next input field using the focusNextInput function.

This change enhances the user experience by automatically moving the focus to the next input field after a valid input is entered.


67-68: LGTM!

The updated inputChange function handles the case where the input is cleared (i.e., when the value is an empty string) by calling the changeCodeAtFocus function with an empty string.

This change ensures that the application can appropriately manage the state of the input when users delete their entries, enhancing the overall user experience.

micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Home/UserProfile.js (2)

762-762: LGTM!

The conditional logic to disable the email field in multi-tenant scenarios looks good and aligns with the provided summary of changes.


779-779: LGTM!

The conditional rendering of the change password button based on the multi-tenancy check looks good and aligns with the provided summary of changes.

coderabbitai[bot]
coderabbitai bot previously approved these changes Sep 16, 2024
Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between f7a57fc and 10e16da.

Files selected for processing (1)
  • micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Home/UserProfile.js (3 hunks)
Additional context used
Path-based instructions (1)
micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Home/UserProfile.js (1)

Pattern **/*.js: check

Biome
micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Home/UserProfile.js

[error] 727-727: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)

Additional comments not posted (2)
micro-ui/web/micro-ui-internals/packages/modules/core/src/pages/citizen/Home/UserProfile.js (2)

762-762: LGTM!

The change to conditionally disable the email input field based on the result of Digit.Utils.getMultiRootTenant() enhances the component's responsiveness to the application's multi-tenant capabilities.


779-779: LGTM!

The change to conditionally render the change password button based on the values of changepassword and the result of Digit.Utils.getOTPBasedLogin() aligns the component's behavior with the multi-tenant capabilities of the application.

@@ -724,7 +724,7 @@ const UserProfile = ({ stateCode, userType, cityDetails }) => {
name="mobileNumber"
placeholder="Enter a valid Mobile No."
onChange={(value) => setUserMobileNumber(value)}
disable={true}
disable={Digit.Utils.getMultiRootTenant()? false : true}
Copy link
Contributor

Choose a reason for hiding this comment

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

Simplify the conditional expression.

The ternary operator is redundant here as the result of Digit.Utils.getMultiRootTenant() is already a boolean value. Consider simplifying the code by directly assigning the negated result to the disable prop.

Apply this diff to simplify the code:

-disable={Digit.Utils.getMultiRootTenant()? false : true}
+disable={!Digit.Utils.getMultiRootTenant()}
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
disable={Digit.Utils.getMultiRootTenant()? false : true}
disable={!Digit.Utils.getMultiRootTenant()}
Tools
Biome

[error] 727-727: Unnecessary use of boolean literals in conditional expression.

Simplify your code by directly assigning the result without using a ternary operator.
If your goal is negation, you may use the logical NOT (!) or double NOT (!!) operator for clearer and concise code.
Check for more details about NOT operator.
Unsafe fix: Remove the conditional expression with

(lint/complexity/noUselessTernary)

@@ -1,7 +1,11 @@
import { LocalizationService } from "./Localization/service";

const ADMIN_CODE = ({ tenantId, hierarchyType }) => {
if(Digit.Utils.getMultiRootTenant()){
return hierarchyType.code;
Copy link
Collaborator

Choose a reason for hiding this comment

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

why overriding this way ? then how the boundary codes gets localised
? @aaradhya-egov

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In localisation code, previously it is creating code with tenant but in our case tenant will be dynamic thats why i have removed tenant from localisaed code. from here i am just taking code. and below we have getlocalities function where I am using that localisation code @jagankumar-egov

Copy link
Collaborator

Choose a reason for hiding this comment

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

Ok

@jagankumar-egov jagankumar-egov merged commit 49481a4 into develop Sep 17, 2024
2 checks passed
@jagankumar-egov jagankumar-egov deleted the otp-fix branch September 17, 2024 05:45
@coderabbitai coderabbitai bot mentioned this pull request Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants