Location
app.js:7-12
Problem
const CATEGORY_LABELS = {
1: 'Daily',
2: 'Error',
3: 'TDD',
4: 'Will to go on',
};
Category names are duplicated between the frontend and the database. If a category is added, renamed, or reordered in the DB, the frontend map silently diverges. New categories will fall through to affirmation.category || id || '—' as a fallback, which shows raw IDs to users.
Suggested fix
The app already calls GET /api/v1/categories to check auth. Extend the window.load handler to fetch categories and build the label map dynamically:
const categoriesResult = await fetchCategories(); // add this helper to fetch-utils.js
const CATEGORY_LABELS = Object.fromEntries(
(categoriesResult.ok ? categoriesResult.data : []).map(c => [c.id, c.type])
);
This eliminates the manual sync requirement.
Location
app.js:7-12Problem
Category names are duplicated between the frontend and the database. If a category is added, renamed, or reordered in the DB, the frontend map silently diverges. New categories will fall through to
affirmation.category || id || '—'as a fallback, which shows raw IDs to users.Suggested fix
The app already calls
GET /api/v1/categoriesto check auth. Extend thewindow.loadhandler to fetch categories and build the label map dynamically:This eliminates the manual sync requirement.