Skip to content

Bugfix: allow admin to update vet details and resolve user edit form …#258

Merged
TatjanaTrajkovic merged 4 commits into
mainfrom
bugfix/update_vet_info
Apr 23, 2026
Merged

Bugfix: allow admin to update vet details and resolve user edit form …#258
TatjanaTrajkovic merged 4 commits into
mainfrom
bugfix/update_vet_info

Conversation

@TatjanaTrajkovic

@TatjanaTrajkovic TatjanaTrajkovic commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

…issues (#232)

Summary by CodeRabbit

Release Notes

  • New Features

    • Veterinarian records can now be updated from the admin dashboard with automatic population of existing data.
  • Improvements

    • Data refresh now completes synchronously after saving changes, ensuring updates are fully persisted before closing operations.
  • Bug Fixes

    • Fixed vet record management to correctly identify and update existing records instead of creating duplicates.

@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 24 minutes and 25 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 24 minutes and 25 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: ce2bc75d-dc99-4ea7-864c-beea579b8181

📥 Commits

Reviewing files that changed from the base of the PR and between 17b4f57 and b06c765.

📒 Files selected for processing (5)
  • frontend/src/components/admin/UserModal.jsx
  • src/main/java/org/example/vet1177/dto/request/user/UserUpdateRequest.java
  • src/main/java/org/example/vet1177/services/UserService.java
  • src/main/java/org/example/vet1177/services/VetService.java
  • src/test/java/org/example/vet1177/services/UserServiceTest.java
📝 Walkthrough

Walkthrough

This pull request adds update functionality for vet records across the frontend and backend. The frontend UserModal component now fetches existing vet data during edit mode and hydrates the form with license, specialization, and booking information. The backend introduces a new PUT endpoint and corresponding service method to update vet records with license conflict validation.

Changes

Cohort / File(s) Summary
Frontend Form Updates
frontend/src/components/admin/UserModal.jsx, frontend/src/pages/AdminDashboard.jsx
UserModal now fetches and populates vet-specific fields during edit mode using userId lookup, and changes persistence logic to use userId-based updates. AdminDashboard synchronizes data refresh after user save operations.
API Service Layer
frontend/src/services/api.jsx
Adds vetService.update(userId, vetData) method that sends PUT requests to /vets/${userId} for updating existing vet records.
Backend Vet Update Endpoint & Service
src/main/java/org/example/vet1177/controller/VetController.java, src/main/java/org/example/vet1177/services/VetService.java
Adds HTTP PUT endpoint at /api/vets/{userId} with admin authorization and corresponding service method that validates license conflicts before persisting vet record updates.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Suggested reviewers

  • johanbriger
  • annikaholmqvist94
  • lindaeskilsson

Poem

🐰 A vet's record now bends to the will,
With updates that flow and fulfill,
From form to the backend so deep,
The data we nurture and keep,
Changes flowing like lettuce downhill! 🥬

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
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 (4 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: adding functionality for admins to update vet details and fixing user edit form issues. It aligns with the substantial changes across frontend and backend components.
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/update_vet_info

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


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

Caution

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

⚠️ Outside diff range comments (1)
frontend/src/components/admin/UserModal.jsx (1)

223-250: ⚠️ Potential issue | 🟠 Major

Add a bookingInfo control so admins can edit all submitted vet details.

bookingInfo is fetched and sent in vetPayload, but the form only renders license and specialization fields. As-is, admins cannot change booking information through this edit flow.

🛠️ Proposed UI addition
                             <div className="space-y-1.5">
                                 <label htmlFor={specId} className="text-[10px] font-black text-blue-500 uppercase tracking-widest ml-1 italic block text-left">Specialisering</label>
                                 <input
                                     id={specId}
                                     className="w-full px-4 py-3 bg-blue-50/30 border border-blue-100 rounded-2xl focus:ring-2 focus:ring-blue-500 outline-none transition-all font-medium text-slate-700"
                                     placeholder="T.ex. Kirurgi"
                                     value={formData.specialization}
                                     onChange={(e) => setFormData({...formData, specialization: e.target.value})}
                                 />
                             </div>
+                            <div className="space-y-1.5">
+                                <label className="text-[10px] font-black text-blue-500 uppercase tracking-widest ml-1 italic block text-left">Bokningsinformation</label>
+                                <textarea
+                                    className="w-full px-4 py-3 bg-blue-50/30 border border-blue-100 rounded-2xl focus:ring-2 focus:ring-blue-500 outline-none transition-all font-medium text-slate-700"
+                                    placeholder="T.ex. bokningsbara tider eller instruktioner"
+                                    value={formData.bookingInfo}
+                                    onChange={(e) => setFormData({...formData, bookingInfo: e.target.value})}
+                                />
+                            </div>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@frontend/src/components/admin/UserModal.jsx` around lines 223 - 250, The form
only exposes licenseId and specialization but not the bookingInfo field, so
admins can't edit bookingInfo even though it's included in vetPayload; update
the UserModal component to add a controlled input (or textarea/select as
appropriate) bound to formData.bookingInfo with onChange using
setFormData({...formData, bookingInfo: e.target.value}), include an appropriate
label and id (e.g., bookingInfoInput) alongside the existing VETERINÄR-DETALJER
inputs, and ensure when submitting the modal the vetPayload still includes
formData.bookingInfo so edits are sent to the backend.
🤖 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/components/admin/UserModal.jsx`:
- Around line 42-53: When loading vet info in the UserModal (vetService.getAll
then setFormData), handle the case where no Vet row exists by creating one
instead of assuming update will succeed: detect whether vetRecord exists from
vetService.getAll (or catch a 404 from vetService.update) and call
vetService.create(...) with appropriate payload (userId from initialData.id and
fields like licenseId, specialization, bookingInfo) when absent; also update the
save/update handler that currently calls vetService.update(initialData.id, ...)
to fall back to vetService.create on a 404 error so converting OWNER/ADMIN→VET
creates the backend Vet row instead of failing.

In `@src/main/java/org/example/vet1177/services/VetService.java`:
- Around line 74-83: updateVet performs a pre-save duplicate-license check but
does not catch persistence-level unique constraint failures; wrap the
vetRepository.save(vet) call inside a try/catch that catches
DataIntegrityViolationException (same handling as createVet) and rethrow a
BusinessRuleException with a localized message like "Licens-ID X används redan"
(include request.licenseId()), so updateVet and createVet consistently translate
DB uniqueness violations into BusinessRuleException; reference updateVet,
vetRepository.save, DataIntegrityViolationException, and BusinessRuleException
when making the change.

---

Outside diff comments:
In `@frontend/src/components/admin/UserModal.jsx`:
- Around line 223-250: The form only exposes licenseId and specialization but
not the bookingInfo field, so admins can't edit bookingInfo even though it's
included in vetPayload; update the UserModal component to add a controlled input
(or textarea/select as appropriate) bound to formData.bookingInfo with onChange
using setFormData({...formData, bookingInfo: e.target.value}), include an
appropriate label and id (e.g., bookingInfoInput) alongside the existing
VETERINÄR-DETALJER inputs, and ensure when submitting the modal the vetPayload
still includes formData.bookingInfo so edits are sent to the backend.
🪄 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: a5ac726a-1548-40ba-b175-f9b7185a30e7

📥 Commits

Reviewing files that changed from the base of the PR and between 2a6965b and 17b4f57.

📒 Files selected for processing (5)
  • frontend/src/components/admin/UserModal.jsx
  • frontend/src/pages/AdminDashboard.jsx
  • frontend/src/services/api.jsx
  • src/main/java/org/example/vet1177/controller/VetController.java
  • src/main/java/org/example/vet1177/services/VetService.java

Comment thread frontend/src/components/admin/UserModal.jsx
Comment thread src/main/java/org/example/vet1177/services/VetService.java Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend bug Something isn't working frontend

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Frontend: uppdatering av användaruppgifter försöker skapa ny användare

1 participant