Files
evidencija-rezija/app/lib
Nikola Derežič fdfa23e67d fix: resolve MongoDB ObjectId serialization error in client components
Fix React serialization warning when passing ObjectIds to client components:

**Problem:**
- MongoDB ObjectIds have toJSON() methods which React rejects in client components
- Error: "Only plain objects can be passed to Client Components from Server Components. Objects with toJSON methods are not supported"
- Occurred when rendering main page with year parameter (?year=2023)

**Solution:**
- Add $addFields stage in fetchAllLocations aggregation pipeline
- Convert location _id and bill _id fields to strings using $toString
- Simplify $project stage to use single "bills": 1 instead of individual field projections
- Ensures only plain objects (strings) are passed to client components

**Technical Details:**
- Modified app/lib/actions/locationActions.ts:268-287
- Added $addFields stage before existing $project stage
- Converted ObjectIds to strings while preserving all other data structures
- Build passes without serialization warnings

ObjectId serialization now handled properly across all client component boundaries.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-14 22:45:14 +02:00
..
2025-07-23 13:40:14 +02:00
2024-01-08 16:32:08 +01:00
2024-02-06 09:56:43 +01:00
2025-01-13 16:32:38 +01:00
2024-01-09 10:51:40 +01:00
2024-01-06 10:59:07 +01:00