- lib/domain/checkin.ts: add streakMessage() — milestone thresholds (30/14/7/3/2
days) are domain decisions, not UI copy; page now imports instead of defining
- lib/utils/format.ts: add relativeDate() — was duplicated in admin/patients page;
formatting utilities belong here alongside other date helpers
- lib/domain/signals.ts: add sparkLevel() — wellness categorisation using
SPARKLINE thresholds belongs in signals domain next to wellnessAvg()
- admin/patients page: remove all three local function defs, clean unused imports
- admin/reports page: replace magic -7 with SIGNAL_CHECKIN_WINDOW_DAYS
No behaviour change — same logic, now in testable, single-homed modules.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
- lib/config/auth.ts: add PASSWORD_RESET_TOKEN_MAX_LENGTH and
RESET_TOKEN_IDENTIFIER_PREFIX ("reset:") so the token schema cap and
identifier prefix have a single source of truth
- auth routes: import and use both new constants (4 occurrences of
hardcoded "reset:" prefix replaced)
- lib/utils/validate.ts: export UUID_RE so routes don't each define their
own copy of the same regex
- documents routes (GET + upload): import UUID_RE instead of local re-def
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
The pattern `name ?? email.split("@")[0]` appeared in 5 cron routes
with slight variations (optional chaining, different fallbacks). Extracted
to lib/utils/format.ts displayName(name, email, fallback="there") and
replaced all occurrences.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
lib/email/templates.ts: 4 remaining hardcoded "VitaReBa" text strings in
email body copy (password-reset, welcome, weekly-digest, checkin-reminder)
now use COMPANY.shortName. Every non-HTML-design brand reference now derives
from lib/config/company.ts.
lib/utils/format.test.ts: 19 tests covering all 6 exported date utilities
(formatDateShort, formatDateLong, formatDateNumeric, formatDateTime,
formatDateMonthDay, formatDateISO) plus HOUR_MS and DAY_MS constants.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Add formatDateMonthDay() to lib/utils/format.ts for compact chart axis labels
("2 Apr"). Replace inline toLocaleDateString in assessments page, checkin page,
admin patient detail page, and admin documents page with the shared utility.
Also fix remaining USER_ROLE string literals in portal/admin layouts and
message thread pages.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>