Skip to content

Conversation

@rithviknishad
Copy link
Member

@rithviknishad rithviknishad commented Jan 23, 2026

Summary by CodeRabbit

Release Notes

  • Refactor

    • Updated location data caching for the payment reconciliation workflow.
  • Chores

    • Added jotai-family library dependency.

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

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 23, 2026

Walkthrough

This PR adds the jotai-family dependency and refactors location caching by removing the generic locationAtomFamily mechanism and introducing a new paymentReconcilationLocationAtom. The cache invalidation calls and atom hooks are updated across Login and PaymentReconciliationSheet components to use the new payment reconciliation-specific cache.

Changes

Cohort / File(s) Summary
Dependency updates
package.json
Added jotai-family runtime dependency (^1.0.1)
Atom definitions
src/atoms/location-atom.ts
Removed locationAtomFamily and invalidateAllLocationCaches exports; removed related imports for atomFamily, atomWithStorage, createJSONStorage
Atom definitions
src/atoms/paymentReconcilationLocationAtom.ts
New file with paymentReconcilationLocationAtom (facility-scoped atomFamily using localStorage) and invalidateAllPaymentReconcilationLocationCaches utility
Component updates
src/components/Auth/Login.tsx, src/pages/Facility/billing/PaymentReconciliationSheet.tsx
Updated imports and hook calls to use paymentReconcilationLocationAtom instead of locationAtomFamily; Login component now calls invalidateAllPaymentReconcilationLocationCaches() on form submission
🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (2 warnings)
Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description is empty; it lacks all required sections including proposed changes, issue reference, merge checklist items, and relevant context. Add a comprehensive description with the issue number, specific changes made (removal of locationAtomFamily, addition of paymentReconcilationLocationAtom, jotai-family dependency), and completion of the merge checklist.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (1 passed)
Check name Status Explanation
Title check ✅ Passed The title directly and clearly summarizes the main change: switching from the deprecated atomFamily/atomWithStorage pattern to jotai-family for managing atom families.

✏️ 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
  • Commit unit tests in branch cache-payment-record-location

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 migrates from the deprecated atomFamily in jotai/utils to the jotai-family package for better atom family support. The change specifically affects the payment reconciliation location caching functionality.

Changes:

  • Replaces deprecated jotai/utils atomFamily with jotai-family package
  • Renames location atom to be more specific to payment reconciliation context
  • Updates all references to use the new atom implementation

Reviewed changes

Copilot reviewed 5 out of 6 changed files in this pull request and generated 7 comments.

Show a summary per file
File Description
package.json Adds jotai-family dependency for atom family functionality
src/atoms/paymentReconcilationLocationAtom.ts New atom file using jotai-family instead of deprecated jotai/utils atomFamily
src/atoms/location-atom.ts Removes deprecated location-atom file
src/pages/Facility/billing/PaymentReconciliationSheet.tsx Updates import and usage to reference new payment reconciliation atom
src/components/Auth/Login.tsx Updates import and function call to use new invalidation helper

import { atomWithStorage } from "jotai/utils";

/**
* Atom family for payment reconcilation location caching per facility
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

Corrected spelling of 'reconcilation' to 'reconciliation'.

Copilot uses AI. Check for mistakes.
export const paymentReconcilationLocationAtom = atomFamily(
(facilityId: string) =>
atomWithStorage<LocationRead | null>(
`payment_reconcilation_location_cache--${facilityId}`,
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

Corrected spelling of 'reconcilation' to 'reconciliation' in the storage key.

Copilot uses AI. Check for mistakes.
Comment on lines +6 to +21
* Atom family for payment reconcilation location caching per facility
*/
export const paymentReconcilationLocationAtom = atomFamily(
(facilityId: string) =>
atomWithStorage<LocationRead | null>(
`payment_reconcilation_location_cache--${facilityId}`,
null,
),
);

/**
* Helper to invalidate all payment reconcilation location caches
*/
export const invalidateAllPaymentReconcilationLocationCaches = () => {
for (const key in localStorage) {
if (key.startsWith("payment_reconcilation_location_cache--")) {
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

Corrected spelling of 'reconcilation' to 'reconciliation'.

Suggested change
* Atom family for payment reconcilation location caching per facility
*/
export const paymentReconcilationLocationAtom = atomFamily(
(facilityId: string) =>
atomWithStorage<LocationRead | null>(
`payment_reconcilation_location_cache--${facilityId}`,
null,
),
);
/**
* Helper to invalidate all payment reconcilation location caches
*/
export const invalidateAllPaymentReconcilationLocationCaches = () => {
for (const key in localStorage) {
if (key.startsWith("payment_reconcilation_location_cache--")) {
* Atom family for payment reconciliation location caching per facility
*/
export const paymentReconcilationLocationAtom = atomFamily(
(facilityId: string) =>
atomWithStorage<LocationRead | null>(
`payment_reconciliation_location_cache--${facilityId}`,
null,
),
);
/**
* Helper to invalidate all payment reconciliation location caches
*/
export const invalidateAllPaymentReconcilationLocationCaches = () => {
for (const key in localStorage) {
if (key.startsWith("payment_reconciliation_location_cache--")) {

Copilot uses AI. Check for mistakes.
Comment on lines +6 to +21
* Atom family for payment reconcilation location caching per facility
*/
export const paymentReconcilationLocationAtom = atomFamily(
(facilityId: string) =>
atomWithStorage<LocationRead | null>(
`payment_reconcilation_location_cache--${facilityId}`,
null,
),
);

/**
* Helper to invalidate all payment reconcilation location caches
*/
export const invalidateAllPaymentReconcilationLocationCaches = () => {
for (const key in localStorage) {
if (key.startsWith("payment_reconcilation_location_cache--")) {
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

Corrected spelling of 'reconcilation' to 'reconciliation' in the storage key prefix.

Suggested change
* Atom family for payment reconcilation location caching per facility
*/
export const paymentReconcilationLocationAtom = atomFamily(
(facilityId: string) =>
atomWithStorage<LocationRead | null>(
`payment_reconcilation_location_cache--${facilityId}`,
null,
),
);
/**
* Helper to invalidate all payment reconcilation location caches
*/
export const invalidateAllPaymentReconcilationLocationCaches = () => {
for (const key in localStorage) {
if (key.startsWith("payment_reconcilation_location_cache--")) {
* Atom family for payment reconciliation location caching per facility
*/
export const paymentReconcilationLocationAtom = atomFamily(
(facilityId: string) =>
atomWithStorage<LocationRead | null>(
`payment_reconciliation_location_cache--${facilityId}`,
null,
),
);
/**
* Helper to invalidate all payment reconciliation location caches
*/
export const invalidateAllPaymentReconcilationLocationCaches = () => {
for (const key in localStorage) {
if (key.startsWith("payment_reconciliation_location_cache--")) {

Copilot uses AI. Check for mistakes.
/**
* Atom family for payment reconcilation location caching per facility
*/
export const paymentReconcilationLocationAtom = atomFamily(
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

Corrected spelling of 'Reconcilation' to 'Reconciliation' in the atom name.

Copilot uses AI. Check for mistakes.
import otpApi from "@/types/otp/otpApi";

import { clearQueryPersistenceCache } from "@/Utils/request/queryClient";
import { invalidateAllPaymentReconcilationLocationCaches } from "@/atoms/paymentReconcilationLocationAtom";
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

Corrected spelling of 'Reconcilation' to 'Reconciliation' in the import path and function name.

Suggested change
import { invalidateAllPaymentReconcilationLocationCaches } from "@/atoms/paymentReconcilationLocationAtom";
import { invalidateAllPaymentReconciliationLocationCaches } from "@/atoms/paymentReconciliationLocationAtom";

Copilot uses AI. Check for mistakes.
import { Textarea } from "@/components/ui/textarea";

import { locationAtomFamily } from "@/atoms/location-atom";
import { paymentReconcilationLocationAtom } from "@/atoms/paymentReconcilationLocationAtom";
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

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

Corrected spelling of 'Reconcilation' to 'Reconciliation' in the import.

Suggested change
import { paymentReconcilationLocationAtom } from "@/atoms/paymentReconcilationLocationAtom";
import { paymentReconciliationLocationAtom } from "@/atoms/paymentReconciliationLocationAtom";

Copilot uses AI. Check for mistakes.
@cloudflare-workers-and-pages
Copy link

Deploying care-preview with  Cloudflare Pages  Cloudflare Pages

Latest commit: 5d11e5b
Status: ✅  Deploy successful!
Preview URL: https://dbb64a66.care-preview-a7w.pages.dev
Branch Preview URL: https://cache-payment-record-locatio.care-preview-a7w.pages.dev

View logs

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

🤖 Fix all issues with AI agents
In `@src/atoms/paymentReconcilationLocationAtom.ts`:
- Around line 19-25: The iteration in
invalidateAllPaymentReconcilationLocationCaches uses for...in over localStorage
which can enumerate inherited properties; replace it with a defensive iteration
over Object.keys(localStorage) (e.g., Object.keys(localStorage).forEach) and
filter keys that startWith "payment_reconcilation_location_cache--" before
calling localStorage.removeItem to ensure only actual stored keys are removed.
- Around line 1-14: Rename the misspelled "reconcilation" identifiers to
"reconciliation": update the exported atomFamily name
paymentReconcilationLocationAtom → paymentReconciliationLocationAtom and change
the storage key prefix `payment_reconcilation_location_cache--${facilityId}` →
`payment_reconciliation_location_cache--${facilityId}`; also update any related
helper/utility identifiers such as
invalidateAllPaymentReconcilationLocationCaches →
invalidateAllPaymentReconciliationLocationCaches and adjust all imports/usages
across the codebase to use the corrected names to keep consistency.

Comment on lines +1 to +14
import { LocationRead } from "@/types/location/location";
import { atomFamily } from "jotai-family";
import { atomWithStorage } from "jotai/utils";

/**
* Atom family for payment reconcilation location caching per facility
*/
export const paymentReconcilationLocationAtom = atomFamily(
(facilityId: string) =>
atomWithStorage<LocationRead | null>(
`payment_reconcilation_location_cache--${facilityId}`,
null,
),
);
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

Typo: "reconcilation" should be "reconciliation" throughout.

The naming uses "Reconcilation" (missing 'i') but the component file uses "Reconciliation". This inconsistency could cause confusion and maintenance issues.

Affected identifiers:

  • paymentReconcilationLocationAtompaymentReconciliationLocationAtom
  • payment_reconcilation_location_cache--payment_reconciliation_location_cache--
  • invalidateAllPaymentReconcilationLocationCachesinvalidateAllPaymentReconciliationLocationCaches
🔤 Proposed fix for consistent spelling
-import { LocationRead } from "@/types/location/location";
-import { atomFamily } from "jotai-family";
-import { atomWithStorage } from "jotai/utils";
-
-/**
- * Atom family for payment reconcilation location caching per facility
- */
-export const paymentReconcilationLocationAtom = atomFamily(
-  (facilityId: string) =>
-    atomWithStorage<LocationRead | null>(
-      `payment_reconcilation_location_cache--${facilityId}`,
-      null,
-    ),
-);
+import { LocationRead } from "@/types/location/location";
+import { atomFamily } from "jotai-family";
+import { atomWithStorage } from "jotai/utils";
+
+/**
+ * Atom family for payment reconciliation location caching per facility
+ */
+export const paymentReconciliationLocationAtom = atomFamily(
+  (facilityId: string) =>
+    atomWithStorage<LocationRead | null>(
+      `payment_reconciliation_location_cache--${facilityId}`,
+      null,
+    ),
+);
📝 Committable suggestion

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

Suggested change
import { LocationRead } from "@/types/location/location";
import { atomFamily } from "jotai-family";
import { atomWithStorage } from "jotai/utils";
/**
* Atom family for payment reconcilation location caching per facility
*/
export const paymentReconcilationLocationAtom = atomFamily(
(facilityId: string) =>
atomWithStorage<LocationRead | null>(
`payment_reconcilation_location_cache--${facilityId}`,
null,
),
);
import { LocationRead } from "@/types/location/location";
import { atomFamily } from "jotai-family";
import { atomWithStorage } from "jotai/utils";
/**
* Atom family for payment reconciliation location caching per facility
*/
export const paymentReconciliationLocationAtom = atomFamily(
(facilityId: string) =>
atomWithStorage<LocationRead | null>(
`payment_reconciliation_location_cache--${facilityId}`,
null,
),
);
🤖 Prompt for AI Agents
In `@src/atoms/paymentReconcilationLocationAtom.ts` around lines 1 - 14, Rename
the misspelled "reconcilation" identifiers to "reconciliation": update the
exported atomFamily name paymentReconcilationLocationAtom →
paymentReconciliationLocationAtom and change the storage key prefix
`payment_reconcilation_location_cache--${facilityId}` →
`payment_reconciliation_location_cache--${facilityId}`; also update any related
helper/utility identifiers such as
invalidateAllPaymentReconcilationLocationCaches →
invalidateAllPaymentReconciliationLocationCaches and adjust all imports/usages
across the codebase to use the corrected names to keep consistency.

Comment on lines +19 to +25
export const invalidateAllPaymentReconcilationLocationCaches = () => {
for (const key in localStorage) {
if (key.startsWith("payment_reconcilation_location_cache--")) {
localStorage.removeItem(key);
}
}
};
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

Consider using Object.keys() for safer localStorage iteration.

Using for...in on localStorage may inadvertently iterate over inherited properties in some environments. Using Object.keys() is more defensive.

♻️ Proposed safer iteration
 export const invalidateAllPaymentReconcilationLocationCaches = () => {
-  for (const key in localStorage) {
-    if (key.startsWith("payment_reconcilation_location_cache--")) {
+  Object.keys(localStorage).forEach((key) => {
+    if (key.startsWith("payment_reconciliation_location_cache--")) {
       localStorage.removeItem(key);
     }
-  }
+  });
 };
📝 Committable suggestion

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

Suggested change
export const invalidateAllPaymentReconcilationLocationCaches = () => {
for (const key in localStorage) {
if (key.startsWith("payment_reconcilation_location_cache--")) {
localStorage.removeItem(key);
}
}
};
export const invalidateAllPaymentReconcilationLocationCaches = () => {
Object.keys(localStorage).forEach((key) => {
if (key.startsWith("payment_reconciliation_location_cache--")) {
localStorage.removeItem(key);
}
});
};
🤖 Prompt for AI Agents
In `@src/atoms/paymentReconcilationLocationAtom.ts` around lines 19 - 25, The
iteration in invalidateAllPaymentReconcilationLocationCaches uses for...in over
localStorage which can enumerate inherited properties; replace it with a
defensive iteration over Object.keys(localStorage) (e.g.,
Object.keys(localStorage).forEach) and filter keys that startWith
"payment_reconcilation_location_cache--" before calling localStorage.removeItem
to ensure only actual stored keys are removed.

@github-actions
Copy link

🎭 Playwright Test Results

Status: ❌ Failed
Test Shards: 3

Metric Count
Total Tests 171
✅ Passed 145
❌ Failed 26
⏭️ Skipped 0

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

Run: #5098

@bodhish bodhish merged commit 11eb94d into develop Jan 25, 2026
25 of 30 checks passed
@bodhish bodhish deleted the cache-payment-record-location branch January 25, 2026 14:51
@github-actions
Copy link

@rithviknishad Your efforts have helped advance digital healthcare and TeleICU systems. 🚀 Thank you for taking the time out to make CARE better. We hope you continue to innovate and contribute; your impact is immense! 🙌

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.

4 participants