Skip to content

Shared Helpers

The @life-manager/shared/helper package contains feature-grouped business logic used by both platforms. Import via @life-manager/shared/helper or @life-manager/shared/helper/<domain>/<file>.

Full CRUD operations for the hierarchical project/folder tree structure.

  • addFolder, renameFolder, deleteFolder — folder management with parent validation
  • moveProject, moveFolder — drag-and-drop reordering support
  • buildTree — convert flat lists to nested tree structure
  • getFolderPath, getDescendants — tree traversal utilities

Work-related calculations and formatting utilities.

  • secondsToTimerFormat — convert seconds to HH:MM:SS display
  • getRoundedSeconds — apply rounding rules (up/down/nearest) to time values
  • calculateEarnings — compute earnings from duration and hourly salary
  • formatDuration — human-readable duration strings

Time entry grouping, aggregation, and formatting.

  • Group time entries by day, week, or project
  • Calculate total durations and earnings per group
  • Sort and filter entries by date ranges

Timer session calculations used by the timer engine.

  • calculateSessionTimeValues — compute elapsed time, remaining time, and progress for active timer sessions

Detects and resolves overlapping time entries.

  • Identify entries that overlap in time ranges
  • Split or trim entries to resolve conflicts
  • Used when submitting new timer results or editing entries manually

Computes time fragment sessions for partial-day calculations and calendar views.

Finance calculation and formatting utilities.

  • Anchor-day logic for recurring cashflows (handles month-end edge cases like Feb 28/29)
  • Currency formatting helpers
  • Cashflow categorization (income vs. expense)

Processes recurring cashflow definitions into concrete single cashflow instances.

  • Evaluate which recurring cashflows are due based on current date
  • Generate pending single cashflow records from recurring definitions
  • Handle interval types (daily, weekly, monthly, yearly)
  • Called automatically at app startup via useProcessRecurringCashflows

Computes aggregated values for finance projects.

  • Sum up all associated cashflows (single + recurring)
  • Apply project adjustments
  • Calculate current balance, total income, total expenses

Pomodoro technique phase management and state reconstruction.

  • getPhaseDuration — return duration for current phase (work/short break/long break)
  • shouldPauseForTransition — determine if timer should auto-pause between phases
  • shouldStopForLongBreak — determine if cycle is complete
  • reconstructPomodoroState — rebuild phase state from persisted timer data (for app restart recovery)
  • Phase cycle counting and progression logic

Visual styling constants for pomodoro phases — colors, icons, and border styles per phase type.

Utilities for appointment-timer integration.

  • getProjectRoundingSettings — extract rounding config from a project for timer use
  • Validate appointment time ranges
  • Convert between appointment and timer data formats

Default values and validation helpers for the appointment creation/edit form.