Skip to content

Conversation

@KadariPavani
Copy link
Contributor

@KadariPavani KadariPavani commented Jan 11, 2026

…n consistency in Login in another branch #14744

Proposed Changes

Fixes #14744
This change replaces unsafe any usages in the auth components with explicit TypeScript types and makes related fixes to validation, event handling, and accessibility.

Replaced any form/state/error types with explicit interfaces: LoginForm, LoginFormErrors, ResetPasswordForm, ResetPasswordFormErrors, and ResetPasswordPayload.
Strongly typed event handlers and validation functions (e.g., React.ChangeEvent, React.FormEvent, React.MouseEvent) instead of e: any.
Removed unsafe type assertions like (fieldValue as Record<string, string>)[name] = value and implemented type-safe handleChange logic that only updates known form fields.
Separated API payload from UI state: ResetPasswordPayload requires token for the API while form state remains token-less.
Accessibility and cleanup: added id="otp" to the OTP input to match the Label's htmlFor and removed a stray console.log debug statement.
Tagging: @ohcnetwork/care-fe-code-reviewers

Merge Checklist

  • Add specs that demonstrate the bug or test the new feature.
  • Update product documentation.
  • Ensure that UI text is placed in I18n files.
  • Prepare a screenshot or demo video for the changelog entry and attach it to the issue.
  • Request peer reviews.
  • Complete QA on mobile devices.
  • Complete QA on desktop devices.
  • Add or update Playwright tests for related changes

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced login validation with clearer, field-specific error messages for username and password.
    • Improved error handling and messaging for one-time password operations.
  • New Features

    • Stronger, more consistent form state handling for the login flow.
    • Username input normalized to lowercase during entry.
    • Better handling of captcha values during login.

✏️ Tip: You can customize this high-level summary in your review settings.

@KadariPavani KadariPavani requested review from a team and Copilot January 11, 2026 05:30
@netlify
Copy link

netlify bot commented Jan 11, 2026

Deploy Preview for care-ohc ready!

Name Link
🔨 Latest commit 19c9f00
🔍 Latest deploy log https://app.netlify.com/projects/care-ohc/deploys/69633835b2815300088a6918
😎 Deploy Preview https://deploy-preview-15096.preview.ohc.network
📱 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 project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 11, 2026

Walkthrough

Login.tsx replaces loose any types with explicit TypeScript interfaces and annotations for form state, errors, and handlers; updates validation and OTP error typings; and adds cn import used for conditional styling. Inputs are normalized (username lowercased) and state hooks use generics.

Changes

Cohort / File(s) Change Summary
Type definitions
src/components/Auth/Login.tsx
Added LoginForm (username, password, optional g-recaptcha-response) and LoginFormErrors (username?, password?) interfaces.
State init & hooks
src/components/Auth/Login.tsx
Replaced initForm: anyconst initForm: LoginForm; initErr: anyconst initErr: LoginFormErrors; useState calls now use generics (useState<LoginForm>, useState<LoginFormErrors>).
Event handlers & signatures
src/components/Auth/Login.tsx
handleChange typed as React.ChangeEvent<HTMLInputElement> and lowercases username; onCaptchaChange typed `string
Validation & errors
src/components/Auth/Login.tsx
Per-field error assignment implemented (username/password); validation functions return explicit types; errors cleared on field change.
OTP mutation error types
src/components/Auth/Login.tsx
onError typings tightened: OTP send uses Error & { data?: OtpError[] }; OTP verify uses Error & { cause?: { errors?: OtpValidationError[] } }.
Misc / styling
src/components/Auth/Login.tsx
Imported and used cn for conditional class names based on error presence.
🚥 Pre-merge checks | ✅ 4 | ❌ 1
❌ Failed checks (1 inconclusive)
Check name Status Explanation Resolution
Title check ❓ Inconclusive Title mentions validation consistency and type improvements relevant to PR objectives, though it truncates mid-word, making it incomplete and unclear. Complete the truncated title (ends with 'improve validatio…') to clearly convey the full scope of changes and improve clarity.
✅ Passed checks (4 passed)
Check name Status Explanation
Description check ✅ Passed PR description comprehensively covers all changes including type replacements, validation improvements, accessibility fixes, and includes all merge checklist items marked as complete.
Linked Issues check ✅ Passed Code changes directly address issue #14744 by replacing unsafe any types with explicit interfaces (LoginForm, LoginFormErrors) and strongly typing event handlers (React.ChangeEvent) for Login.tsx validation consistency.
Out of Scope Changes check ✅ Passed All changes in raw_summary for Login.tsx are scoped to addressing issue #14744 requirements: replacing any types, adding explicit interfaces, and improving type safety without functional changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves type safety in the Login component by replacing any types with explicit TypeScript interfaces and refining validation logic. The changes eliminate unsafe type assertions and ensure stricter type checking throughout the authentication flow.

Changes:

  • Added LoginForm and LoginFormErrors interfaces to replace any types in form state management
  • Strongly typed event handlers (React.ChangeEvent, React.FormEvent) and error callbacks with proper error structure types
  • Refactored handleChange to use type-safe field updates with conditional logic for username/password fields
  • Improved validation functions with explicit return types (LoginForm | false) and clearer validation logic

Comment on lines 229 to 232
if (
!form.username ||
(typeof form.username === "string" && !form.username.match(/\w/))
) {
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

The type check typeof form.username === "string" is redundant. Since form.username is already typed as string in the LoginForm interface (line 79), this condition will always evaluate to true. You can simplify the validation to just check if the value is empty or doesn't match the regex pattern.

Suggested change
if (
!form.username ||
(typeof form.username === "string" && !form.username.match(/\w/))
) {
if (!form.username || !form.username.match(/\w/)) {

Copilot uses AI. Check for mistakes.
Comment on lines 272 to 273
!form.username ||
(typeof form.username === "string" && !form.username.match(/\w/))
Copy link

Copilot AI Jan 11, 2026

Choose a reason for hiding this comment

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

The type check typeof form.username === "string" is redundant. Since form.username is already typed as string in the LoginForm interface (line 79), this condition will always evaluate to true. You can simplify the validation to just check if the value is empty or doesn't match the regex pattern.

Copilot uses AI. Check for mistakes.
@github-actions
Copy link

github-actions bot commented Jan 11, 2026

🚀 Preview Deployment Ready!

Name Details
🔗 Preview URL https://e6b82605.care-preview-a7w.pages.dev
📝 Commit 19c9f00
🌐 Environment pr-15096

This preview will be automatically updated when you push new commits to this PR.

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/Auth/Login.tsx (1)

147-156: Fix incorrect error property access in sendOtp handler — error messages won't display.

The sendOtp error handler (lines 147-156) has an incorrect type annotation. The mutate utility delegates to callApi, which throws HTTPError with a .cause property containing the response data, not a .data property. Currently, error?.data will always be undefined, causing the handler to always display the generic "send_otp_error" message instead of the actual API error.

Update line 148 from:

const errors = error?.data || [];

to:

const errors = (error.cause as OtpError[]) || [];

And update the type annotation on line 147 from Error & { data?: OtpError[] } to Error & { cause?: OtpError[] }.

Additionally, the verifyOtp error handler (lines 179-198) has incomplete error handling. The mutation throws the raw response object directly when it contains "errors", but the error handler only checks error.cause?.errors. This won't catch the structure of manually thrown responses. The error handling should account for both the HTTPError path (with .cause) and the manually thrown response object path.

📜 Review details

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1a62942 and c1f4efd.

📒 Files selected for processing (1)
  • src/components/Auth/Login.tsx
🧰 Additional context used
📓 Path-based instructions (12)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx}: Write concise, technical TypeScript code with accurate examples
Use TypeScript for all code; prefer interfaces over types
Avoid enums; use maps instead
Use TanStack Query for data fetching from the API along with query and mutate utilities for the queryFn and mutationFn
Use raviger for routing

**/*.{ts,tsx}: Use TypeScript with strict mode and ES2022 target
Use interface for defining object types in TypeScript
Avoid explicit any type in TypeScript
Use proper nullability annotations in TypeScript types
Use dedicated error handlers and TypeScript strict null checks

**/*.{ts,tsx}: Use TypeScript for all new code
Prefer interfaces over types for object definitions in TypeScript
Avoid using any type; use proper type definitions in TypeScript
Use type inference where possible in TypeScript
Use TanStack Query for API data management
Prefer React Context for global state management

**/*.{ts,tsx}: Use TanStack Query with the query and mutate utilities from @/Utils/request/
Use appropriate query keys following the resource pattern for TanStack Query
Leverage TanStack Query built-in features for pagination and debouncing
Implement proper error handling using the global error handler for TanStack Query operations
Use useQuery hook with queryKey and queryFn parameters, where queryFn wraps the API route with the query() utility
Use useMutation hook with mutationFn parameter wrapping API routes with the mutate() utility, and implement onSuccess callbacks to invalidate related queries
Support path parameters in TanStack Query using the pathParams option in query/mutate utilities
Support query parameters in TanStack Query using the queryParams option in query/mutate utilities
Use the silent: true option to suppress global error notifications when custom error handling is needed

**/*.{ts,tsx}: Use TypeScript with strict mode and ES2022 target
Use interface for defining object types
Avoid explicit any types and maint...

Files:

  • src/components/Auth/Login.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx,js,jsx}: Use functional and declarative programming patterns; avoid classes
Prefer iteration and modularization over code duplication
Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError)
Use the "function" keyword for pure functions
Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements

**/*.{ts,tsx,js,jsx}: Use path aliases for imports from src (@/*)
Use double quotes for strings
Semicolons are required at end of statements
Order imports as: 3rd-party → library → CAREUI → UI → components → hooks → utils → relative
Use PascalCase for component and class names
Use camelCase for variable and function names

**/*.{ts,tsx,js,jsx}: Use path aliases @/* for imports from src directory
Use double quotes for strings
Require semicolons at end of statements
Order imports: 3rd-party → library → CAREUI → UI → components → hooks → utils → relative
Use PascalCase for component and class names
Use camelCase for variable and function names

Files:

  • src/components/Auth/Login.tsx
**/*.{tsx,jsx}

📄 CodeRabbit inference engine (.cursorrules)

Use declarative JSX

Files:

  • src/components/Auth/Login.tsx
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/**/*.{ts,tsx}: Use strict TypeScript configuration for medical data safety in all TypeScript source files
All literal strings must use i18next for multi-language support in healthcare interfaces
Use comprehensive error boundaries and user-friendly error messages for medical workflow debugging without exposing PHI
Follow ESLint configured rules for React hooks, accessibility, and code quality
Use @tanstack/react-query for server state management in API client code
Localize date and time formats for medical timestamps using locale-aware formatting functions
Use date-fns for date handling and manipulation with locale awareness for medical timestamps

Files:

  • src/components/Auth/Login.tsx
src/components/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/components/**/*.{ts,tsx}: Implement WCAG 2.1 AA accessibility compliance in medical applications with screen reader compatibility and keyboard navigation
Include medical use cases, accessibility notes, and WCAG compliance documentation in component documentation
Follow established React component patterns and folder structure organized by feature and domain

src/components/**/*.{ts,tsx}: Use path aliases: @/components/, @/types/, @/lib/, @/pages/ for imports
Follow import order: External packages → @/components/ui/@/components/@/CAREUI/@/types/@/lib/ → relative imports
Use named exports from lucide-react for icons (e.g., import { SettingsIcon } from "lucide-react")
Import useTranslation from react-i18next for internationalization
Use React 19.1.1 hooks pattern - Functional components only
Always define TypeScript Props interfaces (e.g., PatientInfoCardProps) for component props
Use handle prefix for event handlers (e.g., handleSubmit, handleTagsUpdate, handlePatientSelect)
Use shadcn/ui components as primary UI system (Button, Card, Badge, etc.) from @/components/ui/
Use healthcare-specific CAREUI custom components (Calendar, WeekdayCheckbox, Zoom) from @/CAREUI/
Use buttonVariants from @/components/ui/button with CVA patterns for button styling
Follow <Card><CardHeader> pattern for consistent card layouts
Use PatientRead type from @/types/emr/patient/patient for patient data handling
Implement TagAssignmentSheet with TagEntityType for patient/facility tags
Use PatientHoverCard for patient info overlays
Use Badge components to display patient status, facility capacity, medication dosage with color variants
Use cva() from class variance authority for variant-based component styling
Use cn() from @/lib/utils for conditional class composition
Follow Tailwind CSS 4.1.3 color system: primary-700, gray-900, red-500 pattern with dark mode variants
Use Tailwind shadow system: shadow-sm, shadow-xs for el...

Files:

  • src/components/Auth/Login.tsx
src/**/*.{ts,tsx,css}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use Prettier for consistent code formatting across the healthcare application

Files:

  • src/components/Auth/Login.tsx
src/**/*.{tsx,ts}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/**/*.{tsx,ts}: Use React 19.1.1 features and patterns following React 19 Documentation for healthcare application development
Use shadcn/ui as primary component system and CAREUI for healthcare-specific components
Use framer-motion for animations in healthcare UI interfaces

Files:

  • src/components/Auth/Login.tsx
src/**/*.{tsx,css}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use Tailwind CSS 4.1.3 utility classes with custom healthcare-specific design system for styling

Files:

  • src/components/Auth/Login.tsx
**/*

📄 CodeRabbit inference engine (CLAUDE.md)

Use 2-space indentation

Files:

  • src/components/Auth/Login.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/02-coding-standards.mdc)

**/*.tsx: Use functional components with proper type definitions in React
One component per file is preferred
Prefer default exports for React components
Follow the component naming pattern: ComponentName.tsx for React components
Use Tailwind CSS for styling
Use Shadcn UI components when available
Use local state for component-specific data
Use PascalCase for component file names (e.g., AuthWizard.tsx)

Files:

  • src/components/Auth/Login.tsx
**/*.{tsx,ts}

📄 CodeRabbit inference engine (.cursor/rules/04-ui-components.mdc)

**/*.{tsx,ts}: Use Shadcn UI components as the primary component library
Follow the component documentation for proper usage
Customize components using Tailwind CSS
Use navigate and useRedirect from raviger for navigation and redirects
Use Tailwind's responsive classes and follow mobile-first approach
Implement proper ARIA attributes for accessibility
Ensure keyboard navigation works in components
Define component props using TypeScript interfaces
Use translation keys from src/Locale/ for internationalization
Support RTL languages in components
Use proper date/time formatting for multiple language support

Files:

  • src/components/Auth/Login.tsx
**/*.{ts,tsx,js,jsx,json,css,scss,html}

📄 CodeRabbit inference engine (AGENTS.md)

Use 2-space indentation

Files:

  • src/components/Auth/Login.tsx
🧠 Learnings (37)
📓 Common learnings
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/common.instructions.md:0-0
Timestamp: 2025-11-25T13:50:54.683Z
Learning: Applies to src/common/**/validation.tsx : Implement healthcare system password and identifier validation in validation.tsx
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Implement proper authentication checks in page components
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/react-components.instructions.md:0-0
Timestamp: 2025-11-25T13:52:51.914Z
Learning: Applies to src/components/**/*.{ts,tsx} : Handle controlled inputs with proper TypeScript typing for form state
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .cursor/rules/04-ui-components.mdc:0-0
Timestamp: 2025-11-25T13:54:35.875Z
Learning: Applies to **/*.{tsx,ts} : Define component props using TypeScript interfaces
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T13:49:43.065Z
Learning: Applies to components/**/*.{ts,tsx} : Use functional components with TypeScript interfaces
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Use controlled components for form inputs in page components
Learnt from: sainak
Repo: ohcnetwork/care_fe PR: 8979
File: src/components/Auth/Login.tsx:28-28
Timestamp: 2024-11-05T18:59:04.554Z
Learning: In `src/components/Auth/Login.tsx`, the `__CUSTOM_DESCRIPTION_HTML__` constant is set during the build process and is already sanitized.
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Implement proper form validation with `zod` schemas in page components
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .cursor/rules/02-coding-standards.mdc:0-0
Timestamp: 2025-11-25T13:54:09.978Z
Learning: Applies to **/*.tsx : Use functional components with proper type definitions in React
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Handle form submission states (loading, success, error) in page components
📚 Learning: 2025-11-25T13:50:54.683Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/common.instructions.md:0-0
Timestamp: 2025-11-25T13:50:54.683Z
Learning: Applies to src/common/**/validation.tsx : Implement healthcare system password and identifier validation in validation.tsx

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:19.758Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Implement proper authentication checks in page components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:50:46.407Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/careui.instructions.md:0-0
Timestamp: 2025-11-25T13:50:46.407Z
Learning: Applies to src/CAREUI/**/*.{ts,tsx} : Ensure full compatibility with react-hook-form for medical data collection in CAREUI components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:19.758Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Implement proper form validation with `zod` schemas in page components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:50:10.786Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-25T13:50:10.786Z
Learning: Applies to src/**/*{[Ff]orm,[Ii]nput,[Ff]ield}*.{ts,tsx} : Use react-hook-form with zod validation for medical data integrity in form components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:19.758Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Use controlled components for form inputs in page components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2024-11-05T18:59:04.554Z
Learnt from: sainak
Repo: ohcnetwork/care_fe PR: 8979
File: src/components/Auth/Login.tsx:28-28
Timestamp: 2024-11-05T18:59:04.554Z
Learning: In `src/components/Auth/Login.tsx`, the `__CUSTOM_DESCRIPTION_HTML__` constant is set during the build process and is already sanitized.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2024-11-20T19:08:38.025Z
Learnt from: Jacobjeevan
Repo: ohcnetwork/care_fe PR: 9080
File: src/components/Users/UserEditDetails.tsx:90-97
Timestamp: 2024-11-20T19:08:38.025Z
Learning: In the React component `UserEditDetails` (src/components/Users/UserEditDetails.tsx), error handling for form submissions is handled within the `UserAddEditForm` component, so additional error handling is unnecessary.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:51.914Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/react-components.instructions.md:0-0
Timestamp: 2025-11-25T13:52:51.914Z
Learning: Applies to src/components/**/*.{ts,tsx} : Handle controlled inputs with proper TypeScript typing for form state

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:19.758Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Handle form submission states (loading, success, error) in page components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:50:46.407Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/careui.instructions.md:0-0
Timestamp: 2025-11-25T13:50:46.407Z
Learning: Applies to src/CAREUI/**/*.{ts,tsx} : Integrate CAREUI components with React Query for real-time data from medical API endpoints

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:49:43.065Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T13:49:43.065Z
Learning: Applies to **/*.{ts,tsx} : Use TanStack Query for data fetching from the API along with query and mutate utilities for the queryFn and mutationFn

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:54:24.075Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .cursor/rules/03-data-fetching.mdc:0-0
Timestamp: 2025-11-25T13:54:24.075Z
Learning: Applies to **/*.{ts,tsx} : Use `useMutation` hook with `mutationFn` parameter wrapping API routes with the `mutate()` utility, and implement `onSuccess` callbacks to invalidate related queries

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:54:24.075Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .cursor/rules/03-data-fetching.mdc:0-0
Timestamp: 2025-11-25T13:54:24.075Z
Learning: Applies to **/*.{ts,tsx} : Use TanStack Query with the `query` and `mutate` utilities from `@/Utils/request/`

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:51.914Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/react-components.instructions.md:0-0
Timestamp: 2025-11-25T13:52:51.914Z
Learning: Applies to src/components/**/*.{ts,tsx} : Use `tanstack/react-query` for server state management with facility data and patient records

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:50:10.786Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-25T13:50:10.786Z
Learning: Custom React hooks for healthcare workflows must follow hooks.instructions.md

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:51.914Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/react-components.instructions.md:0-0
Timestamp: 2025-11-25T13:52:51.914Z
Learning: Applies to src/components/**/*.{ts,tsx} : Use healthcare-specific CAREUI custom components (Calendar, WeekdayCheckbox, Zoom) from `@/CAREUI/`

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:50:46.407Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/careui.instructions.md:0-0
Timestamp: 2025-11-25T13:50:46.407Z
Learning: Applies to src/CAREUI/**/*.{ts,tsx} : Implement appropriate validation for clinical data inputs in CAREUI components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:50:46.407Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/careui.instructions.md:0-0
Timestamp: 2025-11-25T13:50:46.407Z
Learning: Applies to src/CAREUI/**/*.{ts,tsx} : Use standard medical component interface patterns with medicalContext, accessibility properties (ariaLabel, screenReaderText), clinical validation callbacks (onValidationError), and medical data properties (patientId, facilityId)

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:50:46.407Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/careui.instructions.md:0-0
Timestamp: 2025-11-25T13:50:46.407Z
Learning: Applies to src/CAREUI/**/*.{ts,tsx} : Implement robust error handling with user-friendly medical context in CAREUI components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2024-11-05T16:18:57.875Z
Learnt from: AnveshNalimela
Repo: ohcnetwork/care_fe PR: 8930
File: cypress/pageobject/Users/UserCreation.ts:31-42
Timestamp: 2024-11-05T16:18:57.875Z
Learning: In `UserCreationPage` of `UserCreation.ts`, methods like `typePhoneNumber` and `typeUserPhoneNumber` target different input fields and are both necessary.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2024-11-07T02:35:08.706Z
Learnt from: khavinshankar
Repo: ohcnetwork/care_fe PR: 9036
File: src/components/Patient/PatientRegister.tsx:947-954
Timestamp: 2024-11-07T02:35:08.706Z
Learning: In `src/components/Patient/PatientRegister.tsx`, passing `state` and `dispatch` to `PLUGIN_Component` is necessary for plugin functionality and is acceptable in our codebase.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-04-11T20:28:51.054Z
Learnt from: AdityaJ2305
Repo: ohcnetwork/care_fe PR: 11884
File: src/pages/Landing/LandingPage.tsx:128-158
Timestamp: 2025-04-11T20:28:51.054Z
Learning: The LoginHeader component uses the AuthContext for authentication and includes the SignCompact component, making it incompatible with the token-based authentication flow used in the LandingPage. The custom header implementation in LandingPage is specifically designed for patient authentication with different navigation targets (/patient/home vs /dashboard) and different user information display.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:33.081Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/providers.instructions.md:0-0
Timestamp: 2025-11-25T13:52:33.081Z
Learning: Applies to src/Providers/**/*PatientUserProvider*{.ts,.tsx} : PatientUserProvider should handle patient authentication for public appointment booking

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-04-11T20:28:51.054Z
Learnt from: AdityaJ2305
Repo: ohcnetwork/care_fe PR: 11884
File: src/pages/Landing/LandingPage.tsx:128-158
Timestamp: 2025-04-11T20:28:51.054Z
Learning: The LoginHeader component includes both logged-in UI (with home button and dropdown) and logged-out UI (with sign-in button). When integrating authentication headers in pages that already have login sections (like LandingPage), custom header implementations may be needed to avoid duplicate login UI elements.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:19.758Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Redirect to login when authentication is required in page components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:33.081Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/providers.instructions.md:0-0
Timestamp: 2025-11-25T13:52:33.081Z
Learning: Applies to src/Providers/**/*AuthUserProvider*{.ts,.tsx} : AuthUserProvider should manage authenticated user and role-based permissions with proper state management using useState and context

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2024-12-02T18:50:29.685Z
Learnt from: kihan2518B
Repo: ohcnetwork/care_fe PR: 8956
File: src/components/Patient/PatientRegister.tsx:861-861
Timestamp: 2024-12-02T18:50:29.685Z
Learning: In `src/components/Patient/PatientRegister.tsx`, `insuranceDetails` is not part of `state.form`, so changes to it are not tracked by the `isDirty` state. Therefore, the form's `disabled` state needs to be conditionally set based on `insuranceDetails.length`.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:19.758Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Handle patient data with appropriate privacy considerations in healthcare page components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:50:10.786Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-25T13:50:10.786Z
Learning: Applies to src/**/*.{ts,tsx} : Use comprehensive error boundaries and user-friendly error messages for medical workflow debugging without exposing PHI

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:19.758Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Handle API errors gracefully in page components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-01-14T09:56:07.985Z
Learnt from: rajku-dev
Repo: ohcnetwork/care_fe PR: 9887
File: src/components/Users/CreateUserForm.tsx:153-159
Timestamp: 2025-01-14T09:56:07.985Z
Learning: In react-hook-form, form.formState.isValid being false with an empty form.formState.errors object typically indicates that either not all required fields are filled, some fields haven't been "touched", or there's pending async validation. The errors object only contains validation errors for fields that have been validated.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-04-13T03:41:38.805Z
Learnt from: rithviknishad
Repo: ohcnetwork/care_fe PR: 11815
File: src/components/Questionnaire/QuestionTypes/EncounterQuestion.tsx:332-341
Timestamp: 2025-04-13T03:41:38.805Z
Learning: Form inputs in React components should use the controlled component pattern (using `value` instead of `defaultValue`) to ensure they properly reflect changes from all sources, particularly for textareas and form elements that may be updated from multiple places.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:51:41.208Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/lib.instructions.md:0-0
Timestamp: 2025-11-25T13:51:41.208Z
Learning: Applies to src/lib/**/validators.ts : Implement form validation for healthcare-specific requirements in validators.ts

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-12-17T19:47:58.152Z
Learnt from: AdityaJ2305
Repo: ohcnetwork/care_fe PR: 14821
File: src/components/Location/LocationNavigation.tsx:161-163
Timestamp: 2025-12-17T19:47:58.152Z
Learning: To ensure the remove-unused-i18n.js cleanup script detects i18n keys, avoid wrapping keys inside a ternary expression passed directly to t(). Instead, call t() separately in each branch of a conditional, e.g. condition ? t("key1") : t("key2"), or compute the key in a variable before passing to t(). For LocationNavigation.tsx (and similar TSX files in the repo), prefer explicit separate i18n calls per branch or a shared precomputed key to guarantee all keys are statically detectable by the script.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-12-22T10:16:36.690Z
Learnt from: Jacobjeevan
Repo: ohcnetwork/care_fe PR: 14804
File: src/pages/Facility/services/pharmacy/DispensesView.tsx:117-135
Timestamp: 2025-12-22T10:16:36.690Z
Learning: In the care_fe repository, prefer the native HTML title attribute for simple tooltips over using shadcn/ui Tooltip components. Use Tooltip components only when the tooltip requires richer content, interactivity, or accessibility enhancements that cannot be achieved with a plain title. For simple cases, add a title attribute to the element (e.g., <span title="...">). If a Tooltip is used, ensure it is accessible and necessary, and avoid duplicating content available in the title attribute.

Applied to files:

  • src/components/Auth/Login.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (9)
  • GitHub Check: CodeQL analysis (javascript-typescript)
  • GitHub Check: Agent
  • GitHub Check: build
  • GitHub Check: Redirect rules - care-ohc
  • GitHub Check: Header rules - care-ohc
  • GitHub Check: Test
  • GitHub Check: CodeQL-Build
  • GitHub Check: Pages changed - care-ohc
  • GitHub Check: deploy-preview
🔇 Additional comments (6)
src/components/Auth/Login.tsx (6)

78-87: Excellent type safety improvements!

The new LoginForm and LoginFormErrors interfaces clearly define the form structure and validation state. Using nullable strings for error fields (string | null) properly models the presence or absence of validation errors.


100-109: LGTM! Properly typed form state.

Form initialization and state hooks are now strongly typed, replacing the previous any annotations. This ensures type safety throughout the component and enables better IDE support.


209-222: Well-designed type-safe change handler.

The implementation correctly:

  • Uses proper React event typing
  • Employs type narrowing to restrict updates to username and password fields only
  • Normalizes username to lowercase for case-insensitive login
  • Clears field-specific errors on change

The intentional field restriction is good design—it prevents accidental updates to non-existent fields and maintains type safety. The g-recaptcha-response field is appropriately handled separately via onCaptchaChange.


224-248: Validation function properly typed.

The validateData function now has an explicit return type (LoginForm | false) and clear field-by-field validation logic. The validation rules are preserved from the original implementation while adding type safety.


267-284: LGTM! Consistent validation pattern.

The validateForgetData function follows the same type-safe pattern as validateData, correctly validating only the username field (appropriate for the forgot password flow).


293-299: Captcha handler correctly typed.

The onCaptchaChange function now uses string | null (correct for ReCaptcha's onChange callback) instead of any. The implementation properly updates the form state using bracket notation for the hyphenated field name.

@github-actions
Copy link

github-actions bot commented Jan 11, 2026

🎭 Playwright Test Results

Status: ✅ Passed
Test Shards: 3

Metric Count
Total Tests 251
✅ Passed 251
❌ Failed 0
⏭️ Skipped 0

📊 Detailed results are available in the playwright-final-report artifact.

Run: #4526

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

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/components/Auth/Login.tsx (1)

224-245: Consider strengthening username validation.

The current validation uses the regex /\w/, which only checks for at least one word character (letter, digit, or underscore). This is quite lenient and doesn't enforce:

  • Minimum/maximum length constraints
  • Specific allowed character sets
  • Leading/trailing whitespace prevention

For a healthcare application handling user authentication, more robust validation would improve security and data quality.

Based on learnings, consider implementing healthcare-specific identifier validation in a shared validation utility.

💡 Example: More robust username validation
const validateData = (): LoginForm | false => {
  let hasError = false;
  const err: LoginFormErrors = { ...errors };

  // Validate username
  const trimmedUsername = form.username.trim();
  if (!trimmedUsername) {
    hasError = true;
    err.username = "field_required";
  } else if (trimmedUsername.length < 3) {
    hasError = true;
    err.username = "username_too_short";
  } else if (!/^[a-zA-Z0-9._-]+$/.test(trimmedUsername)) {
    hasError = true;
    err.username = "username_invalid_characters";
  }

  // Validate password
  if (!form.password) {
    hasError = true;
    err.password = "field_required";
  }

  if (hasError) {
    setErrors(err);
    return false;
  }
  return form;
};

Also applies to: 264-278

🤖 Fix all issues with AI agents
In @src/components/Auth/Login.tsx:
- Around line 209-222: The handleChange function's runtime check (if name ===
"username" || name === "password") doesn't narrow the type of name for
TypeScript, so indexed accesses like errorField[name] and fieldValue[name] are
not type-safe; update handleChange to perform explicit type narrowing (e.g., a
type guard function isAuthField(name): name is "username" | "password", or
separate branches like if (name === "username") { const key: "username" =
"username"; ... } else if (name === "password") { const key: "password" =
"password"; ... }) and use that narrowed key for errorField[key],
fieldValue[key], setErrors and setForm to ensure strict typings while preserving
the current logic.
📜 Review details

Configuration used: Repository UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c1f4efd and 19c9f00.

📒 Files selected for processing (1)
  • src/components/Auth/Login.tsx
🧰 Additional context used
📓 Path-based instructions (12)
**/*.{ts,tsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx}: Write concise, technical TypeScript code with accurate examples
Use TypeScript for all code; prefer interfaces over types
Avoid enums; use maps instead
Use TanStack Query for data fetching from the API along with query and mutate utilities for the queryFn and mutationFn
Use raviger for routing

**/*.{ts,tsx}: Use TypeScript with strict mode and ES2022 target
Use interface for defining object types in TypeScript
Avoid explicit any type in TypeScript
Use proper nullability annotations in TypeScript types
Use dedicated error handlers and TypeScript strict null checks

**/*.{ts,tsx}: Use TypeScript for all new code
Prefer interfaces over types for object definitions in TypeScript
Avoid using any type; use proper type definitions in TypeScript
Use type inference where possible in TypeScript
Use TanStack Query for API data management
Prefer React Context for global state management

**/*.{ts,tsx}: Use TanStack Query with the query and mutate utilities from @/Utils/request/
Use appropriate query keys following the resource pattern for TanStack Query
Leverage TanStack Query built-in features for pagination and debouncing
Implement proper error handling using the global error handler for TanStack Query operations
Use useQuery hook with queryKey and queryFn parameters, where queryFn wraps the API route with the query() utility
Use useMutation hook with mutationFn parameter wrapping API routes with the mutate() utility, and implement onSuccess callbacks to invalidate related queries
Support path parameters in TanStack Query using the pathParams option in query/mutate utilities
Support query parameters in TanStack Query using the queryParams option in query/mutate utilities
Use the silent: true option to suppress global error notifications when custom error handling is needed

**/*.{ts,tsx}: Use TypeScript with strict mode and ES2022 target
Use interface for defining object types
Avoid explicit any types and maint...

Files:

  • src/components/Auth/Login.tsx
**/*.{ts,tsx,js,jsx}

📄 CodeRabbit inference engine (.cursorrules)

**/*.{ts,tsx,js,jsx}: Use functional and declarative programming patterns; avoid classes
Prefer iteration and modularization over code duplication
Use descriptive variable names with auxiliary verbs (e.g., isLoading, hasError)
Use the "function" keyword for pure functions
Avoid unnecessary curly braces in conditionals; use concise syntax for simple statements

**/*.{ts,tsx,js,jsx}: Use path aliases for imports from src (@/*)
Use double quotes for strings
Semicolons are required at end of statements
Order imports as: 3rd-party → library → CAREUI → UI → components → hooks → utils → relative
Use PascalCase for component and class names
Use camelCase for variable and function names

**/*.{ts,tsx,js,jsx}: Use path aliases @/* for imports from src directory
Use double quotes for strings
Require semicolons at end of statements
Order imports: 3rd-party → library → CAREUI → UI → components → hooks → utils → relative
Use PascalCase for component and class names
Use camelCase for variable and function names

Files:

  • src/components/Auth/Login.tsx
**/*.{tsx,jsx}

📄 CodeRabbit inference engine (.cursorrules)

Use declarative JSX

Files:

  • src/components/Auth/Login.tsx
src/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/**/*.{ts,tsx}: Use strict TypeScript configuration for medical data safety in all TypeScript source files
All literal strings must use i18next for multi-language support in healthcare interfaces
Use comprehensive error boundaries and user-friendly error messages for medical workflow debugging without exposing PHI
Follow ESLint configured rules for React hooks, accessibility, and code quality
Use @tanstack/react-query for server state management in API client code
Localize date and time formats for medical timestamps using locale-aware formatting functions
Use date-fns for date handling and manipulation with locale awareness for medical timestamps

Files:

  • src/components/Auth/Login.tsx
src/components/**/*.{ts,tsx}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/components/**/*.{ts,tsx}: Implement WCAG 2.1 AA accessibility compliance in medical applications with screen reader compatibility and keyboard navigation
Include medical use cases, accessibility notes, and WCAG compliance documentation in component documentation
Follow established React component patterns and folder structure organized by feature and domain

src/components/**/*.{ts,tsx}: Use path aliases: @/components/, @/types/, @/lib/, @/pages/ for imports
Follow import order: External packages → @/components/ui/@/components/@/CAREUI/@/types/@/lib/ → relative imports
Use named exports from lucide-react for icons (e.g., import { SettingsIcon } from "lucide-react")
Import useTranslation from react-i18next for internationalization
Use React 19.1.1 hooks pattern - Functional components only
Always define TypeScript Props interfaces (e.g., PatientInfoCardProps) for component props
Use handle prefix for event handlers (e.g., handleSubmit, handleTagsUpdate, handlePatientSelect)
Use shadcn/ui components as primary UI system (Button, Card, Badge, etc.) from @/components/ui/
Use healthcare-specific CAREUI custom components (Calendar, WeekdayCheckbox, Zoom) from @/CAREUI/
Use buttonVariants from @/components/ui/button with CVA patterns for button styling
Follow <Card><CardHeader> pattern for consistent card layouts
Use PatientRead type from @/types/emr/patient/patient for patient data handling
Implement TagAssignmentSheet with TagEntityType for patient/facility tags
Use PatientHoverCard for patient info overlays
Use Badge components to display patient status, facility capacity, medication dosage with color variants
Use cva() from class variance authority for variant-based component styling
Use cn() from @/lib/utils for conditional class composition
Follow Tailwind CSS 4.1.3 color system: primary-700, gray-900, red-500 pattern with dark mode variants
Use Tailwind shadow system: shadow-sm, shadow-xs for el...

Files:

  • src/components/Auth/Login.tsx
src/**/*.{ts,tsx,css}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use Prettier for consistent code formatting across the healthcare application

Files:

  • src/components/Auth/Login.tsx
src/**/*.{tsx,ts}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

src/**/*.{tsx,ts}: Use React 19.1.1 features and patterns following React 19 Documentation for healthcare application development
Use shadcn/ui as primary component system and CAREUI for healthcare-specific components
Use framer-motion for animations in healthcare UI interfaces

Files:

  • src/components/Auth/Login.tsx
src/**/*.{tsx,css}

📄 CodeRabbit inference engine (.github/copilot-instructions.md)

Use Tailwind CSS 4.1.3 utility classes with custom healthcare-specific design system for styling

Files:

  • src/components/Auth/Login.tsx
**/*

📄 CodeRabbit inference engine (CLAUDE.md)

Use 2-space indentation

Files:

  • src/components/Auth/Login.tsx
**/*.tsx

📄 CodeRabbit inference engine (.cursor/rules/02-coding-standards.mdc)

**/*.tsx: Use functional components with proper type definitions in React
One component per file is preferred
Prefer default exports for React components
Follow the component naming pattern: ComponentName.tsx for React components
Use Tailwind CSS for styling
Use Shadcn UI components when available
Use local state for component-specific data
Use PascalCase for component file names (e.g., AuthWizard.tsx)

Files:

  • src/components/Auth/Login.tsx
**/*.{tsx,ts}

📄 CodeRabbit inference engine (.cursor/rules/04-ui-components.mdc)

**/*.{tsx,ts}: Use Shadcn UI components as the primary component library
Follow the component documentation for proper usage
Customize components using Tailwind CSS
Use navigate and useRedirect from raviger for navigation and redirects
Use Tailwind's responsive classes and follow mobile-first approach
Implement proper ARIA attributes for accessibility
Ensure keyboard navigation works in components
Define component props using TypeScript interfaces
Use translation keys from src/Locale/ for internationalization
Support RTL languages in components
Use proper date/time formatting for multiple language support

Files:

  • src/components/Auth/Login.tsx
**/*.{ts,tsx,js,jsx,json,css,scss,html}

📄 CodeRabbit inference engine (AGENTS.md)

Use 2-space indentation

Files:

  • src/components/Auth/Login.tsx
🧠 Learnings (47)
📓 Common learnings
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/common.instructions.md:0-0
Timestamp: 2025-11-25T13:50:54.683Z
Learning: Applies to src/common/**/validation.tsx : Implement healthcare system password and identifier validation in validation.tsx
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Implement proper authentication checks in page components
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/careui.instructions.md:0-0
Timestamp: 2025-11-25T13:50:46.407Z
Learning: Applies to src/CAREUI/**/*.{ts,tsx} : Implement appropriate validation for clinical data inputs in CAREUI components
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/react-components.instructions.md:0-0
Timestamp: 2025-11-25T13:52:51.914Z
Learning: Applies to src/components/**/*.{ts,tsx} : Handle controlled inputs with proper TypeScript typing for form state
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Use controlled components for form inputs in page components
Learnt from: Jacobjeevan
Repo: ohcnetwork/care_fe PR: 9080
File: cypress/pageobject/Users/ManageUserPage.ts:67-97
Timestamp: 2024-11-14T08:09:58.453Z
Learning: In Cypress test files (`cypress/pageobject/Users/ManageUserPage.ts`), when methods are called to check input provided earlier in the test, adding TypeScript interfaces, input validation, and custom error messages is unnecessary.
Learnt from: AnveshNalimela
Repo: ohcnetwork/care_fe PR: 8930
File: cypress/pageobject/Users/UserCreation.ts:31-42
Timestamp: 2024-11-05T16:18:57.875Z
Learning: In `UserCreationPage` of `UserCreation.ts`, methods like `typePhoneNumber` and `typeUserPhoneNumber` target different input fields and are both necessary.
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Implement proper form validation with `zod` schemas in page components
Learnt from: Denyme24
Repo: ohcnetwork/care_fe PR: 13799
File: src/pages/Scheduling/components/CreateScheduleTemplateSheet.tsx:115-122
Timestamp: 2025-09-22T19:02:08.124Z
Learning: In the care_fe project's form components (like CreateScheduleTemplateSheet.tsx), maintainers use the union/refine pattern (z.union([z.number().min(1), z.undefined()]).refine()) for numeric fields instead of z.number({ required_error, invalid_type_error }) because their forms initialize with undefined values and use onChange handlers that convert invalid inputs back to undefined. This pattern maintains consistency with existing form architecture and avoids requiring refactoring of initialization and input handling logic.
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/context.instructions.md:0-0
Timestamp: 2025-11-25T13:51:23.408Z
Learning: Applies to src/context/**/*.{ts,tsx} : Use TypeScript interfaces for all healthcare context types
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Handle form submission states (loading, success, error) in page components
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/careui.instructions.md:0-0
Timestamp: 2025-11-25T13:50:46.407Z
Learning: Applies to src/CAREUI/**/*.{ts,tsx} : Ensure full compatibility with react-hook-form for medical data collection in CAREUI components
📚 Learning: 2025-11-25T13:50:54.683Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/common.instructions.md:0-0
Timestamp: 2025-11-25T13:50:54.683Z
Learning: Applies to src/common/**/validation.tsx : Implement healthcare system password and identifier validation in validation.tsx

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:19.758Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Implement proper authentication checks in page components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:50:46.407Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/careui.instructions.md:0-0
Timestamp: 2025-11-25T13:50:46.407Z
Learning: Applies to src/CAREUI/**/*.{ts,tsx} : Ensure full compatibility with react-hook-form for medical data collection in CAREUI components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:51.914Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/react-components.instructions.md:0-0
Timestamp: 2025-11-25T13:52:51.914Z
Learning: Applies to src/components/**/*.{ts,tsx} : Handle controlled inputs with proper TypeScript typing for form state

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:19.758Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Implement proper form validation with `zod` schemas in page components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:19.758Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Use controlled components for form inputs in page components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:54:09.978Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .cursor/rules/02-coding-standards.mdc:0-0
Timestamp: 2025-11-25T13:54:09.978Z
Learning: Applies to **/*.tsx : Use functional components with proper type definitions in React

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2024-11-05T18:59:04.554Z
Learnt from: sainak
Repo: ohcnetwork/care_fe PR: 8979
File: src/components/Auth/Login.tsx:28-28
Timestamp: 2024-11-05T18:59:04.554Z
Learning: In `src/components/Auth/Login.tsx`, the `__CUSTOM_DESCRIPTION_HTML__` constant is set during the build process and is already sanitized.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:50:10.786Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-25T13:50:10.786Z
Learning: Applies to src/**/*{[Ff]orm,[Ii]nput,[Ff]ield}*.{ts,tsx} : Use react-hook-form with zod validation for medical data integrity in form components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:33.081Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/providers.instructions.md:0-0
Timestamp: 2025-11-25T13:52:33.081Z
Learning: Applies to src/Providers/**/*AuthUserProvider*{.ts,.tsx} : AuthUserProvider should manage authenticated user and role-based permissions with proper state management using useState and context

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2024-11-05T19:01:42.250Z
Learnt from: SwanandBhuskute
Repo: ohcnetwork/care_fe PR: 8940
File: src/components/Users/UserProfile.tsx:196-218
Timestamp: 2024-11-05T19:01:42.250Z
Learning: In the `UserProfile` component (`src/components/Users/UserProfile.tsx`), the password validation rules do not include a requirement for special characters.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2024-11-14T08:07:32.427Z
Learnt from: Jacobjeevan
Repo: ohcnetwork/care_fe PR: 9080
File: src/Utils/permissions.ts:37-50
Timestamp: 2024-11-14T08:07:32.427Z
Learning: In the `showUserPasswordReset` function within `src/Utils/permissions.ts`, both `authUser` and `targetUser` are guaranteed to be provided. Therefore, null or undefined checks for these parameters are unnecessary.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2024-11-14T08:09:58.453Z
Learnt from: Jacobjeevan
Repo: ohcnetwork/care_fe PR: 9080
File: cypress/pageobject/Users/ManageUserPage.ts:67-97
Timestamp: 2024-11-14T08:09:58.453Z
Learning: In Cypress test files (`cypress/pageobject/Users/ManageUserPage.ts`), when methods are called to check input provided earlier in the test, adding TypeScript interfaces, input validation, and custom error messages is unnecessary.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2024-11-05T16:18:57.875Z
Learnt from: AnveshNalimela
Repo: ohcnetwork/care_fe PR: 8930
File: cypress/pageobject/Users/UserCreation.ts:31-42
Timestamp: 2024-11-05T16:18:57.875Z
Learning: In `UserCreationPage` of `UserCreation.ts`, methods like `typePhoneNumber` and `typeUserPhoneNumber` target different input fields and are both necessary.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2024-12-05T22:18:04.236Z
Learnt from: UdaySagar-Git
Repo: ohcnetwork/care_fe PR: 9298
File: src/components/Common/FilePreviewCard.tsx:39-47
Timestamp: 2024-12-05T22:18:04.236Z
Learning: In `src/components/Common/FilePreviewCard.tsx`, the `getFileType` function does not need to explicitly check for empty or uppercase file extensions because they are already validated and normalized during the file upload process.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-01-14T09:22:13.878Z
Learnt from: rajku-dev
Repo: ohcnetwork/care_fe PR: 9887
File: src/components/Users/CreateUserForm.tsx:93-93
Timestamp: 2025-01-14T09:22:13.878Z
Learning: The suggestion to use GENDER_TYPES.map(g => g.id) for gender enum validation in CreateUserForm.tsx was incorrect and caused an error.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2024-11-20T19:08:38.025Z
Learnt from: Jacobjeevan
Repo: ohcnetwork/care_fe PR: 9080
File: src/components/Users/UserEditDetails.tsx:90-97
Timestamp: 2024-11-20T19:08:38.025Z
Learning: In the React component `UserEditDetails` (src/components/Users/UserEditDetails.tsx), error handling for form submissions is handled within the `UserAddEditForm` component, so additional error handling is unnecessary.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2024-11-20T18:54:27.563Z
Learnt from: Jacobjeevan
Repo: ohcnetwork/care_fe PR: 9080
File: src/components/Users/UserFormValidations.tsx:137-148
Timestamp: 2024-11-20T18:54:27.563Z
Learning: In the function `ValidateDoctorMedicalCouncilRegistration` in `src/components/Users/UserFormValidations.tsx`, avoid enforcing a specific format for medical council registration numbers, as they vary globally.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-01-14T09:22:13.878Z
Learnt from: rajku-dev
Repo: ohcnetwork/care_fe PR: 9887
File: src/components/Users/CreateUserForm.tsx:93-93
Timestamp: 2025-01-14T09:22:13.878Z
Learning: In CreateUserForm.tsx, the gender validation schema uses string literals that match GENDER_TYPES.map(g => g.id). Using GENDER_TYPES directly with z.enum() fails because it's marked with 'as const' which makes it a readonly tuple type incompatible with Zod's enum.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-03-26T03:26:25.654Z
Learnt from: rithviknishad
Repo: ohcnetwork/care_fe PR: 11557
File: src/pages/Organization/OrganizationPatients.tsx:155-156
Timestamp: 2025-03-26T03:26:25.654Z
Learning: In the Patient interface (src/types/emr/newPatient.ts), phone_number is a required field according to the TypeScript type definition and doesn't need null checks before formatting.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:50:46.407Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/careui.instructions.md:0-0
Timestamp: 2025-11-25T13:50:46.407Z
Learning: Applies to src/CAREUI/**/*.{ts,tsx} : Integrate CAREUI components with React Query for real-time data from medical API endpoints

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:49:43.065Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .cursorrules:0-0
Timestamp: 2025-11-25T13:49:43.065Z
Learning: Applies to **/*.{ts,tsx} : Use TanStack Query for data fetching from the API along with query and mutate utilities for the queryFn and mutationFn

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:54:24.075Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .cursor/rules/03-data-fetching.mdc:0-0
Timestamp: 2025-11-25T13:54:24.075Z
Learning: Applies to **/*.{ts,tsx} : Use `useMutation` hook with `mutationFn` parameter wrapping API routes with the `mutate()` utility, and implement `onSuccess` callbacks to invalidate related queries

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:54:24.075Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .cursor/rules/03-data-fetching.mdc:0-0
Timestamp: 2025-11-25T13:54:24.075Z
Learning: Applies to **/*.{ts,tsx} : Use TanStack Query with the `query` and `mutate` utilities from `@/Utils/request/`

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:51.914Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/react-components.instructions.md:0-0
Timestamp: 2025-11-25T13:52:51.914Z
Learning: Applies to src/components/**/*.{ts,tsx} : Use `tanstack/react-query` for server state management with facility data and patient records

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:50:10.786Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-25T13:50:10.786Z
Learning: Custom React hooks for healthcare workflows must follow hooks.instructions.md

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:51.914Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/react-components.instructions.md:0-0
Timestamp: 2025-11-25T13:52:51.914Z
Learning: Applies to src/components/**/*.{ts,tsx} : Use healthcare-specific CAREUI custom components (Calendar, WeekdayCheckbox, Zoom) from `@/CAREUI/`

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:50:46.407Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/careui.instructions.md:0-0
Timestamp: 2025-11-25T13:50:46.407Z
Learning: Applies to src/CAREUI/**/*.{ts,tsx} : Implement appropriate validation for clinical data inputs in CAREUI components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:50:46.407Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/careui.instructions.md:0-0
Timestamp: 2025-11-25T13:50:46.407Z
Learning: Applies to src/CAREUI/**/*.{ts,tsx} : Use standard medical component interface patterns with medicalContext, accessibility properties (ariaLabel, screenReaderText), clinical validation callbacks (onValidationError), and medical data properties (patientId, facilityId)

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:50:46.407Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/careui.instructions.md:0-0
Timestamp: 2025-11-25T13:50:46.407Z
Learning: Applies to src/CAREUI/**/*.{ts,tsx} : Implement robust error handling with user-friendly medical context in CAREUI components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2024-11-07T02:35:08.706Z
Learnt from: khavinshankar
Repo: ohcnetwork/care_fe PR: 9036
File: src/components/Patient/PatientRegister.tsx:947-954
Timestamp: 2024-11-07T02:35:08.706Z
Learning: In `src/components/Patient/PatientRegister.tsx`, passing `state` and `dispatch` to `PLUGIN_Component` is necessary for plugin functionality and is acceptable in our codebase.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-04-11T20:28:51.054Z
Learnt from: AdityaJ2305
Repo: ohcnetwork/care_fe PR: 11884
File: src/pages/Landing/LandingPage.tsx:128-158
Timestamp: 2025-04-11T20:28:51.054Z
Learning: The LoginHeader component uses the AuthContext for authentication and includes the SignCompact component, making it incompatible with the token-based authentication flow used in the LandingPage. The custom header implementation in LandingPage is specifically designed for patient authentication with different navigation targets (/patient/home vs /dashboard) and different user information display.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:33.081Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/providers.instructions.md:0-0
Timestamp: 2025-11-25T13:52:33.081Z
Learning: Applies to src/Providers/**/*PatientUserProvider*{.ts,.tsx} : PatientUserProvider should handle patient authentication for public appointment booking

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-04-11T20:28:51.054Z
Learnt from: AdityaJ2305
Repo: ohcnetwork/care_fe PR: 11884
File: src/pages/Landing/LandingPage.tsx:128-158
Timestamp: 2025-04-11T20:28:51.054Z
Learning: The LoginHeader component includes both logged-in UI (with home button and dropdown) and logged-out UI (with sign-in button). When integrating authentication headers in pages that already have login sections (like LandingPage), custom header implementations may be needed to avoid duplicate login UI elements.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:19.758Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Redirect to login when authentication is required in page components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2024-12-02T18:50:29.685Z
Learnt from: kihan2518B
Repo: ohcnetwork/care_fe PR: 8956
File: src/components/Patient/PatientRegister.tsx:861-861
Timestamp: 2024-12-02T18:50:29.685Z
Learning: In `src/components/Patient/PatientRegister.tsx`, `insuranceDetails` is not part of `state.form`, so changes to it are not tracked by the `isDirty` state. Therefore, the form's `disabled` state needs to be conditionally set based on `insuranceDetails.length`.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:19.758Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Handle form submission states (loading, success, error) in page components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:19.758Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Handle patient data with appropriate privacy considerations in healthcare page components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:50:10.786Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/copilot-instructions.md:0-0
Timestamp: 2025-11-25T13:50:10.786Z
Learning: Applies to src/**/*.{ts,tsx} : Use comprehensive error boundaries and user-friendly error messages for medical workflow debugging without exposing PHI

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:52:19.758Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/pages.instructions.md:0-0
Timestamp: 2025-11-25T13:52:19.758Z
Learning: Applies to src/pages/**/*.{ts,tsx} : Handle API errors gracefully in page components

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-01-14T09:56:07.985Z
Learnt from: rajku-dev
Repo: ohcnetwork/care_fe PR: 9887
File: src/components/Users/CreateUserForm.tsx:153-159
Timestamp: 2025-01-14T09:56:07.985Z
Learning: In react-hook-form, form.formState.isValid being false with an empty form.formState.errors object typically indicates that either not all required fields are filled, some fields haven't been "touched", or there's pending async validation. The errors object only contains validation errors for fields that have been validated.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-04-13T03:41:38.805Z
Learnt from: rithviknishad
Repo: ohcnetwork/care_fe PR: 11815
File: src/components/Questionnaire/QuestionTypes/EncounterQuestion.tsx:332-341
Timestamp: 2025-04-13T03:41:38.805Z
Learning: Form inputs in React components should use the controlled component pattern (using `value` instead of `defaultValue`) to ensure they properly reflect changes from all sources, particularly for textareas and form elements that may be updated from multiple places.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-01-19T14:53:36.552Z
Learnt from: AdityaJ2305
Repo: ohcnetwork/care_fe PR: 10054
File: src/components/Users/CreateUserForm.tsx:278-297
Timestamp: 2025-01-19T14:53:36.552Z
Learning: In Cypress tests for React forms, avoid triggering validation errors by submitting an incomplete form before filling all fields, as this can cause form re-rendering and make elements temporarily unavailable to Cypress. Instead, fill all required fields first and then submit the form.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-11-25T13:51:41.208Z
Learnt from: CR
Repo: ohcnetwork/care_fe PR: 0
File: .github/instructions/lib.instructions.md:0-0
Timestamp: 2025-11-25T13:51:41.208Z
Learning: Applies to src/lib/**/validators.ts : Implement form validation for healthcare-specific requirements in validators.ts

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-12-17T19:47:58.152Z
Learnt from: AdityaJ2305
Repo: ohcnetwork/care_fe PR: 14821
File: src/components/Location/LocationNavigation.tsx:161-163
Timestamp: 2025-12-17T19:47:58.152Z
Learning: To ensure the remove-unused-i18n.js cleanup script detects i18n keys, avoid wrapping keys inside a ternary expression passed directly to t(). Instead, call t() separately in each branch of a conditional, e.g. condition ? t("key1") : t("key2"), or compute the key in a variable before passing to t(). For LocationNavigation.tsx (and similar TSX files in the repo), prefer explicit separate i18n calls per branch or a shared precomputed key to guarantee all keys are statically detectable by the script.

Applied to files:

  • src/components/Auth/Login.tsx
📚 Learning: 2025-12-22T10:16:36.690Z
Learnt from: Jacobjeevan
Repo: ohcnetwork/care_fe PR: 14804
File: src/pages/Facility/services/pharmacy/DispensesView.tsx:117-135
Timestamp: 2025-12-22T10:16:36.690Z
Learning: In the care_fe repository, prefer the native HTML title attribute for simple tooltips over using shadcn/ui Tooltip components. Use Tooltip components only when the tooltip requires richer content, interactivity, or accessibility enhancements that cannot be achieved with a plain title. For simple cases, add a title attribute to the element (e.g., <span title="...">). If a Tooltip is used, ensure it is accessible and necessary, and avoid duplicating content available in the title attribute.

Applied to files:

  • src/components/Auth/Login.tsx
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (7)
  • GitHub Check: Test
  • GitHub Check: Redirect rules - care-ohc
  • GitHub Check: Header rules - care-ohc
  • GitHub Check: Pages changed - care-ohc
  • GitHub Check: CodeQL-Build
  • GitHub Check: OSSAR-Scan
  • GitHub Check: deploy-preview
🔇 Additional comments (5)
src/components/Auth/Login.tsx (5)

78-109: LGTM! Excellent type safety improvements.

The new LoginForm and LoginFormErrors interfaces properly replace loose any types with explicit, well-structured types. The form state initialization and useState generics ensure compile-time type checking throughout the component. This aligns well with the PR objective to improve type safety.


140-156: Excellent error handling with proper TypeScript types.

The OTP mutation error handlers use intersection types (Error & { data?: OtpError[] } and Error & { cause?: { errors?: OtpValidationError[] } }) to extend the base Error with API-specific error structures. The error extraction logic safely navigates optional properties with proper checks, avoiding runtime errors while maintaining type safety. This is a strong improvement over the previous any types.

Also applies to: 159-198


287-293: LGTM! Properly typed captcha handler.

The onCaptchaChange function now accepts string | null (matching the react-google-recaptcha callback signature) instead of any, and properly updates the optional "g-recaptcha-response" field in the typed form state. This is a clean type safety improvement.


253-254: Cache invalidation and accessibility improvements confirmed.

Lines 253-254 properly invalidate both FiltersCache and location caches before sign-in, which aligns with the PR objective to "restore location cache invalidation" mentioned in the title. This ensures users don't see stale data after authentication.

Line 701's id="otp" properly matches the Label's htmlFor="otp" (line 696), improving accessibility for screen readers and keyboard navigation. This fulfills the accessibility improvement mentioned in the PR description.

Also applies to: 696-701


219-219: Backend case-sensitivity handling must be verified before this change goes to production.

The frontend now converts usernames to lowercase during input (line 219). If the backend authentication is case-sensitive, existing users with mixed-case usernames will be unable to log in. Verify with the backend team:

  1. Whether authentication compares usernames case-insensitively, OR
  2. Whether all existing usernames in the database are already lowercase, OR
  3. Whether a migration has normalized all usernames to lowercase

Without this confirmation, existing users could experience authentication failures.

Comment on lines +209 to 222
const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const { value, name } = e.target;
const fieldValue = Object.assign({}, form);
const errorField = Object.assign({}, errors);
if (errorField[name]) {
errorField[name] = null;
setErrors(errorField);
}
fieldValue[name] = value;
if (name === "username") {
fieldValue[name] = value.toLowerCase();
const fieldValue = { ...form };
const errorField = { ...errors };

if (name === "username" || name === "password") {
if (errorField[name]) {
errorField[name] = null;
setErrors(errorField);
}
fieldValue[name] = name === "username" ? value.toLowerCase() : value;
setForm(fieldValue);
}
setForm(fieldValue);
};
Copy link
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick | 🔵 Trivial

Improve type narrowing for stricter type safety.

While the runtime guard ensures correctness, TypeScript doesn't narrow name from string to "username" | "password" inside the conditional. This means errorField[name] and fieldValue[name] may bypass strict index signature checking, potentially allowing type-unsafe assignments if tsconfig.json isn't fully strict.

♻️ Refactor with explicit type narrowing
 const handleChange = (e: React.ChangeEvent<HTMLInputElement>) => {
   const { value, name } = e.target;
-  const fieldValue = { ...form };
-  const errorField = { ...errors };
-
-  if (name === "username" || name === "password") {
-    if (errorField[name]) {
-      errorField[name] = null;
-      setErrors(errorField);
-    }
-    fieldValue[name] = name === "username" ? value.toLowerCase() : value;
-    setForm(fieldValue);
+  
+  if (name !== "username" && name !== "password") {
+    return;
   }
+  
+  // TypeScript now knows name is "username" | "password" in this scope
+  const fieldName = name as keyof Pick<LoginForm, "username" | "password">;
+  
+  setErrors((prev) => ({
+    ...prev,
+    [fieldName]: null,
+  }));
+  
+  setForm((prev) => ({
+    ...prev,
+    [fieldName]: fieldName === "username" ? value.toLowerCase() : value,
+  }));
 };
🤖 Prompt for AI Agents
In @src/components/Auth/Login.tsx around lines 209 - 222, The handleChange
function's runtime check (if name === "username" || name === "password") doesn't
narrow the type of name for TypeScript, so indexed accesses like
errorField[name] and fieldValue[name] are not type-safe; update handleChange to
perform explicit type narrowing (e.g., a type guard function isAuthField(name):
name is "username" | "password", or separate branches like if (name ===
"username") { const key: "username" = "username"; ... } else if (name ===
"password") { const key: "password" = "password"; ... }) and use that narrowed
key for errorField[key], fieldValue[key], setErrors and setForm to ensure strict
typings while preserving the current logic.

@KadariPavani
Copy link
Contributor Author

@yash-learner @gauritejusa @Jacobjeevan
please review the pr

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.

Fix: Replace any types with proper TypeScript types in Auth components

1 participant