Skip to content

fix: fetch pet records directly inPetDetail instead of relying on cac…#262

Merged
TatjanaTrajkovic merged 2 commits into
mainfrom
bugfix/pet_detail_fetch_records_by_pet_id
Apr 23, 2026
Merged

fix: fetch pet records directly inPetDetail instead of relying on cac…#262
TatjanaTrajkovic merged 2 commits into
mainfrom
bugfix/pet_detail_fetch_records_by_pet_id

Conversation

@TatjanaTrajkovic

@TatjanaTrajkovic TatjanaTrajkovic commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

…hed App state

Summary by CodeRabbit

  • Improvements
    • Medical records for pet details now load dynamically with a loading indicator, improving responsiveness when viewing pet information.

@TatjanaTrajkovic TatjanaTrajkovic self-assigned this Apr 23, 2026
@TatjanaTrajkovic TatjanaTrajkovic added the bug Something isn't working label Apr 23, 2026
@coderabbitai

coderabbitai Bot commented Apr 23, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@TatjanaTrajkovic has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 52 minutes and 51 seconds before requesting another review.

Your organization is not enrolled in usage-based pricing. Contact your admin to enable usage-based pricing to continue reviews beyond the rate limit, or try again in 52 minutes and 51 seconds.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 34cbfb74-da6f-4928-b685-486660716ad7

📥 Commits

Reviewing files that changed from the base of the PR and between 59d74f3 and e038f39.

📒 Files selected for processing (1)
  • frontend/src/pages/PetDetail.jsx
📝 Walkthrough

Walkthrough

The PetDetail component now fetches its own medical records instead of receiving them as props from the parent App component. This shifts data-fetching responsibility from the parent to the child component, requiring the component to manage its own loading state and call the medical record service on mount.

Changes

Cohort / File(s) Summary
Data Fetching Refactor
frontend/src/App.jsx, frontend/src/pages/PetDetail.jsx
Removed petRecords prop from PetDetail route in App.jsx. PetDetail now manages its own data fetching with useState for petRecords and loading, plus a useEffect hook that calls medicalRecordService.getRecordsByPet(pet.id) when the pet changes. Updated UI to show loading spinner during fetch operations.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Suggested labels

frontend

Poem

🐰 A rabbit hops with joy today,
Props be gone, fetch is the way!
Each pet loads its own file true,
No more passing between two and two.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately describes the main change: moving pet records fetching from App to PetDetail component, though it is truncated.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

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

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch bugfix/pet_detail_fetch_records_by_pet_id

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@frontend/src/pages/PetDetail.jsx`:
- Around line 7-11: The useEffect guard return leaves loading true when pet?.id
is falsy, causing the spinner to hang; update the effect (or the initial state)
so loading is false when there is no pet id: either initialize const [loading,
setLoading] = useState(!!pet?.id) or modify the useEffect to call
setLoading(false) in the early-return branch before returning; reference the
useEffect, pet?.id, and setLoading identifiers when making the change.
- Around line 9-16: The effect in PetDetail.jsx that calls
medicalRecordService.getRecordsByPet(pet.id) can suffer from stale-response
races when pet.id changes; wrap the async call with a cancellation guard (e.g.,
let cancelled = false or an AbortController) inside the useEffect so resolved
promises from older requests are ignored: set cancelled = false before calling
getRecordsByPet, and in then/catch/finally check if cancelled and return early
(avoid calling setPetRecords or setLoading when cancelled); return a cleanup
function that sets cancelled = true (or aborts the controller); keep the
dependency on pet?.id unchanged and reference the existing useEffect,
medicalRecordService.getRecordsByPet, setPetRecords and setLoading when making
the changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 46803b95-36ec-4366-b606-7dd975637e56

📥 Commits

Reviewing files that changed from the base of the PR and between 73b4efa and 59d74f3.

📒 Files selected for processing (2)
  • frontend/src/App.jsx
  • frontend/src/pages/PetDetail.jsx
💤 Files with no reviewable changes (1)
  • frontend/src/App.jsx

Comment thread frontend/src/pages/PetDetail.jsx
Comment thread frontend/src/pages/PetDetail.jsx
@TatjanaTrajkovic
TatjanaTrajkovic merged commit 0c69c49 into main Apr 23, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bugfix: PetDetail visar tom journalhistorik när man navigerar via patientkort

1 participant