Commit Graph

147 Commits

Author SHA1 Message Date
686bec6c10 feat: add Revolut payment link support alongside IBAN
- Add NoteBox component for displaying warning messages with icon
- Add Revolut profile name field to user settings schema
- Update UserSettingsForm to support payment instruction selection (disabled/IBAN/Revolut)
- Add Croatian and English translations for new payment options
- Reserve fields for future per-instruction enable/disable functionality

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-24 13:37:54 +01:00
Knee Cola
fcecaaa901 (refactor) dbTypes: added utilBillsProofOfPaymentUploadedAt to BillingLocation 2025-11-23 22:13:09 +01:00
Knee Cola
7a01dad5e7 (refactor) locationActions: add timestamp for utility bills proof of payment upload 2025-11-23 21:58:04 +01:00
Knee Cola
3389bce755 (refactor) locationActions: preventing multiple proof of payment uploads 2025-11-23 21:56:18 +01:00
Knee Cola
fb3393c985 (bugfix) decoding hub3a from image did not work 2025-11-23 12:53:35 +01:00
Knee Cola
1995ad9de9 optimizing DB projections 2025-11-23 11:59:06 +01:00
Knee Cola
9d53fb1753 chore: Upgrade pdfjs-dist from 4.0.379 to 4.10.38
Updated PDF.js library to version 4.10.38 for improved PDF rendering
and barcode scanning capabilities.

Changes:
- package.json: Updated pdfjs-dist dependency to ^4.10.38
- package-lock.json: Updated dependency tree
- public/pdf.worker.min.mjs: Updated PDF.js worker file
- app/lib/pdf/barcodeDecoder.ts: Removed unused import

This is a minor version update within v4, maintaining API compatibility
while receiving bug fixes and improvements.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 10:48:51 +01:00
Knee Cola
7a5c503ce9 Refactor: Complete barcodeImage removal and hub3aText migration
This commit completes the migration from storing bitmap barcodes to using
decoded HUB-3A text strings, removing all legacy code while maintaining
backward compatibility during the transition period.

Database & Server Actions:
- billActions: Removed commented legacy barcodeImage code
- locationActions: Updated field references in projections
- monthActions: Use hub3aText when copying bills to new months
- printActions: Support both hub3aText and barcodeImage during migration
  - Added @deprecated annotation to barcodeImage field
  - Filter includes bills with either field
  - Pass both fields to support gradual migration

Barcode Decoder:
- Removed barcodeImage field from DecodeResult type
- Deleted copyBarcodeImage() function (58 lines)
  - No longer generating bitmaps during decode
  - Barcodes now generated on-demand from hub3aText
- Cleaner separation: decoder extracts text, component renders barcode

UI Components:
- Pdf417Barcode: Added optional className prop for styling flexibility
  - Removed unnecessary wrapper div
  - Conditional styling (use className or default dimensions)
- PrintPreview: Use Pdf417Barcode component with fallback to legacy barcodeImage
- ViewBillCard: Major cleanup and migration support
  - Removed unused imports (React, updateOrAddBill, useLocale)
  - Removed unused middleware function
  - Removed unused variables and hidden input
  - Prefer hub3aText with Pdf417Barcode, fallback to barcodeImage
  - Clear legacy support comments

Migration Strategy:
All rendering code now follows the pattern:
1. Prefer hub3aText (new field) when available
2. Fallback to barcodeImage (legacy field) if needed
3. Clear comments marking legacy support code
4. Allows gradual migration without breaking existing bills

Benefits:
- More efficient storage (text vs base64 bitmap)
- Barcodes generated on-demand (not stored)
- Cleaner, more maintainable code
- Consistent use of Pdf417Barcode component
- Removed ~60 lines of unused code

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 09:03:53 +01:00
Knee Cola
89c06e2799 Refactor: Complete barcodeImage to hub3aText migration across codebase
Database & Types:
- Added hub3aText field to Bill interface in db-types.ts
- Marked barcodeImage as @deprecated legacy field

Server Actions:
- Updated billActions to read/write hub3aText instead of barcodeImage
- Commented out legacy barcodeImage code with migration notes

Barcode Decoder:
- Renamed image2canvas to file2canvas for clarity
- Added new image2canvas function for base64 encoded images (migration support)
- Added hub3aText to DecodeResult type
- Exported decodeFromImage function for legacy data migration
- Updated decoding logic to extract and return hub3aText

UI Components:
- Refactored Pdf417Barcode to accept hub3aText string instead of PaymentParams
- Removed EncodePayment call from Pdf417Barcode (now expects pre-encoded text)
- Updated ViewLocationCard to encode payment params before passing to Pdf417Barcode

This completes the refactoring from storing bitmap images to storing decoded
HUB-3A payment strings, providing more efficient storage and easier data manipulation.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 08:25:06 +01:00
Knee Cola
6df9557921 Add utility bills proof of payment file upload functionality
Changes:
- Updated BillingLocation interface:
  - Added utilBillsProofOfPaymentAttachment field (BillAttachment type)
- Added server action uploadUtilBillsProofOfPayment:
  - Validates PDF file type
  - Serializes file attachment to base64
  - Stores attachment in BillingLocation document
  - Returns success/error status
- Updated ViewLocationCard component:
  - Added file upload input with PDF-only accept
  - Implemented handleFileChange with immediate upload
  - Added upload state management (isUploading, uploadError, attachment)
  - Shows spinner while uploading
  - Input disabled during upload
  - Conditionally renders file input or download link
  - Link displayed after successful upload
- Created route handler for serving proof of payment PDFs:
  - GET /share/proof-of-payment/[id]/route.tsx
  - Fetches attachment from database
  - Converts base64 to binary
  - Returns PDF with proper headers
- Added not-found page for proof of payment route
- Updated middleware to include proof-of-payment in public pages
- Added translations:
  - en: "Upload proof of payment (PDF only)"
  - hr: "Priložite potvrdu o uplati:"

File uploads immediately on selection without page reload.
Only PDF files accepted with client and server-side validation.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 23:47:08 +01:00
Knee Cola
a2cea49e9f Update formatCurrency to handle optional currencyCode and default to EUR 2025-11-22 23:06:04 +01:00
Knee Cola
c025c6f2ce Update formatCurrency to use currency code from UserSettings
Changes:
- Updated formatCurrency function:
  - Added currencyCode parameter with EUR default
  - Implemented Intl.NumberFormat for proper currency formatting
  - Added fallback for invalid currency codes
- Updated component hierarchy to pass currency:
  - HomePage: Fetch userSettings and pass to MonthLocationList
  - MonthLocationList: Accept and pass currency to child components
  - LocationCard: Accept currency prop and use in formatCurrency
  - MonthCard: Accept currency prop and use in formatCurrency
  - ViewLocationCard: Pass currency from userSettings to formatCurrency
- Removed hardcoded $ symbols, now using proper currency formatting

All currency amounts now display with the user's selected currency code
from their settings, using locale-appropriate formatting (hr-HR).

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 23:04:42 +01:00
Knee Cola
4db56f8383 Rename 'iban' to 'ownerIBAN' in UserSettings
Changes:
- Updated UserSettings interface: iban -> ownerIBAN
- Updated userSettingsActions.ts:
  - Changed State type to use ownerIBAN
  - Updated FormSchema validation to reference ownerIBAN
  - Updated validation refinements to check ownerIBAN
  - Updated form data parsing to read ownerIBAN
  - Renamed normalizedIban to normalizedOwnerIBAN
  - Updated database write operations to use ownerIBAN
- Updated UserSettingsForm.tsx:
  - Changed state tracking to use ownerIBAN
  - Updated validation check to reference ownerIBAN (cleanedOwnerIBAN)
  - Updated input field: id, name, and event handlers
- Updated ViewLocationCard.tsx to use ownerIBAN instead of iban
- Updated English translations:
  - iban-label -> owner-iban-label
  - iban-placeholder -> owner-iban-placeholder
  - iban-required -> owner-iban-required
  - iban-invalid -> owner-iban-invalid
- Updated Croatian translations with corresponding ownerIBAN keys

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 22:43:30 +01:00
Knee Cola
e6adb10689 Rename 'town' to 'ownerTown' in UserSettings with 27 character max length
Changes:
- Updated UserSettings interface: town -> ownerTown
- Updated userSettingsActions.ts:
  - Changed State type to use ownerTown
  - Added max length validation (27 characters) to FormSchema
  - Updated validation refinement to check ownerTown
  - Updated form data parsing to read ownerTown
  - Updated database write operations to use ownerTown
- Updated UserSettingsForm.tsx:
  - Changed state tracking to use ownerTown
  - Updated validation check to reference ownerTown
  - Updated input field: id, name, maxLength={27}
- Updated ViewLocationCard.tsx to use ownerTown instead of town
- Updated English translations:
  - town-label -> owner-town-label: "Your Postal Code and Town"
  - town-placeholder -> owner-town-placeholder
  - town-required -> owner-town-required
- Updated Croatian translations with corresponding ownerTown keys

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 22:40:12 +01:00
Knee Cola
387b7e0256 Rename 'street' to 'ownerStreet' in UserSettings with 25 character max length
Changes:
- Updated UserSettings interface: street -> ownerStreet
- Updated userSettingsActions.ts:
  - Changed State type to use ownerStreet
  - Added max length validation (25 characters) to FormSchema
  - Updated validation refinement to check ownerStreet
  - Updated form data parsing to read ownerStreet
  - Updated database write operations to use ownerStreet
- Updated UserSettingsForm.tsx:
  - Changed state tracking to use ownerStreet
  - Updated validation check to reference ownerStreet
  - Updated input field: id, name, maxLength={25}
- Updated ViewLocationCard.tsx to use ownerStreet instead of street
- Updated English translations:
  - street-label -> owner-street-label: "Your Street and House Number"
  - street-placeholder -> owner-street-placeholder
  - street-required -> owner-street-required
- Updated Croatian translations with corresponding ownerStreet keys

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 22:37:04 +01:00
Knee Cola
db1df76ed6 Rename firstName to ownerName with updated validation
- Renamed firstName to ownerName in UserSettings interface
- Updated UserSettingsForm field to accept full name (first and last)
- Set maximum length to 25 characters for owner name field
- Updated all database operations to use ownerName
- Changed English label from "First Name" to "Your First and Last Name"
- Updated Croatian translations to match (Vaše ime i prezime)
- Updated form validation schema and error messages
- Removed old lastName-related translations
- Updated ViewLocationCard to use ownerName for recipient

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 22:31:07 +01:00
Knee Cola
c1762f7157 Remove lastName field from UserSettings and database
- Removed lastName from UserSettings interface
- Updated UserSettingsForm to remove lastName input field
- Removed lastName from all database operations
- Updated form validation schema to remove lastName validation
- Updated ViewLocationCard to use only firstName for recipient name
- Removed lastName from user settings form state tracking
- Updated Croatian translations to reflect changes

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 22:26:41 +01:00
Knee Cola
b4e459b2d5 Rename tenantFirstName to tenantName with updated validation
- Renamed tenantFirstName to tenantName in BillingLocation interface
- Updated LocationEditForm field to accept full name (first and last)
- Set maximum length to 30 characters for tenant name field
- Updated all database operations to use tenantName
- Changed English label from "Tenant First Name" to "Tenant First and Last Name"
- Updated Croatian translations to match (Ime i prezime podstanara)
- Updated form validation schema and error messages
- Removed old tenantLastName-related translations

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 22:17:10 +01:00
Knee Cola
a1c683528c Remove tenantLastName field from LocationEditForm and database
- Removed tenantLastName from BillingLocation interface
- Updated LocationEditForm to remove tenantLastName input field
- Removed tenantLastName from all database operations (insert and update)
- Updated form validation schema to remove tenantLastName validation
- Updated ViewLocationCard to use only tenantFirstName for payer name
- Removed tenantLastName from tenant field state tracking

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 22:09:13 +01:00
Knee Cola
280e2ec029 Populate paymentParams with actual data from database
- Updated ViewLocationCard to accept userSettings prop
- Replaced all hardcoded payment values with dynamic data:
  * Amount calculated from monthly expenses
  * Payer info from tenant fields (name, street, town)
  * Recipient info from userSettings (name, street, town, IBAN)
  * Reference number and description generated from location data
- Created getUserSettingsByUserId function for fetching owner settings on public pages
- Updated LocationViewPage to fetch and pass userSettings to ViewLocationCard

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 15:47:07 +01:00
Knee Cola
ec39eda51f Add tenantStreet and tenantTown fields to LocationEditForm
- Added tenantStreet and tenantTown optional fields to BillingLocation interface
- Updated LocationEditForm to include new input fields with 27 character max length
- Both fields are mandatory when 2D code generation is enabled
- Updated all database operations (insert and update) to persist new fields
- Added Croatian and English translations for labels and validation messages
- Updated form state tracking to include new tenant address fields

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 15:33:00 +01:00
Knee Cola
3cf880a661 Add town and currency fields to user settings
Adds two new fields to user settings form:
- Town field: Text input for city/town (required when 2D code enabled)
- Currency field: Select dropdown with ISO 4217 currency codes (EUR default)

Updates:
- Database schema: Added town and currency fields to UserSettings
- Validation: Both fields required when 2D code is enabled
- Form UI: Added input fields with proper validation and error handling
- Translations: Added Croatian and English labels and error messages
- Currency options: 36 ISO 4217 codes with EUR at top as default

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 15:14:19 +01:00
Knee Cola
795d9c690b Rename address field to street and change to text input
Changes the user settings address field to street with the following updates:
- Renames database field from 'address' to 'street' in UserSettings type
- Changes form input from textarea to single-line text input
- Updates validation logic and error messages
- Updates translations in both Croatian and English
- Removes deprecated AppSettingsForm component

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 15:00:12 +01:00
Knee Cola
371333802a Add PDF417 barcode rendering component
Implements client-side PDF417 barcode rendering with React component.
Uses useEffect to prevent hydration mismatch by generating barcodes
only after component mount. Integrates barcode display in location cards.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 14:22:57 +01:00
Knee Cola
fe980723c0 Add custom PDF417 barcode generation library
Implements PDF417 2D barcode encoder with bcmath utilities and lookup tables.
Ported from TCPDF library to TypeScript for client-side barcode generation.

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-22 14:22:02 +01:00
Knee Cola
cbd13cbae3 Add seenByTenant tracking feature
- Add seenByTenant field to BillingLocation interface
- Implement setSeenByTenant function to mark locations as viewed by tenant
  - Checks if flag is already set to avoid unnecessary DB updates
  - Includes TypeDoc documentation
- Update LocationViewPage to call setSeenByTenant when non-owner visits
- Add seenByTenant to fetchAllLocations projection
- Update LocationCard to show "seen by tenant" status indicator
  - Displays in "Monthly statement" fieldset with checkmark icon
  - Shows alongside monthly expense total
- Add localization strings for monthly statement and seen status

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 23:51:23 +01:00
Knee Cola
3540ef596b Enforce integer-only values for rent amount field
- Add .int() validation to rentAmount in FormSchema
- Remove decimal formatting (was dividing by 100)
- Change min value from 0 to 1
- Add right text alignment for better numeric display
- Add localization for integer validation error message

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 23:06:42 +01:00
Knee Cola
1c25917093 (fix) redirect home was not correct 2025-11-18 22:59:43 +01:00
Knee Cola
bfa9afdb45 Add rent amount field to location form
- Add rentAmount field to BillingLocation interface (stored in cents)
- Implement Zod validation with conditional requirement when rent notification is enabled
- Add rent amount input field to LocationEditForm with decimal display
- Update all database operations to persist rentAmount
- Add localization strings for both English and Croatian
- Fix missing notes field in insertOne/insertMany operations

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 13:06:29 +01:00
Knee Cola
be5d5074fe Refactor: renamed AccountForm to UserSettingsForm and update related actions and translations 2025-11-18 12:52:43 +01:00
Knee Cola
b03f0574cd Refactor: rename account-form to settings-form and update translations 2025-11-18 12:33:24 +01:00
Knee Cola
9e3d49c74f Refactor AccountForm with 2D code toggle and conditional validation
- Refactor AccountForm to use toggle for showing/hiding profile fields
- Add show2dCodeInMonthlyStatement field to UserProfile database schema
- Implement conditional validation: all fields mandatory when 2D code is enabled
- Update FormSchema with .refine() methods for firstName, lastName, address, and IBAN
- IBAN validation includes both presence check and format validation when required
- Add validation error messages to English and Croatian localization files
- Initialize toggle state from persisted database value
- Form fields conditionally displayed based on toggle state

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 12:24:11 +01:00
Knee Cola
92b2b74b66 (refactor): locationNotes removed 2025-11-18 11:55:42 +01:00
Knee Cola
63096be133 Add automatic rent notification feature to LocationEditForm
- Add rentDueNotification toggle to enable automatic rent notifications
- Add rentDueDay selector (1-28) for specifying when rent is due
- Extract tenant email to independent section shown when either autoBillFwd or rentDueNotification is enabled
- Update email validation to be mandatory when any automatic notification is active
- Update database schema to persist rentDueNotification and rentDueDay fields
- Add all database operations to handle new fields with proper defaults
- Add localization strings for English and Croatian

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 11:29:57 +01:00
Knee Cola
f4e82b7314 Implement bill forwarding strategy with radio button persistence
Added billFwdStrategy field to store user's choice for when to forward
utility bills to tenants, with database persistence and UI updates.

Changes:
- Added billFwdStrategy field to BillingLocation interface ("when-payed" | "when-attached")
- Updated FormSchema to validate billFwdStrategy enum values
- Modified updateOrAddLocation to persist billFwdStrategy in all database operations
- Defaults to "when-payed" (first option) when no value exists in database
- Updated LocationEditForm radio buttons to use persisted database values
- Radio button selection is preserved across edits and restored from database
- Renamed autoTenantNotification to autoBillFwd throughout codebase
- Updated localization strings for bill forwarding features

Form behavior:
- New locations: "when-payed" radio selected by default
- Existing locations: Radio selection matches stored database value
- Value persisted in current, subsequent, and all month update operations

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-18 10:10:18 +01:00
Knee Cola
c5fe184f9c Rename autoTenantNotification to autoBillFwd and update related references in forms and translations 2025-11-18 09:38:04 +01:00
Knee Cola
67706c575d Add email validation to tenant email field
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>
2025-11-18 09:31:24 +01:00
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
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
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
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
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
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
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