feat(pallets): finish changing location of pallet - #209
Conversation
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: You can disable this status message by setting the Use the checkbox below for a quick retry:
📝 WalkthroughWalkthroughAdds pallet destination, transit, arrival, rerouting, and append-only movement history support across the backend, sync shapes, logistics UI, admin pallet forms, and feature tests. Authentication, registration, password, and 2FA messages now use English and Polish translations. ChangesPallet logistics tracking
Localized authentication messages
Estimated code review effort: 4 (Complex) | ~60 minutes Sequence Diagram(s)sequenceDiagram
participant Operator
participant LogisticsPallets
participant PalletMovementController
participant PalletMovementService
participant PalletMovementLedger
Operator->>LogisticsPallets: select pallet and destination
LogisticsPallets->>PalletMovementController: submit reroute
PalletMovementController->>PalletMovementService: assign destination
PalletMovementService->>PalletMovementLedger: append movement history
PalletMovementService-->>LogisticsPallets: return updated logistics view
Possibly related PRs
Suggested reviewers: 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ 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 |
Auth error and status messages were hardcoded English literals rather than translation calls, so they stayed English on a Polish UI no matter what lang/pl.json contained — there was no key for them to match. Wraps all 29 user-facing strings in AuthController, AuthService, TwoFactorController, TwoFactorChallengeController, RegisterController and RegisterRequest in __(), and adds the 24 resulting keys to lang/en.json and lang/pl.json (parity kept). The login screen resolves the locale because SetLocale runs in the web middleware group, so guest requests are covered. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YbLa6GeJZACX3tFCE7iNJq
|
@CodeRabbit review |
✅ Action performedReview finished.
|
There was a problem hiding this comment.
Actionable comments posted: 3
🧹 Nitpick comments (1)
backend/tests/Feature/Web/Logistics/PalletDestinationTest.php (1)
347-360: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAssert no ledger entry is created by the admin edit path.
The PR objective explicitly states admin pallet CRUD updates destinations "without creating ledger entries," but this test only checks the destination value — add an
assertDatabaseCount('pallet_movements', 0)to actually verify the documented behavior and guard against a future regression that silently starts logging admin edits.As per path instructions, "Tests are mandatory for new endpoints/business logic: happy path, validation 422, authorization (guest + wrong role), domain edge cases."
✅ Proposed test addition
])->assertRedirect(route('admin.pallets.index')); $this->assertSame('DOCK-04', $pallet->fresh()->destination); + $this->assertDatabaseCount('pallet_movements', 0); }🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@backend/tests/Feature/Web/Logistics/PalletDestinationTest.php` around lines 347 - 360, Update test_admin_can_edit_a_pallet_destination_directly to assert the pallet_movements table contains zero records after the admin update, while preserving the existing destination assertion and redirect checks.Source: Path instructions
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@backend/app/Http/Controllers/Web/AuthController.php`:
- Around line 80-84: Make the 2FA attempt-limit message translatable by updating
the rate-limit branch in
backend/app/Http/Controllers/Web/TwoFactorChallengeController.php:51-54 to use
the translation key with a :seconds placeholder and pass the remaining seconds
for interpolation; add the corresponding entries to
backend/lang/en.json:4910-4933 and backend/lang/pl.json:4910-4933. The
AuthController locations at
backend/app/Http/Controllers/Web/AuthController.php:80-84 and :129-132, and the
secondary TwoFactorChallengeController location at :114-117, require no direct
changes.
In `@backend/app/Http/Requests/Concerns/ValidatesPalletLogistics.php`:
- Around line 40-47: Add the missing “Select an active logistics operator.” key
to the Polish translation catalog, matching the corresponding entry in en.json
and the message referenced by palletLogisticsMessages(). Preserve the existing
Polish translation format and do not alter the validation message definition.
In
`@backend/database/migrations/2026_07_25_100001_add_destination_to_pallet_movements_table.php`:
- Around line 14-16: The destination-transition documentation incorrectly treats
to_destination = null as sufficient evidence of arrival. Update the ledger
interpretation comment in
backend/database/migrations/2026_07_25_100001_add_destination_to_pallet_movements_table.php:14-16
to require to_location matching from_destination or an explicit event marker;
clarify in backend/resources/js/Pages/admin/pallet-movements/Index.jsx:40-42
that target clearing and arrival share this transition; and qualify the arrivals
statement in CHANGELOG.md:11 accordingly.
---
Nitpick comments:
In `@backend/tests/Feature/Web/Logistics/PalletDestinationTest.php`:
- Around line 347-360: Update test_admin_can_edit_a_pallet_destination_directly
to assert the pallet_movements table contains zero records after the admin
update, while preserving the existing destination assertion and redirect checks.
🪄 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: defaults
Review profile: CHILL
Plan: Pro Plus
Run ID: aee8791a-e093-4f66-8bad-ff934b42982f
📒 Files selected for processing (35)
CHANGELOG.mdbackend/app/Enums/PalletStatus.phpbackend/app/Http/Controllers/Web/Admin/PalletController.phpbackend/app/Http/Controllers/Web/AuthController.phpbackend/app/Http/Controllers/Web/Logistics/PalletMovementController.phpbackend/app/Http/Controllers/Web/RegisterController.phpbackend/app/Http/Controllers/Web/TwoFactorChallengeController.phpbackend/app/Http/Controllers/Web/TwoFactorController.phpbackend/app/Http/Requests/AssignPalletDestinationRequest.phpbackend/app/Http/Requests/Concerns/ValidatesPalletLogistics.phpbackend/app/Http/Requests/PalletRequest.phpbackend/app/Http/Requests/RegisterRequest.phpbackend/app/Http/Requests/StorePalletMovementRequest.phpbackend/app/Models/Pallet.phpbackend/app/Models/PalletMovement.phpbackend/app/Services/Auth/AuthService.phpbackend/app/Services/Logistics/PalletMovementService.phpbackend/app/Sync/ShapeRegistry.phpbackend/app/Sync/Shapes/PalletMovementsRecentShape.phpbackend/database/factories/PalletFactory.phpbackend/database/factories/PalletMovementFactory.phpbackend/database/migrations/2026_07_25_100000_add_destination_to_pallets_table.phpbackend/database/migrations/2026_07_25_100001_add_destination_to_pallet_movements_table.phpbackend/lang/en.jsonbackend/lang/pl.jsonbackend/resources/js/Pages/admin/pallet-movements/Index.jsxbackend/resources/js/Pages/admin/pallets/Create.jsxbackend/resources/js/Pages/admin/pallets/Edit.jsxbackend/resources/js/Pages/admin/pallets/Index.jsxbackend/resources/js/Pages/admin/pallets/PalletForm.jsxbackend/resources/js/Pages/logistics/MovePallet.jsxbackend/resources/js/Pages/logistics/Pallets.jsxbackend/resources/js/layouts/adminNav.jsbackend/routes/web.phpbackend/tests/Feature/Web/Logistics/PalletDestinationTest.php
The "Set destination" card sat outside ResourceTable's own max-w-7xl wrapper, so it ran edge-to-edge while the table stayed inset. Adds an opt-in `fullWidth` prop to ResourceTable and uses it here, so both share one left/right edge; every other list keeps the 7xl cap. The card's text inputs also used the global .form-input (min-h-[48px]) next to Dropdown triggers (~39px), leaving the four-field row ragged. They now match the Dropdown metrics. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01YbLa6GeJZACX3tFCE7iNJq
- 2FA challenge rate-limit message was a hardcoded interpolated string, so it
stayed English on a Polish UI. Now goes through __() with a :seconds
placeholder; key added to lang/en.json and lang/pl.json.
- Corrected the claim, repeated in the migration docblock, the movements list
and CHANGELOG, that an emptied to_destination marks an arrival. Clearing a
destination produces the identical ledger shape; only a move landing on the
pending destination is an arrival, and pallets.arrived_at is authoritative.
- The admin-CRUD test now asserts no ledger row is written, so the deliberate
"admin edits are unlogged" behaviour can't regress silently.
Not applied: CodeRabbit flagged "Select an active logistics operator." as
missing from lang/pl.json. It is present ("Wybierz aktywnego operatora
logistyki.") and en/pl parity verified clean.
Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YbLa6GeJZACX3tFCE7iNJq
|
@jakub-przepiora ready to review |
|
@JanKolo04 conficts |
# Conflicts: # CHANGELOG.md # backend/lang/en.json # backend/lang/pl.json
Summary
Adds a destination to pallets alongside the existing status and location, so logistics can see where each pallet
is and where it should go. Destination is cleared on arrival (
arrived_atstamped), so transit state is a propertyof the row rather than a string comparison in the UI. Destination changes ride the existing append-only
pallet_movementsledger (newfrom_destination/to_destination), giving one timeline for both "who moved it" and"who redirected it".
New Pallet Logistics view (
/logistics/pallets, Operator/Supervisor/Admin) lists pallets live with status,location, destination, transit state and arrival — filterable by status and location/destination — plus a card to
re-route a pallet without moving it. The Move Pallet terminal gains an optional destination field.
Existing pallets are unaffected: both new columns are nullable and default to unset.
Type of change
Related issue
Closes #101
Testing
New
tests/Feature/Web/Logistics/PalletDestinationTest.php— 18 cases: destination assign/keep/clear, arrivalstamping, stale-arrival clearing, re-route without an operator, validation 422 (length, shipped pallet, soft-deleted),
guest + wrong-role authorization, view render, shape allowlists, and a full pallet journey asserted across the whole
ledger.
php artisan testpasses — 1988 tests, 0 failures (run asphp -d memory_limit=2G vendor/bin/phpunit; theartisan testwrapper OOMs locally at the default 128Mmemory_limit, unrelated to this change — the suite peaks at~329MB)
write paths, Admin CRUD), not manually in a browser
Checklist
.envsecrets committedpallets.destination+arrived_at,pallet_movements.from_destination+to_destination$fillableupdated if new model columns added —PalletandPalletMovementuseFormover the standard web middlewarecomposer auditclean — 37 pre-existing advisories across 11 packages; no dependencies added or changed by thisPR
Notes for reviewers
palletsandpallet_movementsElectric shapes — without that the UI never sees them(there's a test guarding it).
destinationwithout a ledger entry, matching how it already treatslocation. Loggedpaths are the move terminal and the logistics view.
?PalletMovementreturn.Summary by CodeRabbit
New Features
Bug Fixes