Skip to content

Shared Hooks

The @life-manager/shared/hooks package exports six hooks used by both web and mobile apps. Import via @life-manager/shared/hooks or @life-manager/shared/hooks/<name>.

The core timer engine powering both platforms. Manages the full lifecycle of multiple concurrent timers.

Responsibilities:

  • Real-time countdown/countup display with 1-second tick intervals
  • Pomodoro phase management (work → short break → long break transitions)
  • Timer rounding based on per-project TimerRoundingSettings
  • Earnings calculation from active timer duration and project salary
  • Start, stop, pause, and submit timers into persisted WorkTimeEntry records
  • Appointment-linked timer support

Key inputs: Timer collection data, project data, settings, and platform-specific callbacks for mutations.

Key outputs: Enriched timer state objects with computed display values (formatted time, earnings, phase info).

Aggregates work and finance data into period-based dashboard statistics.

Responsibilities:

  • Compute today/this-week/this-month work durations and earnings
  • Multi-currency finance aggregation (income, expense, net) per period
  • Format all values using the user’s locale via useIntl

Data sources: useWorkTimeEntries, useSingleCashflows, useBankAccounts from @life-manager/db/queries.

Builds a hierarchical tree structure from flat project and folder data.

Responsibilities:

  • Convert flat project/folder lists into a nested ProjectTreeItem[] structure
  • Handle parent-child relationships for folders and project assignment
  • Provide the tree data used by react-arborist (web) and flat lists (mobile)

Generic multi-select state management for lists and tables.

Responsibilities:

  • Track selected item IDs
  • Toggle individual items, select all, clear selection
  • Range selection support (shift-click)
  • Expose selectedIds set and selection count

Used in work time entry tables, cashflow lists, and other multi-select contexts.

Background process that manages appointment status transitions.

Responsibilities:

  • Poll appointments and transition statuses based on current time (e.g., upcoming → active → past)
  • Run as a background effect in the app shell

Internationalization wrapper providing locale-aware formatting. Also exports intlUtils for use outside React components.

Responsibilities:

  • formatMoney(amount, currency) — locale-aware currency formatting
  • formatDate(date, format?) — locale-aware date formatting
  • formatDuration(seconds) — human-readable duration strings
  • getLocalizedText(de, en) — return the correct string based on user locale
  • Reads locale from user settings via @life-manager/db/queries