Added conditional required validation and format validation for tenant email.
Changes:
- Tenant email is now required when autoTenantNotification is enabled
- Added email format validation using Zod's built-in email validator
- Email field validates format even when autoTenantNotification is off (if not empty)
- Added localization strings for validation errors (Croatian/English)
Validation logic:
- Format validation: Always checks if email is valid format (when not empty)
- Required validation: Email required when autoTenantNotification is true
- Error messages: "email address is invalid" for format, "tenant email is missing" for required
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
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>
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>
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>
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>
Replaced hardcoded "Validation failed" message with translated
version from language files:
- Updated userProfileActions.ts to use t("validation-failed")
- Added translations in English and Croatian
- Reordered general-error div in AccountForm for better layout
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Implemented optional IBAN validation for the account form profile:
- Installed iban.js package for robust IBAN validation
- Added Zod validation with IBAN.isValid() for format checking
- Normalizes IBAN (removes spaces, uppercase) before storage
- Validates country-specific formats and checksums
- Added validation error messages in English and Croatian
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
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>
- 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>
- Add gotoHomeWithMessage function to navigationActions
- Redirect to home page after successful profile save
- Display success message in toast notification instead of in-form
- Check for profileSaved URL parameter on home page mount
- Clean up URL parameter after showing toast
- Move success message translation to home-page section
- Remove unused success state and message from AccountForm
- Remove useEffect import from AccountForm
User experience: After saving profile, users are redirected to the
familiar home screen and see a toast notification confirming the save.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
- Add /account route with profile form (firstName, lastName, address, IBAN)
- Create UserProfile type and MongoDB users collection
- Implement server actions for getting and updating user profile
- Add Account Circle icon to PageHeader linking to /account
- Install Material UI icons for account icon
- Add form input disabling during save with loading spinner
- Add cancel button to discard changes and return home
- Add English and Croatian translations for account page
- Update locale names with flag emojis in language selector
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Migrated from boolean checkbox to enum-based radio buttons for better
flexibility and clarity in tracking bill payment responsibility.
Changes:
- Added BilledTo enum with values 'tenant' and 'landlord'
- Replaced Bill.billedToTenant (boolean) with Bill.billedTo (enum)
- Updated BillEditForm to use radio buttons instead of checkbox
- Updated billActions to handle billedTo enum values
- Updated all display filtering to use enum comparison
- Updated printActions barcode filtering
- Updated translations for radio button labels (en/hr)
The billedTo property is optional for backward compatibility -
undefined values default to BilledTo.Tenant, maintaining current
behavior where only tenant bills are displayed and calculated.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Updated all components to respect the billedToTenant flag:
- LocationCard: Filter bills display and monthlyExpense calculation
- ViewLocationCard: Filter bills display and monthlyExpense calculation
- HomePage: Update monthlyExpense calculations for month grouping
- printActions: Filter barcode print data to only include tenant bills
All filtering uses (bill.billedToTenant ?? true) for backward
compatibility with existing bills that don't have this property set.
This ensures users only see and calculate expenses for bills that
are the tenant's responsibility.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Implemented full server-side persistence for the billedToTenant property:
- Extract billedToTenant from formData in updateOrAddBill action
- Add to MongoDB $set operations for updating existing bills
- Include in new bill creation with value from form
- Set default value (true) for bills added to subsequent months
- Handle undefined values from existing database records using destructuring defaults
This completes the feature - bills can now track whether they should be
paid by the tenant, with backward compatibility for existing data.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
Remove billYear and billMonth from second column, add payedAmount as last value.
- Update PrintBarcodeData interface to replace yearMonth with payedAmount
- Modify fetchBarcodeDataForPrint to include bill.payedAmount
- Update PrintPreview display to show payedAmount (formatted from cents)
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude <noreply@anthropic.com>
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>
- Add Next.js print route at /[locale]/print/[year]/[month]
- Implement fetchBarcodeDataForPrint function with user authentication
- Create PrintPreview component with basic table layout
- Add proper 404 handling with not-found.tsx
- Fix barcode image display with flexible data URL handling
- Filter and sort bills with barcode data for consistent display
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Improve file attachment handling by:
- Adding fileSize === 0 check to prevent empty files from being processed
- Simplifying attachment logic by moving size validation to serializeAttachment function
- Ensuring null is returned for empty/invalid files to preserve existing attachments
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Fix updateOrAddBill to check file size before processing attachment,
preventing empty blob files from overwriting existing attachments
when updating bill properties.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Implement ability to delete bills from all subsequent months
with toggle option and warning message similar to location deletion.
Includes centered warning box and efficient bulk operations.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
Implement ability to add newly created bills to all subsequent months
with toggle option (disabled by default). Includes duplicate checking
and efficient bulk operations.
🤖 Generated with [Claude Code](https://claude.ai/code)
Co-Authored-By: Claude <noreply@anthropic.com>
- 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>
- 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>
- 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>
- 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>