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 state & district autofill & multiple other small issues in Patient Registration page #9711

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

Conversation

yash-learner
Copy link
Member

@yash-learner yash-learner commented Jan 3, 2025

Proposed Changes


auto_fill_state_._district_based_on_pincode.webm

@ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate bug / test a new feature.
  • Update product documentation.
  • Ensure that UI text is kept in I18n files.
  • Prep screenshot or demo video for changelog entry, and attach it to issue.
  • Request for Peer Reviews
  • Completion of QA

Summary by CodeRabbit

  • New Features

    • Enhanced patient registration process with dynamic organization selection based on pincode.
    • Introduced a new custom hook for retrieving state and district information from pincode.
    • Added new props to the organization selector for improved functionality.
  • Bug Fixes

    • Improved organization selector component to handle pre-selected levels and error messages.
  • Improvements

    • Streamlined pincode handling and organization selection functionality.
    • Enhanced responsiveness to prop changes and error handling in the organization selector.
    • Added specific error messages for organization fetching and pincode auto-fill failures.

Copy link
Contributor

coderabbitai bot commented Jan 3, 2025

Walkthrough

The pull request introduces enhancements to the patient registration process by implementing automatic state and district selection based on the entered pincode. Key modifications are made to the PatientRegistration and OrganizationSelector components to improve organization level selection. A new custom hook, useStateAndDistrictFromPincode, is added to streamline pincode handling, replacing the previous logic. These changes facilitate a more efficient registration experience.

Changes

File Change Summary
src/components/Patient/PatientRegistration.tsx - Added CareIcon import
- Introduced useStateAndDistrictFromPincode hook
- Removed handlePincodeChange function
- Added selectedLevels state
- Updated OrganizationSelector props with parentSelectedLevels and errorMessage
src/pages/Organization/components/OrganizationSelector.tsx - Updated OrganizationSelectorProps interface with parentSelectedLevels and errorMessage
- Modified state initialization to use parentSelectedLevels
- Adjusted handleEdit function and added useEffect for prop updates
src/hooks/useOrganization.ts - Introduced useOrganization hook for fetching organization data
- Added UseOrganizationParams interface
src/hooks/useStateAndDistrictFromPincode.ts - Introduced useStateAndDistrictFromPincode hook for retrieving state and district from pincode
- Added UseStateAndDistrictProps interface
public/locale/en.json - Added error messages for organization fetching and pincode autofill failures

Assessment against linked issues

Objective Addressed Explanation
Autofill state from pincode [#9668]
Render district based on pincode

Possibly related PRs

Suggested labels

needs review, needs testing, good to merge

Suggested reviewers

  • rithviknishad
  • Jacobjeevan
  • bodhish

Poem

🐰 In the meadow of code, we hop with delight,
Pincode whispers secrets, making things right.
Organizations bloom, like flowers in spring,
Autofill magic, oh what joy it can bring!
Registration's path is now smooth and bright! 🏥


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 generate docstrings to generate docstrings for this PR. (Beta)
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

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

CodeRabbit Configuration File (.coderabbit.yaml)

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

Documentation and Community

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

Copy link

netlify bot commented Jan 3, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 4dd0e93
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/67780083aa0cb90008faa259
😎 Deploy Preview https://deploy-preview-9711--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

Copy link

netlify bot commented Jan 3, 2025

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit c6b1783
🔍 Latest deploy log https://app.netlify.com/sites/care-ohc/deploys/677bc54e1e0750000814c69f
😎 Deploy Preview https://deploy-preview-9711--care-ohc.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@yash-learner yash-learner changed the title Fix state & district autofill Fix state & district autofill in Patient Registration page Jan 3, 2025
@yash-learner yash-learner changed the title Fix state & district autofill in Patient Registration page Fix state & district autofill in Patient Registration page & multiple other small issues Jan 3, 2025
@yash-learner yash-learner changed the title Fix state & district autofill in Patient Registration page & multiple other small issues Fix state & district autofill & multiple other small issues in Patient Registration page Jan 3, 2025
Comment on lines 323 to 337
async function fetchOrganizationByName(name: string, parentId?: string) {
try {
const data = await query(organizationApi.list, {
queryParams: {
org_type: "govt",
parent: parentId || "",
name,
},
})({ signal: new AbortController().signal });
return data.results?.[0];
} catch (error) {
toast.error("Error fetching organization");
return undefined;
}
}
Copy link
Member Author

Choose a reason for hiding this comment

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

At some point, we may need to extract this into a separate hook

Copy link
Contributor

@Jacobjeevan Jacobjeevan Jan 4, 2025

Choose a reason for hiding this comment

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

Yea, go ahead and do that since same logic is being used in #9662.

Also check Rithvik's comment below.

cc: @Mahendar0701

@yash-learner yash-learner marked this pull request as ready for review January 3, 2025 21:45
@yash-learner yash-learner requested a review from a team as a code owner January 3, 2025 21:45
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: 0

🧹 Nitpick comments (6)
src/pages/Organization/components/OrganizationSelector.tsx (2)

23-24: Add documentation for new props.
Prefer adding a short explanation or a JSDoc comment for parentSelectedLevels and errorMessage to guide future maintainers on their usage.


170-171: Push only meaningful errors.
errors={[props.errorMessage || ""]} might cause an empty string to appear if there's no actual error. Consider conditionally passing an empty array instead to avoid confusing UI.

-errors={[props.errorMessage || ""]}
+errors={props.errorMessage ? [props.errorMessage] : []}
src/components/Patient/PatientRegistration.tsx (4)

6-6: Confirm i18n usage for toast messages.
Since you are using translations in other notifications, consider localizing toast errors to maintain a consistent user experience.


208-213: Consider grouping pincode org fetch logic.
The logic fetches the state org first, then sets selectedLevels to [] early if state org is not found. Consider returning a partial selection if the state is found but not the district – or add a fallback mechanism.


326-340: Add robust error details.
toast.error("Error fetching organization") might leave users uncertain about the exact cause. Consider including the organization name in the error text or using a more descriptive message.


625-625: Improve UX for disabled text area.
You correctly remove editing with cursor-not-allowed if addresses match. Optionally, add a tooltip or note explaining why the field is disabled for clarity.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 68c4c3d and f58e7b5.

📒 Files selected for processing (2)
  • src/components/Patient/PatientRegistration.tsx (7 hunks)
  • src/pages/Organization/components/OrganizationSelector.tsx (5 hunks)
🔇 Additional comments (6)
src/pages/Organization/components/OrganizationSelector.tsx (3)

33-36: Initialize state thoughtfully.
Using parentSelectedLevels || [] is fine. Consider logging or handling scenarios where parentSelectedLevels might be empty due to unexpected data, ensuring robust default behaviors.


112-124: Validate data removal edge cases.
When the user removes all levels (newLevels.length === 0), you reset the selection. This is correct for typical usage. Confirm that removing the top-level organization doesn't break parent-child flows if the parent-level has siblings or alternative branches.


127-132: Avoid re-initialization loops.
The useEffect reassigns state when parentSelectedLevels changes. This is correct but be aware of potential repeated updates if parent-level changes are frequent.

src/components/Patient/PatientRegistration.tsx (3)

85-85: Validate usage of local org state.
selectedLevels is used to maintain hierarchical organization data derived from the pincode. Ensure that clearing it in one place does not inadvertently disrupt other parts of registration.


219-222: Handle partial fetch failures.
If the district API fails, current logic omits selecting the state org. Evaluate whether you want to preserve the state org even if the district is not found.


676-683: Check null-safety for error message.
You pass errorMessage={errors.geo_organization?.[0]} but if geo_organization is missing or empty, it may show an undefined or empty string in OrganizationSelector. Confirm the UI reflects a real error only when relevant.

Copy link
Member

@rithviknishad rithviknishad left a comment

Choose a reason for hiding this comment

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

not a fan of this approach. how about we stick with how dependent queries are made as per tanstacks docs?

https://tanstack.com/query/latest/docs/framework/react/guides/dependent-queries#usequery-dependent-query

this way we wouldn't need to try catch either and stick with the simplicity.

cc @bodhish

Copy link

github-actions bot commented Jan 5, 2025

👋 Hi, @yash-learner,
Conflicts have been detected against the base branch. Please rebase your branch against the base branch.


This message is automatically generated by prince-chrismc/label-merge-conflicts-action so don't hesitate to report issues/improvements there.

@yash-learner
Copy link
Member Author

not a fan of this approach. how about we stick with how dependent queries are made as per tanstacks docs?

https://tanstack.com/query/latest/docs/framework/react/guides/dependent-queries#usequery-dependent-query

this way we wouldn't need to try catch either and stick with the simplicity.

cc @bodhish

@rithviknishad

Updated it in this bdd739f, 6905db3. Does it look good ?

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

🧹 Nitpick comments (12)
src/hooks/useOrganization.ts (2)

7-12: Add User Facing Documentation Comment for UseOrganizationParams

Though this interface is self-explanatory, adding a short JSDoc comment or code comment could clarify the accepted parameters for future maintainers and reduce confusion about which fields are optional.


20-31: Ensure error handling is robust

While isError is returned, there is no specialized error handling in the queryFn or an onError callback for the query. If additional failover or fallback logic is required when the API call fails, consider adding a custom onError in the useQuery options or a shared error boundary.

src/hooks/useStateAndDistrictFromPincode.ts (3)

14-16: Clarify hook naming or add doc comment

The function name useStateAndDistrictFromPincode is descriptive, but consider adding inline documentation about how it fetches pincode details, extracts the state and district, and loads the corresponding organizations. This can improve maintainability.


43-53: Consider concurrency or caching benefits

The second organization query is nested behind the first's result for stateOrg?.id. This is logical. If you anticipate repeated lookups or the same pincodes, ensure that React Query’s caching strategy is adequately configured to minimize network calls.


56-61: Combine isError states carefully

This hook merges three possible error states into one, which is correct for a simplified approach. However, distinct error messages can help users identify which step failed (e.g., the pincode fetch vs. the state org fetch). Consider returning more granular error states if needed.

src/components/Patient/PatientRegistration.tsx (7)

6-6: Check the usage of CareIcon import

The CareIcon import is newly added. Verify whether all necessary icons are being efficiently imported. For performance, you might consider a dynamic icon library approach if your codebase loads many icons.


30-30: Mention the custom hook in documentation or inline comments

useStateAndDistrictFromPincode is introduced here. A short comment indicating its purpose in the patient registration flow (e.g., “Auto-fills state and district based on pincode”) could guide future contributors.


79-79: Refactor state management for clarity

selectedLevels and setSelectedLevels hold the acquired organizations. Consider whether these should be combined or abstracted to a single object (like geoOrganization) if there’s no plan to scale beyond two levels. This might simplify future expansions.


189-191: Decouple logic from the UI effect

The useStateAndDistrictFromPincode hook is invoked inline here. If you anticipate using the same logic in other forms, it might be beneficial to centralize or abstract the effect of pincode changes, e.g., in a custom reducer or separate function for clarity.


194-206: Enhance user feedback for partial auto-fill

If some part of the data can’t be automatically derived from the pincode (e.g., the district wasn’t found), the pincode_autofill message still appears if levels.length > 0. Consider either partial messages or fallback for missing details.


580-580: UI clarity for disabled text area

When sameAddress is true, the permanent address is disabled. The cursor-not-allowed is good, but consider adding a tooltip or helper text to clarify that the permanent address matches the current address. This could improve UX.


Line range hint 596-606: Refine timed feedback approach

You’re displaying _showAutoFilledPincode for 2 seconds to highlight auto-filling. This is a subtle user experience detail. If users need more time or have accessibility needs, consider a more stable or dismissible notification.

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between f58e7b5 and 45a3d9f.

📒 Files selected for processing (3)
  • src/components/Patient/PatientRegistration.tsx (8 hunks)
  • src/hooks/useOrganization.ts (1 hunks)
  • src/hooks/useStateAndDistrictFromPincode.ts (1 hunks)
🔇 Additional comments (5)
src/hooks/useOrganization.ts (1)

14-19: Confirm default parameter usage logic

Currently, the default values for orgType, parentId, and name are all empty strings. If the intended scenario requires no query to run until a valid name is provided, this setup is fine. Otherwise, you might consider enabling queries based on other parameter conditions (like orgType).

src/hooks/useStateAndDistrictFromPincode.ts (2)

17-25: Validate pincode more thoroughly

validatePincode(pincode) is used to control the enabled property, but ensure it returns false for invalid or partial input. If user input can be partially typed, consider whether the query should wait until the pincode is a specific length (e.g., 6 digits in India).


30-40: Check for fallback behavior when stateName is missing

If pincodeDetails.statename is an empty string, the state query is disabled, which is correct. Just confirm that this is the desired behavior. If there is a possibility of partial matches or alternate naming, you might need more robust fallback or alias logic for stateName.

src/components/Patient/PatientRegistration.tsx (2)

43-46: Validate usage of new or changed imports

With the introduction of OrganizationSelector from @/pages/Organization/components/OrganizationSelector, ensure no cyclical imports exist and confirm version compatibility. This is more of a housekeeping check.


631-638: Verify the OrganizationSelector usage

OrganizationSelector is receiving parentSelectedLevels and an errorMessage. Ensure that the error logic is consistent with your form validation approach. If you have an external form library or inline validation, confirm that the error message updates as expected.

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

🧹 Nitpick comments (3)
src/pages/Organization/components/OrganizationSelector.tsx (3)

33-36: Consider optimizing for reference stability.

While the implementation is functionally correct, consider adding a deep comparison to prevent unnecessary re-renders when only the reference of parentSelectedLevels changes but the content remains the same.

  useEffect(() => {
    if (parentSelectedLevels) {
+     const hasChanged = JSON.stringify(parentSelectedLevels) !== JSON.stringify(selectedLevels);
+     if (hasChanged) {
        setSelectedLevels(parentSelectedLevels);
+     }
    }
  }, [parentSelectedLevels]);

Also applies to: 123-127


108-120: Consider simplifying the control flow.

While the logic is correct, the nested if-else structure could be simplified for better readability.

  const handleEdit = (level: number) => {
    const newLevels = selectedLevels.slice(0, level);
    setSelectedLevels(newLevels);

-   if (!newLevels.length) {
-     onChange("");
-   } else {
-     const lastOrg = newLevels[newLevels.length - 1];
-     if (!lastOrg.has_children) {
-       onChange(lastOrg.id);
-     } else {
-       onChange("");
-     }
-   }
+   const lastOrg = newLevels[newLevels.length - 1];
+   const newValue = lastOrg && !lastOrg.has_children ? lastOrg.id : "";
+   onChange(newValue);
  };

170-171: Simplify required prop and improve error handling.

Two minor improvements could be made:

  1. The double negation (!!) is unnecessary since required is already boolean
  2. Consider passing undefined instead of an empty string array when there's no error
-           required={!!required}
-           errors={[props.errorMessage || ""]}
+           required={required}
+           errors={props.errorMessage ? [props.errorMessage] : undefined}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 45a3d9f and ca922bb.

📒 Files selected for processing (1)
  • src/pages/Organization/components/OrganizationSelector.tsx (5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: cypress-run (1)
  • GitHub Check: OSSAR-Scan
🔇 Additional comments (2)
src/pages/Organization/components/OrganizationSelector.tsx (2)

22-23: LGTM! Well-structured prop additions.

The new optional props enhance the component's flexibility while maintaining type safety.


31-31: Address the TODO comment for component renaming.

The TODO comment suggests renaming to GovtOrganizationSelector. This would indeed better reflect the component's specific purpose, as it's currently hardcoded to handle government organizations (org_type: "govt").

Would you like me to help create a GitHub issue to track this renaming task? This would include:

  1. Renaming the component
  2. Updating all imports
  3. Updating documentation

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

🧹 Nitpick comments (6)
src/hooks/useOrganization.ts (2)

23-24: Consider enhancing the query key specificity.

The current query key ["organization", orgType, name, parentId] could potentially cause cache collisions. Consider adding a more specific prefix.

-    queryKey: ["organization", orgType, name, parentId],
+    queryKey: ["organization", "list", orgType, name, parentId],

37-37: Enhance error toast message with more context.

The generic error message could be more helpful by including the context of what failed.

-  isError && toast.error(t("organizations_fetch_error"));
+  isError && toast.error(t("organizations_fetch_error", { context: `${orgType}${parentId ? ' for parent ' + parentId : ''}` }));
src/hooks/useStateAndDistrictFromPincode.ts (2)

58-62: Consider combining error notifications.

Multiple toast notifications for state and district errors might overwhelm the user. Consider combining them into a single notification.

-  isStateError && toast.info(t("pincode_state_auto_fill_error"));
-
-  isDistrictError &&
-    !isStateError &&
-    toast.info(t("pincode_district_auto_fill_error"));
+  useEffect(() => {
+    if (isStateError || isDistrictError) {
+      const errors = [];
+      if (isStateError) errors.push(t("pincode_state_auto_fill_error"));
+      if (isDistrictError && !isStateError) errors.push(t("pincode_district_auto_fill_error"));
+      toast.info(errors.join(". "));
+    }
+  }, [isStateError, isDistrictError, t]);

34-56: Consider combining state and district queries.

The separate queries for state and district organizations could be combined using a single useQuery to reduce network requests.

+  const { data: orgs, isLoading, isError } = useQuery({
+    queryKey: ["organizations", "state-district", stateName, districtName],
+    queryFn: async () => {
+      const stateOrg = await organizationApi.list({ 
+        org_type: "govt",
+        name: stateName 
+      });
+      if (stateOrg.results?.[0]) {
+        const districtOrg = await organizationApi.list({
+          org_type: "govt",
+          parent: stateOrg.results[0].id,
+          name: districtName
+        });
+        return {
+          stateOrg: stateOrg.results[0],
+          districtOrg: districtOrg.results[0]
+        };
+      }
+      return { stateOrg: null, districtOrg: null };
+    },
+    enabled: !!stateName && !!districtName
+  });
src/components/Patient/PatientRegistration.tsx (2)

189-206: Consider extracting form management logic into a custom hook.

The form management logic, including the pincode-based autofill functionality, could be extracted into a custom hook to improve maintainability and reusability.

// usePatientRegistrationForm.ts
export function usePatientRegistrationForm(initialData?: Partial<PatientModel>) {
  const [form, setForm] = useState<Partial<PatientModel>>(initialData || {
    nationality: "India",
    phone_number: "+91",
    emergency_phone_number: "+91",
  });
  
  const { stateOrg, districtOrg } = useStateAndDistrictFromPincode({
    pincode: form.pincode?.toString() || "",
  });
  
  const [selectedLevels, setSelectedLevels] = useState<Organization[]>([]);
  const [showAutoFilledPincode, setShowAutoFilledPincode] = useState(false);

  useEffect(() => {
    const levels: Organization[] = [];
    if (stateOrg) levels.push(stateOrg);
    if (districtOrg) levels.push(districtOrg);
    setSelectedLevels(levels);

    if (levels.length === 2) {
      setShowAutoFilledPincode(true);
      const timer = setTimeout(() => {
        setShowAutoFilledPincode(false);
      }, 2000);
      return () => clearTimeout(timer);
    }
  }, [stateOrg, districtOrg]);

  return {
    form,
    setForm,
    selectedLevels,
    showAutoFilledPincode
  };
}

Line range hint 596-606: Extract autofill notification into a separate component.

The autofill notification UI could be extracted into a reusable component.

// AutofillNotification.tsx
interface AutofillNotificationProps {
  show: boolean;
  message: string;
}

function AutofillNotification({ show, message }: AutofillNotificationProps) {
  if (!show) return null;
  
  return (
    <div>
      <CareIcon
        icon="l-check-circle"
        className="mr-2 text-sm text-green-500"
      />
      <span className="text-sm text-primary-500">
        {message}
      </span>
    </div>
  );
}
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ca922bb and c6b1783.

📒 Files selected for processing (4)
  • public/locale/en.json (2 hunks)
  • src/components/Patient/PatientRegistration.tsx (8 hunks)
  • src/hooks/useOrganization.ts (1 hunks)
  • src/hooks/useStateAndDistrictFromPincode.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (1)
  • GitHub Check: cypress-run (1)
🔇 Additional comments (4)
src/hooks/useOrganization.ts (1)

31-31: LGTM! Smart query enablement condition.

The query is enabled only when both conditions are met: enabled && !!name. This prevents unnecessary API calls.

src/hooks/useStateAndDistrictFromPincode.ts (1)

26-26: LGTM! Smart validation before query.

Using validatePincode before enabling the query prevents unnecessary API calls with invalid pincodes.

src/components/Patient/PatientRegistration.tsx (1)

631-638: LGTM! Proper prop passing to OrganizationSelector.

The component correctly passes both parentSelectedLevels and errorMessage props to handle the organization selection and validation.

public/locale/en.json (1)

1305-1305: LGTM! Error messages are clear and well-structured.

The new error messages for organization fetching and pincode-based autofill failures are user-friendly and provide specific feedback without exposing technical details.

Also applies to: 1396-1397

@github-actions github-actions bot removed the merge conflict pull requests with merge conflict label Jan 6, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Entering pincode does not auto fill state
4 participants