Commit Graph

345 Commits

Author SHA1 Message Date
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
9fda8cadba Internationalize validation error message
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>
2025-11-17 20:51:57 +01:00
Knee Cola
666443f76e Style placeholder text color in account form inputs
Added placeholder:text-gray-600 styling to all form inputs
(firstName, lastName, address, IBAN) to visually distinguish
placeholder text from entered values.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 20:44:41 +01:00
Knee Cola
ba77169554 Add IBAN formatting for improved display readability
Implemented IBAN formatting to display with proper spacing:
- Added formatIban() utility function in formatStrings.ts
- Format: Groups of 4 characters separated by spaces (e.g., HR12 3456 7890 1234 5678 9)
- Applied formatting to IBAN field display in AccountForm
- Updated validation to check cleaned IBAN (without spaces)
- Maintains backward compatibility with server-side validation

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 20:40:10 +01:00
Knee Cola
6d6c65d4e3 Add real-time warning for missing profile data in account form
Added conditional warning alert that displays when required fields are
empty, updating in real-time as the user types:
- Tracks form values with useState and onChange handlers
- Displays warning when firstName, lastName, address, or IBAN is missing
- Warning appears/disappears instantly as user fills or clears fields
- Explains that 2D barcode won't be shown to tenants until all data is complete
- Added translations in English and Croatian

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 20:33:40 +01:00
Knee Cola
216b08c12b Add IBAN validation using iban.js library
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>
2025-11-17 20:23:11 +01:00
Knee Cola
86fa6a67fe Add info box to account form explaining barcode usage
Added informational alert at the top of the account form to explain
that profile data (name, address, IBAN) will be used to generate 2D
barcodes for tenant bill payments. The alert uses a horizontal layout
on all screen sizes for consistent UX.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 20:06:13 +01:00
Knee Cola
3801638d0f Adjust margin for add bill button tooltip for better alignment 2025-11-17 19:44:42 +01:00
Knee Cola
f5f15ea47e Center button labels vertically using self-center
Replace fixed top margin with self-center for vertical alignment
in PrintButton, AddLocationButton, and AddMonthButton text labels.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 19:42:02 +01:00
Knee Cola
e82f9a2cd6 Fix button alignment by removing negative margin
Remove mr-[-3em] from AddLocationButton, AddMonthButton, and PrintButton
to improve visual alignment and spacing consistency.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 19:33:46 +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
Knee Cola
5bbf80c2ae Implement redirect with toast notification on profile save
- 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>
2025-11-17 18:58:43 +01:00
Knee Cola
513e78e8f1 Refactor account page to use icon in form title
- Remove redundant page heading from account page
- Add AccountCircle icon to AccountForm title
- Clean up unused account-page translations
- Simplify account page component by moving title to form

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 18:44:24 +01:00
Knee Cola
80f4c92755 Add user account settings page with profile management
- 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>
2025-11-17 18:37:59 +01:00
Knee Cola
2b55ba78d7 Improve billedTo radio buttons layout to single row
Changed the layout to display the label and radio buttons in a single
horizontal row for better visual alignment and more compact design.

Before: Label on separate line above radio buttons
After: Label and radio buttons aligned horizontally

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 13:50:58 +01:00
Knee Cola
1605eec5fb Replace billedToTenant boolean with billedTo enum
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>
2025-11-17 13:48:28 +01:00
Knee Cola
f0ccac3f68 Filter bills display to show only billedToTenant bills
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>
2025-11-17 13:36:42 +01:00
Knee Cola
c3b555189b Complete billedToTenant server action implementation
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>
2025-11-17 13:30:47 +01:00
Knee Cola
0ae5140487 Add billedToTenant property to Bill interface with UI support
Added new boolean property to track whether a bill should be paid by the tenant.

Changes:
- Added billedToTenant property to Bill interface in db-types.ts
- Added checkbox UI control in BillEditForm for billedToTenant
- Added state management and change handler for the checkbox
- Added i18n translations (EN: "Billed to tenant", HR: "Plaća podstanar")
- Set default value to true for new bills

Note: Server action implementation pending - property not yet persisted to database.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-17 13:18:15 +01:00
9f09d3257b fixed print media selector 2025-10-15 16:58:24 +02:00
f6edea79e7 manually fixed print layout to 4 qr codes per A4 2025-10-15 16:58:03 +02:00
cd3b2ef16d fix: expand cell padding in print layout to fit 6 bills per A4 page
Increase padding and spacing to fit exactly 6 bills per page (down from 8).
- Increase table cell padding (th: 8px 12px, td: 16px 12px)
- Set barcode image max-height to 85px
- Increase text spacing to 0.5rem in print mode

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 13:45:55 +02:00
b5028ada52 fix: update QR code print layout to show payedAmount instead of yearMonth
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>
2025-10-15 13:36:41 +02:00
94a1bcaf36 fix: adjust padding for print content in PrintPreview component 2025-09-14 22:59:39 +02: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
694ec8508b feat: add multilingual support for print preview empty state
Add i18n support for empty state when no barcode data is found:

**English translations:**
- "No Barcode Data Found" 
- "No bills with 2D barcodes found for {yearMonth}"

**Croatian translations:**
- "Nema Podataka o Barkodovima"
- "Nema računa s 2D barkodovima za {yearMonth}"

**Implementation:**
- Add translation keys to messages/en.json and messages/hr.json
- Update server component to fetch empty state translations
- Use proper next-intl parameter passing for yearMonth variable
- Replace hardcoded English text with localized translations

Empty state now displays correct language based on URL locale:
- /en/print/2025/01 → English empty state message
- /hr/print/2025/01 → Croatian empty state message

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-14 22:31:03 +02:00
834444d5c7 fix: resolve next-intl translation parameter error in print footer
Fix IntlError: FORMATTING_ERROR for print footer translation:

- Pass date parameter correctly to t("print-footer") in server component
- Remove manual string replacement in client component 
- Use proper next-intl parameter syntax: t("key", { param: value })

Error was caused by next-intl expecting translation parameters 
to be passed at the translation function call level, not through 
manual string replacement afterward.

Print preview now loads without FORMATTING_ERROR and displays 
localized footer text correctly in both English and Croatian.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-14 22:16:00 +02:00
29e0fe5334 refactor: remove unnecessary print container padding for improved layout 2025-09-14 21:56:56 +02:00
9a02124e18 feat: implement US-4 - complete print optimization with CSS media queries
- Add comprehensive CSS print media queries for A4 paper optimization
- Implement 69.6mm barcode width specification (20% larger than original 58mm)
- Apply B&W print color optimization forcing all elements to black/white
- Add page break handling to prevent table rows from splitting across pages
- Fix table cropping issue by removing excessive width and reducing container padding
- Optimize print layout with zero padding for maximum table space utilization
- Ensure header/button elements hidden from print output with proper CSS

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-14 21:44:04 +02:00
b205a61cf9 feat: implement US-3 - enhance print layout with professional table design
- Add comprehensive i18n support for all print preview content
- Fix next-intl context error by moving translations to server component
- Implement professional 3-column table layout with proper styling
- Add multilingual table headers (EN: #, Bill Information, 2D Barcode | HR: #, Informacije o Računu, 2D Barkod)
- Center-align index column header and optimize barcode sizing
- Hide print button and header from actual print output
- Fix hydration errors with proper date handling
- Enhanced barcode display with proper padding and sizing

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-14 21:16:33 +02:00
493c2f62fa feat: implement US-2 - create print route with barcode data fetching
- 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>
2025-09-14 19:57:13 +02:00
ecea10e805 feat: implement US-1 - add print button to MonthCard with i18n support
- Add PrintButton component with card styling matching AddLocationButton
- Integrate print button next to "Add a new realestate" with centered layout
- Add English/Croatian translations for print tooltips and labels
- Implement click handler to open print preview in new tab
- Create Sprint Playbook for barcode print functionality

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-14 09:08:40 +02:00
e84188baf2 feat: add unauthenticated /share/attachment/[id] route for shared bill attachments
- Add /share/attachment/.* to public pages in middleware.ts
- Create new /share/attachment/[id] route handler for downloading attachments without authentication
- Add custom 404 page for missing shared attachments
- Update ViewBillCard component to use shared attachment route instead of authenticated route

This enables attachment downloads from shared bill pages without requiring user login.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-09-08 13:57:53 +02:00
6c7a315966 fix: prevent empty file from overwriting existing bill attachments
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>
2025-08-29 22:32:07 +02:00
8b845261d2 fix: prevent empty file from overwriting existing bill attachments
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>
2025-08-29 22:12:23 +02:00
daa9b2a134 locationAction: query optimization 2025-08-11 13:58:57 +02:00
fade52a49f billActions: projection optimization 2025-08-11 13:57:36 +02:00
aab0afd045 locationAction: fixed optional form fields 2025-08-11 13:57:07 +02:00
21da2f0d49 optimization: projecting only what's needed 2025-08-11 13:38:59 +02:00
d42a7da75b fixed typescript error 2025-08-11 12:49:10 +02:00
44cdcf8cec optimized queries 2025-08-11 12:19:29 +02:00
3ce158825e add bulk bill deletion across subsequent months
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>
2025-08-11 12:11:10 +02:00
71895229ec add bulk bill creation across subsequent months
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>
2025-08-11 12:01:18 +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
80e30deace add conditional warning for destructive delete operation
- Added React state to track toggle status and show warning only when enabled
- Implemented modern custom border warning style with left red border and subtle background
- Added responsive width constraints (max-w-[24rem]) and word wrapping for proper layout
- Warning includes ⚠️ emoji and clear messaging about irreversible operation
- Fixed JSON syntax errors in translation files (replaced HTML entities with escaped quotes)
- Enhanced translations: "Also delete" phrasing and detailed warning messages
- Warning appears dynamically when bulk deletion option is activated

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-11 11:24:09 +02:00
131dfe793b improve LocationDeleteForm toggle layout
- Center the delete toggle horizontally within the form using justify-center
- Add consistent spacing between label and toggle input with gap-4
- Improves visual balance and readability of the delete confirmation form

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-11 11:05:37 +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
2cf338c50a improve development authentication setup
- Replaced manual code commenting with environment variable controlled mock auth
- Added development env vars to VS Code launch.json for automatic mock authentication
- Removed unused LinkedIn provider import
- Authentication now automatically uses mock session when launched via VS Code debug
- Zero security impact on production (env vars only exist during debug sessions)

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-11 10:47:55 +02:00