Skip to content

Bug fix/standardize status texts#256

Merged
annikaholmqvist94 merged 11 commits into
mainfrom
bugFix/standardize-status-texts
Apr 24, 2026
Merged

Bug fix/standardize status texts#256
annikaholmqvist94 merged 11 commits into
mainfrom
bugFix/standardize-status-texts

Conversation

@annikaholmqvist94

@annikaholmqvist94 annikaholmqvist94 commented Apr 23, 2026

Copy link
Copy Markdown
Contributor

Standardiserar statustexter över hela gränssnittet och fixar två mindre textbuggar i admin-vyn. Tidigare visade ärendetiteln, status-dropdownen och
aktivitetsloggen olika ord för samma status (Inskickat / Öppen / IN_PROGRESS). Nu kommer alla texter från en enda mappning både i frontend och backend.

Ändringar

Statustexter — ny master-mappning

Backend

  • RecordStatus.java: enumet har nu en displayLabel()-metod med svenska texter. Används av MedicalRecordService.updateStatus när status-ändringar loggas
    till activity_log-tabellen, så att lograderna lagras på svenska istället för raw enum.
  • MedicalRecordService.java: "Status ändrad till: " + newStatus → "Status ändrad till: " + newStatus.displayLabel().
  • MedicalRecordServiceTest.updateStatus_shouldLogActivity: uppdaterat så testet kopplas till labeln istället för enum-namnet.

Frontend

  • statusHelper.js:
    • OPEN-label: Inskickat → Öppen
    • CLOSED-label: Avslutat → Avslutad
    • Ny ACTIVE_STATUS_KEYS (statusar VET kan välja i dropdown — CLOSED utesluts, stängs via modalen)
    • Ny getStatusLabel() med fallback
    • Ny ACTION_LABELS + getActionLabel() för ActivityType-enum
  • CaseDetail.jsx: hårdkodade -rader i status-dropdownen ersatta av loop över ACTIVE_STATUS_KEYS. Dropdown och header-badge kan inte längre gå ur
    synk.
  • AuditLogView.jsx: log.action.replace('_', ' ') → getActionLabel(log.action). Admin ser nu svenska rubriker: "Ärende skapat", "Status ändrad", "Kommentar
    tillagd", "Veterinär tilldelad", "Ärende uppdaterat" istället för STATUS CHANGED m.fl.

Övriga UI-textfixar

AdminDashboard.jsx

  • Rad 175: stavfel Admininstratörer → Administratörer
  • Rad 211: Audit Log → Aktivitetslogg (enda engelska UI-strängen i hela appen)

Påverkan på användaren

  • CaseDetail header-badge, dashboards, PetDetail-lista, VET-dropdown: samma statustext överallt ("Öppen" / "Under behandling" / "Väntar på svar" /
    "Avslutad").
  • CaseDetail "Logg & Historik": status-ändringsraden visar "Status ändrad till: Under behandling" istället för "...IN_PROGRESS".
  • Admin-vyn: svenska rubriker på varje logghändelse.
  • Historiska rader i activity_log med gamla enum-texter förblir oförändrade. Fixen gäller nya rader.

closes #239
closes #249

Summary by CodeRabbit

  • Bug Fixes

    • Corrected typo in admin dashboard label
    • Audit logs now show human-readable Swedish action labels
  • New Features

    • Audit log view displays formatted action heading, date, and description
    • Status selector now built dynamically from available statuses
  • Localization

    • Swedish display labels updated for status values and audit/dashboard terminology

@coderabbitai

coderabbitai Bot commented Apr 23, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@annikaholmqvist94 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 54 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 54 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: ff06a352-ba0a-499c-800c-931deab95094

📥 Commits

Reviewing files that changed from the base of the PR and between c658302 and fcfc848.

📒 Files selected for processing (1)
  • frontend/src/components/admin/AuditLogView.jsx
📝 Walkthrough

Walkthrough

This PR standardizes Swedish display labels for statuses and actions across backend and frontend: backend enum now holds Swedish labels; frontend uses new helper mappings and functions (including action labels) and updates UI text and status dropdown rendering accordingly.

Changes

Cohort / File(s) Summary
Frontend: Audit & Status Helpers
frontend/src/utils/statusHelper.js
Adds ACTION_LABELS, getActionLabel(), ACTIVE_STATUS_KEYS, and getStatusLabel(); updates STATUS_MAP labels to Swedish.
Frontend: Audit Log UI
frontend/src/components/admin/AuditLogView.jsx
Imports and uses getActionLabel() to render formatted action labels in audit entries.
Frontend: Case & Admin UIs
frontend/src/pages/CaseDetail.jsx, frontend/src/pages/AdminDashboard.jsx
CaseDetail builds status dropdown from ACTIVE_STATUS_KEYS and uses mapped labels; AdminDashboard fixes Swedish UI text (Administratörer, Aktivitetslogg).
Backend: Status enum & service
src/main/java/.../entities/RecordStatus.java, src/main/java/.../services/MedicalRecordService.java, src/test/java/.../services/MedicalRecordServiceTest.java
RecordStatus now stores Swedish displayLabel(); MedicalRecordService.updateStatus() logs using displayLabel(); tests updated to assert against the display label.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Suggested labels

bug, backend, frontend

Suggested reviewers

  • lindaeskilsson
  • TatjanaTrajkovic
  • johanbriger

Poem

🐇 I hopped through enums, labels snug and neat,

"Öppen", "Avslutad" — now every view meets.
From backend burrow to frontend log's light,
Swedish words dancing, all tidy and bright.
A carrot-cheered commit — hoppity delight!

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.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 'Bug fix/standardize status texts' clearly summarizes the main change: standardizing status text display across the application's frontend and backend.
Linked Issues check ✅ Passed All linked issue requirements are met: #239 addressed via consistent STATUS_MAP and getStatusLabel/getActionLabel functions; #249 addressed via Swedish UI text updates across components and enum display labels.
Out of Scope Changes check ✅ Passed All changes are scoped to standardizing status and action texts: backend enum labels, helper functions, component UI updates, and test assertions align with linked issues.

✏️ 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/standardize-status-texts

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

Caution

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

⚠️ Outside diff range comments (1)
src/main/java/org/example/vet1177/services/MedicalRecordService.java (1)

245-259: ⚠️ Potential issue | 🟡 Minor

Minor: inconsistent log text between updateStatus(CLOSED) and close().

Both paths emit an ActivityType.STATUS_CHANGED entry when a case ends up closed, but they produce different messages:

  • updateStatus(..., RecordStatus.CLOSED, ...)"Status ändrad till: Avslutad" (line 256)
  • close(...)"Ärende stängt" (line 286)

For users reading "Logg & Historik", the same business event will render with two different phrasings depending on which endpoint the client happened to call. Worth unifying so the activity log is deterministic regardless of code path.

♻️ Suggested alignment (one option)
         activityLogService.log(
                 ActivityType.STATUS_CHANGED,
-                "Ärende stängt",
+                "Status ändrad till: " + RecordStatus.CLOSED.displayLabel(),
                 closedBy,
                 updated
         );

Alternatively, have close() delegate to updateStatus(..., CLOSED, ...) so there is a single source of truth for both the state transition and the log text.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/main/java/org/example/vet1177/services/MedicalRecordService.java` around
lines 245 - 259, The activity log messages for the same business event are
inconsistent between updateStatus(..., RecordStatus.CLOSED, ...) and close(...):
unify them by choosing one canonical message or delegating close(...) to call
updateStatus(...) so the same ActivityType.STATUS_CHANGED entry and text are
used; update the call to activityLogService.log(...)
(ActivityType.STATUS_CHANGED) to use the agreed Swedish label (e.g., "Status
ändrad till: " + RecordStatus.CLOSED.displayLabel() or "Ärende stängt") and
remove the duplicate/contradictory message in the other method so both paths
produce identical log text.
🧹 Nitpick comments (1)
src/test/java/org/example/vet1177/services/MedicalRecordServiceTest.java (1)

432-437: LGTM – test now tracks the enum as the source of truth.

Switching from a hardcoded "AWAITING_INFO" substring to RecordStatus.AWAITING_INFO.displayLabel() is the right call: the test stays green automatically if the Swedish label is ever reworded, and it actually verifies the user-visible contract rather than the enum identifier.

Optional (nit): contains(...) on the label alone will still pass if the prefix "Status ändrad till: " is accidentally dropped or changed. If you want to lock the full log format, consider eq("Status ändrad till: " + RecordStatus.AWAITING_INFO.displayLabel()). Not blocking.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/test/java/org/example/vet1177/services/MedicalRecordServiceTest.java`
around lines 432 - 437, Tests now assert the enum's display label but to lock
the full log format change the verifier to assert the exact message: in the
verify(activityLogService).log(...) call replace the
contains(RecordStatus.AWAITING_INFO.displayLabel()) argument with eq("Status
ändrad till: " + RecordStatus.AWAITING_INFO.displayLabel()) so
ActivityType.STATUS_CHANGED, the exact user-facing string, currentUser and
record are all checked.
🤖 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/AuditLogView.jsx`:
- Around line 73-84: Remove the orphaned JSX block that appears between the
useMemo closure and the loading guard (the fragment referencing log, date, and
getActionLabel outside the render); then update the actual render loop where
each audit row is output (replace occurrences of log.action.replace('_', ' ')
with a call to getActionLabel(log.action) and ensure the existing loading check
(if (loading) return ...) remains at the top of the component return path);
verify there are no remaining references to the orphaned variables (log, date)
outside the loop and that getActionLabel is used inside the rendered map/loop
for headings.

In `@frontend/src/pages/CaseDetail.jsx`:
- Around line 3-6: There are duplicate imports for STATUS_MAP/ACTIVE_STATUS_KEYS
and lucide-react icons, and the new lucide import omitted UserMinus which is
still used; remove the duplicated import lines and consolidate into a single
import from '../utils/statusHelper' that includes STATUS_MAP and
ACTIVE_STATUS_KEYS, and a single import from 'lucide-react' that lists all icons
used (Stethoscope, Lock, FileText, CheckCircle, Upload, Trash2, ExternalLink,
UserMinus) so no bindings are redeclared and UserMinus remains defined.

In `@frontend/src/utils/statusHelper.js`:
- Around line 25-31: ACTION_LABELS is missing the UNASSIGNED key so AuditLogView
will display the raw "UNASSIGNED" string; add an entry 'UNASSIGNED': 'Släpp
ärende' (or the agreed Swedish label) to the ACTION_LABELS object so
getActionLabel(log.action) returns a localized heading instead of the raw enum;
update the ACTION_LABELS export accordingly.

---

Outside diff comments:
In `@src/main/java/org/example/vet1177/services/MedicalRecordService.java`:
- Around line 245-259: The activity log messages for the same business event are
inconsistent between updateStatus(..., RecordStatus.CLOSED, ...) and close(...):
unify them by choosing one canonical message or delegating close(...) to call
updateStatus(...) so the same ActivityType.STATUS_CHANGED entry and text are
used; update the call to activityLogService.log(...)
(ActivityType.STATUS_CHANGED) to use the agreed Swedish label (e.g., "Status
ändrad till: " + RecordStatus.CLOSED.displayLabel() or "Ärende stängt") and
remove the duplicate/contradictory message in the other method so both paths
produce identical log text.

---

Nitpick comments:
In `@src/test/java/org/example/vet1177/services/MedicalRecordServiceTest.java`:
- Around line 432-437: Tests now assert the enum's display label but to lock the
full log format change the verifier to assert the exact message: in the
verify(activityLogService).log(...) call replace the
contains(RecordStatus.AWAITING_INFO.displayLabel()) argument with eq("Status
ändrad till: " + RecordStatus.AWAITING_INFO.displayLabel()) so
ActivityType.STATUS_CHANGED, the exact user-facing string, currentUser and
record are all checked.
🪄 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: a21cda88-13c0-40a4-9358-511e974189d7

📥 Commits

Reviewing files that changed from the base of the PR and between c9de25e and 6e12f82.

📒 Files selected for processing (7)
  • frontend/src/components/admin/AuditLogView.jsx
  • frontend/src/pages/AdminDashboard.jsx
  • frontend/src/pages/CaseDetail.jsx
  • frontend/src/utils/statusHelper.js
  • src/main/java/org/example/vet1177/entities/RecordStatus.java
  • src/main/java/org/example/vet1177/services/MedicalRecordService.java
  • src/test/java/org/example/vet1177/services/MedicalRecordServiceTest.java

Comment thread frontend/src/components/admin/AuditLogView.jsx Outdated
Comment thread frontend/src/pages/CaseDetail.jsx
Comment thread frontend/src/utils/statusHelper.js
@annikaholmqvist94
annikaholmqvist94 merged commit d016ed5 into main Apr 24, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Kontrollera och standardisera språk - hela sajten ska vara på svenska Standardisera statustexter i hela gränssnittet

1 participant