Skip to content

Commit 566f6ed

Browse files
RJK134claudecursoragentCopilotCopilot
authored
refactor(tasks): extract taskTypeLabel utility and deduplicate triage/dashboard mappings (#85)
* fix(dashboard): translate task.taskType in Triage Tasks panel The dashboard's "Triage Tasks" panel was rendering raw enum values (URGENT_REVIEW, CLARIFY_SYMPTOMS, ASK_FOR_POSTCODE, ASK_HORSE_COUNT, MANUAL_CLASSIFICATION) where the triage page itself maps them through i18n via taskTypeLabel + t(). Mirrors the pattern at app/[locale]/triage/page.tsx:184–193 and 321: - Adds useTranslations('triage') as tTriage. - Adds the same taskTypeLabel(taskType) mapping. - Replaces {task.taskType} with {tTriage(taskTypeLabel(task.taskType))}. All five enum values are already keyed in messages/{en,fr}.json under the triage namespace (urgentReview, askPostcode, askHorseCount, clarifySymptoms, manualClassification). Fallback returns the raw value if the map ever drifts out of sync. Closes Finding 7 of docs/UAT_v1_1_TRIAGE_round2.md. https://claude.ai/code/session_01PF4MU4P4Ytt9UcuVsbAzT5 * refactor: extract taskTypeLabel into shared utility Both dashboard and triage pages had an identical taskTypeLabel mapping copy-pasted between them. Move it to lib/utils/task-type-label.ts so future enum or translation key changes only need to be made in one place. * Update lib/utils/task-type-label.ts Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * fix(task-type-label): return null for unknown types and add unit tests Agent-Logs-Url: https://github.com/RJK134/EquiSmile/sessions/9ea8e98d-e479-4ece-9130-11de6f3585a3 Co-authored-by: RJK134 <167345619+RJK134@users.noreply.github.com> * refactor(task-type-label): avoid double lookup in map callbacks Agent-Logs-Url: https://github.com/RJK134/EquiSmile/sessions/9ea8e98d-e479-4ece-9130-11de6f3585a3 Co-authored-by: RJK134 <167345619+RJK134@users.noreply.github.com> --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: Cursor Agent <cursoragent@cursor.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com>
1 parent 4e08c8e commit 566f6ed

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
import { describe, it, expect } from 'vitest';
2+
import { taskTypeLabel, TRIAGE_TASK_TYPE_LABEL_MAP } from '@/lib/utils/triage-task-type';
3+
4+
describe('TRIAGE_TASK_TYPE_LABEL_MAP', () => {
5+
it('covers all expected task types', () => {
6+
expect(Object.keys(TRIAGE_TASK_TYPE_LABEL_MAP)).toEqual(
7+
expect.arrayContaining([
8+
'URGENT_REVIEW',
9+
'ASK_FOR_POSTCODE',
10+
'ASK_HORSE_COUNT',
11+
'CLARIFY_SYMPTOMS',
12+
'MANUAL_CLASSIFICATION',
13+
])
14+
);
15+
});
16+
});
17+
18+
describe('taskTypeLabel', () => {
19+
it('maps URGENT_REVIEW to urgentReview', () => {
20+
expect(taskTypeLabel('URGENT_REVIEW')).toBe('urgentReview');
21+
});
22+
23+
it('maps ASK_FOR_POSTCODE to askPostcode', () => {
24+
expect(taskTypeLabel('ASK_FOR_POSTCODE')).toBe('askPostcode');
25+
});
26+
27+
it('maps ASK_HORSE_COUNT to askHorseCount', () => {
28+
expect(taskTypeLabel('ASK_HORSE_COUNT')).toBe('askHorseCount');
29+
});
30+
31+
it('maps CLARIFY_SYMPTOMS to clarifySymptoms', () => {
32+
expect(taskTypeLabel('CLARIFY_SYMPTOMS')).toBe('clarifySymptoms');
33+
});
34+
35+
it('maps MANUAL_CLASSIFICATION to manualClassification', () => {
36+
expect(taskTypeLabel('MANUAL_CLASSIFICATION')).toBe('manualClassification');
37+
});
38+
39+
it('returns the raw enum value for an unknown task type', () => {
40+
expect(taskTypeLabel('UNKNOWN_FUTURE_TYPE')).toBe('UNKNOWN_FUTURE_TYPE');
41+
});
42+
43+
it('returns an empty string for an empty string input', () => {
44+
expect(taskTypeLabel('')).toBe('');
45+
});
46+
});

0 commit comments

Comments
 (0)