Refactor frontend date formatting helpers and mark Task 10 done
This commit is contained in:
@@ -204,7 +204,7 @@ Reference: `Docs/Refactoring.md` for full analysis of each issue.
|
||||
|
||||
---
|
||||
|
||||
### Task 10 — Consolidate duplicated formatting functions (frontend)
|
||||
### Task 10 — Consolidate duplicated formatting functions (frontend) (✅ completed)
|
||||
|
||||
**Priority**: Low
|
||||
**Refactoring ref**: Refactoring.md §7
|
||||
@@ -214,10 +214,11 @@ Reference: `Docs/Refactoring.md` for full analysis of each issue.
|
||||
- `frontend/src/pages/JailDetailPage.tsx` (has `fmtSeconds()` ~L152)
|
||||
- `frontend/src/pages/JailsPage.tsx` (has `fmtSeconds()` ~L147)
|
||||
|
||||
**What to do**:
|
||||
1. Create `frontend/src/utils/formatDate.ts`.
|
||||
2. Define three exported functions:
|
||||
- `formatTimestamp(ts: string): string` — consolidation of `formatTimestamp` and `fmtTime`
|
||||
**What was done**:
|
||||
1. Added shared helper `frontend/src/utils/formatDate.ts` with `formatTimestamp()` + `formatSeconds()`.
|
||||
2. Replaced local `formatTimestamp` and `fmtTime` in component/page files with shared helper imports.
|
||||
3. Ensured no local formatting helpers are left in the target files.
|
||||
4. Ran frontend tests (`cd frontend && npx vitest run --run`): all tests passed.
|
||||
- `formatSeconds(seconds: number): string` — consolidation of the two identical `fmtSeconds` functions
|
||||
3. In each of the four affected files, remove the local function definition and replace it with an import from `src/utils/formatDate.ts`. Adjust call sites if the function name changed.
|
||||
4. Run existing frontend tests: `cd frontend && npx vitest run` — all tests must pass.
|
||||
|
||||
Reference in New Issue
Block a user