Commit Graph

35 Commits

Author SHA1 Message Date
Knee Cola
93cf159c44 Add auto tenant notification toggle to LocationEditForm
Added toggle to control automatic tenant notifications with conditional
email field visibility based on the toggle state.

Changes:
- Added autoTenantNotification field to BillingLocation interface
- Updated LocationEditForm with "Notify tenant automatically" toggle
- Email field now only visible when autoTenantNotification is enabled
- Toggle appears after tenant name fields (when generateTenantCode is active)
- Updated updateOrAddLocation action to persist autoTenantNotification flag
- Added localization strings for toggle (Croatian/English)

Field visibility hierarchy:
1. Generate 2D code toggle (always visible)
2. Tenant name fields (visible when #1 is ON)
3. Auto notification toggle (visible when #1 is ON)
4. Email field (visible when #1 AND #3 are ON)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 09:24:18 +01:00
Knee Cola
5dd7d40edf Update navigation to preserve year/month context in redirects
Modified gotoHomeWithMessage to accept optional yearMonth parameter and
updated location actions to redirect with year/month context after save/delete.

Changes:
- Updated gotoHomeWithMessage to accept yearMonth parameter
- Modified redirect URLs to include year and month query params
- updateOrAddLocation now redirects to /${locale}?year=${year}&month=${month}&locationSaved=true
- deleteLocationById now redirects to /${locale}?year=${year}&month=${month}&locationDeleted=true
- Removed unused gotoHome import from locationActions

This ensures users return to the same month view after location operations,
maintaining context and providing success feedback via URL parameters.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 09:05:25 +01:00
Knee Cola
9ae023cc94 Add tenant information fields to LocationEditForm
Added optional tenant fields (first name, last name, email) to billing locations
with a toggle to enable/disable 2D barcode generation for tenants.

Changes:
- Added generateTenantCode, tenantFirstName, tenantLastName, and tenantEmail
  fields to BillingLocation interface
- Updated LocationEditForm with toggle control and conditional tenant fields
- Implemented conditional validation: tenant names required when generateTenantCode is true
- Updated updateOrAddLocation action to persist tenant data across all update operations
- Added localization strings for tenant fields and validation messages (Croatian/English)

The generateTenantCode flag is persisted in the database and controls visibility
of tenant name fields. When enabled, both first and last names become mandatory.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 08:23:08 +01:00
Knee Cola
3e355209e8 Fix TypeScript errors in server actions
Added explicit return statements after redirect calls in all server
actions to satisfy TypeScript type checking. These returns won't be
reached due to redirects but are needed for type safety.

Fixed in:
- userProfileActions.ts (updateUserProfile)
- locationActions.ts (updateOrAddLocation, deleteLocationById)
- billActions.ts (updateOrAddBill, deleteBill)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 21:03:42 +01:00
Knee Cola
aee6dc0932 Remove billedTo filtering to show all bills to landlord
The billedTo field indicates payment responsibility (tenant vs landlord),
not viewing permissions. Landlords should see and manage ALL bills.

Changes:
- LocationCard: Display all bills regardless of billedTo value
- LocationCard: Calculate monthlyExpense from all paid bills
- HomePage: Include all paid bills in monthlyExpense aggregation
- printActions: Print all bills with barcodes regardless of billedTo
- locationActions: Add billedTo property to fetchAllLocations result

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 19:32:54 +01:00
Knee Cola
fa1d04480f Extend toast notifications to all forms (bills and locations)
- Update billActions to redirect with toast messages
  - billSaved: when bill is created or updated
  - billDeleted: when bill is deleted
- Update locationActions to redirect with toast messages
  - locationSaved: when location is created or updated
  - locationDeleted: when location is deleted
- Enhance MonthLocationList to check for all toast parameters
  - Consolidated success message handling for all operations
  - Clean up all URL parameters after showing toast
- Add translations for all success messages (EN and HR)
  - Bill saved/deleted messages
  - Location saved/deleted messages

User experience: All forms now redirect to home with toast
notifications, providing consistent feedback across the app.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 19:06:10 +01:00
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
daa9b2a134 locationAction: query optimization 2025-08-11 13:58:57 +02:00
aab0afd045 locationAction: fixed optional form fields 2025-08-11 13:57:07 +02:00
6d6a8782ab optimize database queries by excluding bills field
- Added projections to exclude bills field from location lookup queries
- Optimized updateOrAddLocation currentLocation query (line 79)
- Optimized duplicate check query for subsequent months (line 201)
- Optimized deleteLocationById location lookup query (line 372)
- Reduces network traffic and memory usage by avoiding unnecessary bills data
- Improves query performance especially for locations with many bills or large attachments

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-11 11:50:47 +02:00
a6d0cc77ac add update scope options for location editing
- Added radio button group to LocationEditForm with three update modes:
  1. Current month only (default) - updates specific location
  2. Current and all future months - updates current and subsequent months
  3. All months - updates all locations with same name across all time periods
- Enhanced updateOrAddLocation action with smart update logic based on scope
- Uses name-based matching to find related locations across months
- Added compact radio button styling with reduced spacing and indentation
- Added translations for update scope options in Croatian and English
- Maintains backward compatibility with existing single-location updates

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-11 11:42:48 +02:00
1eac116a55 add option to delete location in all subsequent months
- Added toggle in LocationDeleteForm for deleting locations from future months (disabled by default)
- Modified deleteLocationById action to support batch deletion across subsequent months
- When enabled, deletes all locations with same name in current and future months/years
- Only deletes user's own locations with proper data isolation
- Added translations for toggle text in Croatian and English
- Removed unused imports and variables to fix TypeScript warnings
- Uses efficient MongoDB deleteMany operation for bulk deletions

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-11 11:01:16 +02:00
78a6c18ba5 add option to create location in all subsequent months
- Added toggle in LocationEditForm for adding locations to future months (disabled by default)
- Modified updateOrAddLocation action to support batch creation across subsequent months
- Only creates locations in months where no location with same name exists
- Added translations for toggle text in Croatian and English
- Fixed unused variable warning in deleteLocationById
- Improved auth.ts development comments for clarity

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-11 10:27:31 +02:00
87d6928a97 BugFix: fixing types 2025-01-13 16:32:38 +01:00
103e371d5f mongo projekcija proširena property-em "hasAttachment" 2025-01-13 16:05:15 +01:00
86b6c777c4 opzimizacija: stranica za prikaz godine je dohvaćala i QR kodove = slow 2024-12-14 09:56:50 +01:00
4ab61f9917 implementiran share by link 2024-12-13 17:50:12 +01:00
f7b92931a9 i18n: fixing form validaton messages 2024-02-17 10:17:17 +01:00
fcd94408fe BugFix: fixed translation formating 2024-02-17 09:41:35 +01:00
30b3da9c31 i18n support added to all form validations 2024-02-17 07:28:47 +01:00
cb633ccc4d BugFix: when fetching locations binary data was included in the result 2024-02-08 15:31:35 +01:00
db3b4abed5 optimization: not fetching binary data if not needed 2024-02-08 15:15:10 +01:00
93dd9bf3f4 uklonjen umjetan delay 2024-02-06 14:19:23 +01:00
f0581eb533 za actions dodan "noStore" 2024-02-06 14:17:12 +01:00
7f08349688 uveden umjetni delay 2024-02-06 09:56:43 +01:00
82d895cd6a Hotfix: fn was passed wrong params 2024-02-01 15:17:05 +01:00
2261e83715 refactoring: changing param list of a fn 2024-02-01 15:07:30 +01:00
48990701c9 locationAction didn't allways return form state 2024-01-17 16:17:43 +01:00
0eb11e7d02 form action redirects user to tjhe appropriate year 2024-01-17 15:47:55 +01:00
ccb628aadb implemented pagination 2024-01-10 15:53:46 +01:00
102edff52f refactoring: fixing typescript 2024-01-09 16:41:59 +01:00
8cbf254f38 fixed result sorting 2024-01-09 16:25:23 +01:00
d627ad757d year & month replaced by yearMonth object 2024-01-09 16:20:49 +01:00
46b65711a8 yearMonth split into year + month 2024-01-09 15:43:01 +01:00
8112c9765d refactoring: actions moved to seprate dir 2024-01-09 15:00:26 +01:00