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

Customer Request #228421 [WEB ADMIN] Benificiary Reject and Dropout conditions changed as per State | Bug #222613 [WEB UI] : Prerak Edit | Aadhar Page | Back Button is not working #2240

Open
wants to merge 2 commits into
base: release-2.7.7
Choose a base branch
from

Conversation

nawaz-ss
Copy link
Contributor

@nawaz-ss nawaz-ss commented Oct 7, 2024

https://tracker.tekdi.net/issues/228421
https://tracker.tekdi.net/issues/222613

I have ensured that following Pull Request Checklist is taken care of before sending this PR

  • Code is formatted as per format decided
  • Updated acceptance criteria in tracker
  • Updated test cases in test-cases-tracker

Summary by CodeRabbit

  • New Features

    • Introduced a reusable GetOptions component to render a list of chips based on provided data.
    • Enhanced error message display for Aadhaar updates.
  • Bug Fixes

    • Corrected variable names for improved clarity and consistency.
  • Refactor

    • Improved code readability by updating naming conventions and conditions in the switch statements.

Copy link

coderabbitai bot commented Oct 7, 2024

Walkthrough

The changes introduce a new functional component named GetOptions in the Profile.js file, which renders a list of Chip components based on a unique array provided through props. The component utilizes GetEnumValue for displaying labels and includes PropTypes for type checking. Additionally, several variable names have been updated for clarity, and the switch statements in specific functions have been modified for improved condition handling. The AadhaarDetails.js file has also been updated to include a new onPressBackButton prop for navigation and to comment out sections related to QR code scanning and KYC uploads, streamlining the component's functionality.

Changes

File Path Change Summary
apps/front-end/src/pages/admin/beneficiaries/Profile.js - Added GetOptions functional component with PropTypes.
- Renamed EditButton to editButton.
- Renamed aadhaarerror to aadhaarError.
- Corrected typo in benificiary.
- Updated switch statements for renderDropoutButton and renderRejectButton to use switch (true).
- Adjusted modal components and error messages to reflect new variable names.
apps/front-end/src/pages/front-end/facilitator/AadhaarDetails.js - Added onPressBackButton prop to Layout component for navigation.
- Commented out QR code scanning and KYC upload sections, including related buttons and conditional rendering.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Profile
    participant GetOptions
    participant GetEnumValue

    User->>Profile: Request to view beneficiaries
    Profile->>GetOptions: Render with array, enumType, enumApiData
    GetOptions->>GetEnumValue: Fetch labels for chips
    GetEnumValue-->>GetOptions: Return labels
    GetOptions-->>Profile: Render chips
    Profile-->>User: Display beneficiaries with chips
Loading

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

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

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

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

CodeRabbit Commands (Invoked using PR comments)

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

Other keywords and placeholders

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

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.

@nawaz-ss nawaz-ss changed the title Rejected and Dropout conditions changed on IP side Customer Request #228421 [WEB ADMIN] Benificiary Reject and Dropout conditions changed as per State Oct 7, 2024
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: 0

🧹 Outside diff range and nitpick comments (3)
apps/front-end/src/pages/admin/beneficiaries/Profile.js (3)

206-206: Improved variable naming, but there's a typo

The variable naming has been improved for consistency and follows camelCase convention. However, there's a typo in benificiary that should be corrected.

Consider changing benificiary to beneficiary for correct spelling:

-const [benificiary, setBenificiary] = useState();
+const [beneficiary, setBeneficiary] = useState();

Also applies to: 215-215, 217-217


Line range hint 465-489: Improved status handling, but consider refactoring for readability

The renderDropoutButton function has been updated to handle more status cases, which improves its functionality. The use of switch (true) allows for more complex conditions.

Consider refactoring this function to improve readability. One approach could be to use an object lookup or a series of if-else statements. For example:

const renderDropoutButton = useMemo(() => {
  const status = benificiary?.result?.program_beneficiaries?.status;
  const dropoutEligibleStatuses = [
    'identified',
    'ready_to_enroll',
    'enrolled',
    'approved_ip',
    'activate',
    'enrolled_ip_verified',
    'sso_id_enrolled',
    'sso_id_verified',
    null
  ];

  const isEligibleForDropout = dropoutEligibleStatuses.includes(status) &&
    (status !== 'enrolled' || state_name !== 'RAJASTHAN') &&
    (status !== 'enrolled_ip_verified' || state_name !== 'RAJASTHAN') &&
    (status !== 'sso_id_enrolled' || state_name === 'RAJASTHAN') &&
    (status !== 'sso_id_verified' || state_name === 'RAJASTHAN');

  if (isEligibleForDropout) {
    return (
      <AdminTypo.Dangerbutton
        onPress={(e) => setIsOpenDropOut(true)}
        leftIcon={<IconByName name="UserUnfollowLineIcon" isDisabled />}
      >
        {t("MARK_AS_DROPOUT")}
      </AdminTypo.Dangerbutton>
    );
  }

  return null;
}, [benificiary, state_name, t]);

This approach centralizes the logic and makes it easier to understand and maintain.


Line range hint 509-533: Improved status handling, consider similar refactoring

The renderRejectButton function has been updated similarly to renderDropoutButton, improving its functionality by handling more status cases.

Consider applying a similar refactoring approach as suggested for renderDropoutButton to improve readability and maintainability. For example:

const renderRejectButton = useMemo(() => {
  const status = benificiary?.result?.program_beneficiaries?.status;
  const rejectEligibleStatuses = [
    'identified',
    'ready_to_enroll',
    'enrolled',
    'approved_ip',
    'activate',
    'enrolled_ip_verified',
    'sso_id_enrolled',
    'sso_id_verified',
    null
  ];

  const isEligibleForReject = rejectEligibleStatuses.includes(status) &&
    (status !== 'enrolled' || state_name !== 'RAJASTHAN') &&
    (status !== 'enrolled_ip_verified' || state_name !== 'RAJASTHAN') &&
    (status !== 'sso_id_enrolled' || state_name === 'RAJASTHAN') &&
    (status !== 'sso_id_verified' || state_name === 'RAJASTHAN');

  if (isEligibleForReject) {
    return (
      <AdminTypo.Dangerbutton
        onPress={(e) => setIsOpenReject(true)}
        leftIcon={<IconByName name="UserUnfollowLineIcon" isDisabled />}
      >
        {t("REJECT")}
      </AdminTypo.Dangerbutton>
    );
  }

  return null;
}, [benificiary, state_name, t]);

This refactoring would make the function more consistent with the suggested changes for renderDropoutButton and improve overall code maintainability.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between f3f74d4 and 071843d.

📒 Files selected for processing (1)
  • apps/front-end/src/pages/admin/beneficiaries/Profile.js (16 hunks)
🧰 Additional context used
🔇 Additional comments (4)
apps/front-end/src/pages/admin/beneficiaries/Profile.js (4)

175-195: New component looks good!

The GetOptions component is well-structured and reusable. It efficiently renders a list of unique options as Chip components, utilizing existing utility functions and components.


197-202: PropTypes are well-defined

The PropTypes for the GetOptions component are correctly specified, which is excellent for type checking and documentation.


1689-1689: Correct usage of updated state variable

The error message display has been updated to use the corrected state variable name aadhaarError. This ensures that the error message will be displayed correctly.


Line range hint 1225-1229: Verify the intentional removal of isDisabled prop

The isDisabled prop has been removed from several Select components in the edit access modal. This change allows these components to be always enabled, regardless of the editButton state.

Please confirm if this change is intentional. If not, consider re-adding the isDisabled prop to prevent unintended edits:

-<Select
+<Select
+  isDisabled={!editButton}
   selectedValue={status?.jan_aadhaar_card || ""}
   accessibilityLabel="Select"
   placeholder={status?.jan_aadhaar_card || "Select"}
   // ... other props
>

Apply this change to all affected Select components if necessary.

Also applies to: 1268-1272, 1307-1311, 1347-1351, 1387-1391, 1427-1431, 1468-1472

Copy link

sonarcloud bot commented Oct 7, 2024

@nawaz-ss nawaz-ss changed the title Customer Request #228421 [WEB ADMIN] Benificiary Reject and Dropout conditions changed as per State Customer Request #228421 [WEB ADMIN] Benificiary Reject and Dropout conditions changed as per State | Bug #222613 [WEB UI] : Prerak Edit | Aadhar Page | Back Button is not working Oct 7, 2024
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: 0

🧹 Outside diff range and nitpick comments (1)
apps/front-end/src/pages/front-end/facilitator/AadhaarDetails.js (1)

30-30: LGTM! Consider parameterizing the navigation target.

The addition of the onPressBackButton prop improves the component's navigation functionality, providing a clear way for users to return to the profile page. This is a good usability enhancement.

Consider parameterizing the navigation target instead of hardcoding it. This would make the component more flexible and reusable. For example:

-onPressBackButton: () => navigate(`/profile`),
+onPressBackButton: () => navigate(backUrl),

Where backUrl could be passed as a prop or determined based on the component's context.

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 071843d and 755771e.

📒 Files selected for processing (1)
  • apps/front-end/src/pages/front-end/facilitator/AadhaarDetails.js (1 hunks)
🧰 Additional context used

@Pritams43 Pritams43 changed the base branch from release-2.7.6 to release-2.7.7 October 8, 2024 11:42
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.

1 participant