-
Notifications
You must be signed in to change notification settings - Fork 1k
fix deprecation: switch to jotai-family for atom family #15290
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughThis PR adds the Changes
🚥 Pre-merge checks | ✅ 1 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (1 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
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. Comment |
There was a problem hiding this 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 |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
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'.
| export const paymentReconcilationLocationAtom = atomFamily( | ||
| (facilityId: string) => | ||
| atomWithStorage<LocationRead | null>( | ||
| `payment_reconcilation_location_cache--${facilityId}`, |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
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.
| * 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--")) { |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
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'.
| * 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--")) { |
| * 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--")) { |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
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.
| * 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--")) { |
| /** | ||
| * Atom family for payment reconcilation location caching per facility | ||
| */ | ||
| export const paymentReconcilationLocationAtom = atomFamily( |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
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.
| import otpApi from "@/types/otp/otpApi"; | ||
|
|
||
| import { clearQueryPersistenceCache } from "@/Utils/request/queryClient"; | ||
| import { invalidateAllPaymentReconcilationLocationCaches } from "@/atoms/paymentReconcilationLocationAtom"; |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
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.
| import { invalidateAllPaymentReconcilationLocationCaches } from "@/atoms/paymentReconcilationLocationAtom"; | |
| import { invalidateAllPaymentReconciliationLocationCaches } from "@/atoms/paymentReconciliationLocationAtom"; |
| import { Textarea } from "@/components/ui/textarea"; | ||
|
|
||
| import { locationAtomFamily } from "@/atoms/location-atom"; | ||
| import { paymentReconcilationLocationAtom } from "@/atoms/paymentReconcilationLocationAtom"; |
Copilot
AI
Jan 23, 2026
There was a problem hiding this comment.
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.
| import { paymentReconcilationLocationAtom } from "@/atoms/paymentReconcilationLocationAtom"; | |
| import { paymentReconciliationLocationAtom } from "@/atoms/paymentReconciliationLocationAtom"; |
Deploying care-preview with
|
| 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 |
There was a problem hiding this 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.
| 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, | ||
| ), | ||
| ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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:
paymentReconcilationLocationAtom→paymentReconciliationLocationAtompayment_reconcilation_location_cache--→payment_reconciliation_location_cache--invalidateAllPaymentReconcilationLocationCaches→invalidateAllPaymentReconciliationLocationCaches
🔤 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.
| 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.
| export const invalidateAllPaymentReconcilationLocationCaches = () => { | ||
| for (const key in localStorage) { | ||
| if (key.startsWith("payment_reconcilation_location_cache--")) { | ||
| localStorage.removeItem(key); | ||
| } | ||
| } | ||
| }; |
There was a problem hiding this comment.
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.
| 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.
🎭 Playwright Test ResultsStatus: ❌ Failed
📊 Detailed results are available in the playwright-final-report artifact. Run: #5098 |
|
@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! 🙌 |
Summary by CodeRabbit
Release Notes
Refactor
Chores
✏️ Tip: You can customize this high-level summary in your review settings.