FocusFlow’s formatting utilities (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/piratta/gymApp/llms.txt
Use this file to discover all available pages before exploring further.
src/utils/formatters.ts and src/utils/exporters.ts) provide consistent, locale-aware display formatting across every surface of the application — workout timers, athlete progress charts, routine printouts, and coach dashboards all consume these same helpers to ensure a uniform visual language. All formatter functions are pure (no side effects) and safe to call with invalid or nullish input.
formatTime
"MM:SS" string. Used by the live workout session timer and the in-session rest countdown.
Total elapsed or remaining seconds. Must be a non-negative finite number. Values less than 0 or
NaN return "00:00".string in "MM:SS" format. There is no hour component — durations longer than 59:59 continue incrementing the minute portion (e.g. a 90-minute session displays as "90:00").
| Input | Output |
|---|---|
0 | "00:00" |
9 | "00:09" |
90 | "01:30" |
3661 | "61:01" |
-5 | "00:00" |
NaN | "00:00" |
formatDate
es-ES) via Intl.DateTimeFormat. Accepts multiple input types so callers never need to construct a Date object manually.
The date to format. Accepts a
Date object, an ISO 8601 string (e.g. "2024-03-15"), or a Unix timestamp in milliseconds.Optional
Intl.DateTimeFormatOptions overrides. Defaults to { day: "numeric", month: "numeric", year: "numeric" } when omitted.- An empty string (
"") for falsy input (e.g.null,undefined,0,""). - The result of
String(date)when the input cannot be parsed as a valid date.
| Input | Output (es-ES default) |
|---|---|
"2024-03-15" | "15/3/2024" |
new Date("2025-01-01") | "1/1/2025" |
1710460800000 | "15/3/2024" |
"" | "" |
formatWeight
" kg" to a weight value and handles all edge cases that appear in athlete profiles and workout logs where weight may be missing or zero.
Weight in kilograms. Accepts a number, a numeric string (parsed with
parseFloat), or any nullish / empty value."<value> kg" for valid positive numbers, or "-" for any of the following:
undefinednull- Empty string
"" 0or any non-positive numberNaN(including non-numeric strings)
| Input | Output |
|---|---|
75.5 | "75.5 kg" |
"82" | "82 kg" |
0 | "-" |
null | "-" |
undefined | "-" |
"" | "-" |
"abc" | "-" |
formatRestSeconds
Rest duration in seconds. Non-positive values and nullish inputs return
"-"."-" when input is undefined, null, 0, or negative.
| Input | Output |
|---|---|
30 | "30 seg" |
45 | "45 seg" |
60 | "1 min" |
90 | "1 min 30 seg" |
120 | "2 min" |
150 | "2 min 30 seg" |
0 | "-" |
null | "-" |
undefined | "-" |
generateTemplateHTML
src/utils/exporters.ts and shared by both the ExercisesTab (template preview) and the coach dashboard (routine export).
The workout template or routine object to render.
Coach’s full name. Shown in the header card and the footer attribution line.
Coach’s email address. Shown alongside the name in the header card.
Optional date string displayed in the header. Defaults to
new Date().toLocaleDateString("es-ES") (today’s date in Spanish locale) if omitted.string containing a complete <!DOCTYPE html> document. The caller is responsible for opening it in a new tab:
| Column | Source field | Notes |
|---|---|---|
| EJERCICIO | ex.name | Numbered (1, 2, 3…) |
| CATEGORÍA | ex.category | e.g. “Pecho”, “Piernas” |
| SERIES | ex.setsCount | Bold teal highlight |
| REPS | ex.repsText / ex.sets[].targetReps | Per-set reps shown when ex.customized === true |
| CARGA | ex.expectedWeight | Appends ” kg”; shows ”-” if absent |
| RPE/INT | ex.intensity | Shows “Personalizado” for customised exercises |
| INDICACIONES / NOTAS | ex.notes | Italic; shows ”-” if absent |
The generated HTML includes an inline
<script> that calls window.print() automatically 300 ms after the page loads, so the print dialog opens immediately when the tab is opened. A “🖨️ Imprimir / Guardar PDF” button is also rendered for manual re-trigger.