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>.
useTimeTrackerEngine (666 LOC)
Section titled “useTimeTrackerEngine (666 LOC)”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
WorkTimeEntryrecords - 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).
useDashboardStats (224 LOC)
Section titled “useDashboardStats (224 LOC)”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.
useWorkTree (96 LOC)
Section titled “useWorkTree (96 LOC)”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)
useSelectionManager (90 LOC)
Section titled “useSelectionManager (90 LOC)”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
selectedIdsset and selection count
Used in work time entry tables, cashflow lists, and other multi-select contexts.
useAppointmentStatusManager (73 LOC)
Section titled “useAppointmentStatusManager (73 LOC)”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
useIntl (83 LOC)
Section titled “useIntl (83 LOC)”Internationalization wrapper providing locale-aware formatting. Also exports intlUtils for use outside React components.
Responsibilities:
formatMoney(amount, currency)— locale-aware currency formattingformatDate(date, format?)— locale-aware date formattingformatDuration(seconds)— human-readable duration stringsgetLocalizedText(de, en)— return the correct string based on user locale- Reads locale from user settings via
@life-manager/db/queries