Skip to content

Commit 3144098

Browse files
committed
refactor(activity): format due date change summaries as date-only
1 parent 8c368bc commit 3144098

2 files changed

Lines changed: 37 additions & 1 deletion

File tree

src/app/features/dashboard/presenters/dashboard-activity.presenter.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,4 +53,22 @@ describe('dashboard-activity.presenter', () => {
5353
expect(event.iconColor).toBe('text-red-500');
5454
expect(event.bgColor).toBe('bg-red-100');
5555
});
56+
57+
it('formats due date change values into readable date strings', () => {
58+
const event = mapActivityToRecentActivity({
59+
id: '4',
60+
type: ActivityType.TaskDueDateChanged,
61+
taskTitle: 'Prepare release notes',
62+
actorUserId: 'user-1',
63+
actorDisplayName: 'Demo Admin',
64+
oldValue: '2026-02-24T23:00:00.0000000',
65+
newValue: '2026-02-24T22:00:00.0000000Z',
66+
occurredAt: '2026-02-20T09:00:00.000Z'
67+
});
68+
69+
expect(event.summary).not.toContain('T23:00:00.0000000');
70+
expect(event.summary).not.toContain('T22:00:00.0000000Z');
71+
expect(event.summary).toContain('changed due date from');
72+
expect(event.summary).toContain('to');
73+
});
5674
});

src/app/features/dashboard/presenters/dashboard-activity.presenter.ts

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ function createActivitySummary(activity: ActivityLogDto): string {
4848
case ActivityType.TaskAssigneeChanged:
4949
return `<strong>${actor}</strong> reassigned task from <i>${escapeText(activity.oldValue ?? 'Unassigned')}</i> to <i>${escapeText(activity.newValue ?? 'Unassigned')}</i>`;
5050
case ActivityType.TaskDueDateChanged:
51-
return `<strong>${actor}</strong> changed due date from <i>${escapeText(activity.oldValue ?? 'None')}</i> to <i>${escapeText(activity.newValue ?? 'None')}</i>`;
51+
return `<strong>${actor}</strong> changed due date from <i>${escapeText(formatActivityDateValue(activity.oldValue))}</i> to <i>${escapeText(formatActivityDateValue(activity.newValue))}</i>`;
5252
default:
5353
return `<strong>${actor}</strong> performed an update`;
5454
}
@@ -145,6 +145,24 @@ function formatTaskStatus(status?: TaskStatus | null): string {
145145
}
146146
}
147147

148+
function formatActivityDateValue(value?: string | null): string {
149+
if (!value || value.trim().length === 0) {
150+
return 'None';
151+
}
152+
153+
const trimmed = value.trim();
154+
const parsedDate = new Date(trimmed);
155+
if (Number.isNaN(parsedDate.getTime())) {
156+
return trimmed;
157+
}
158+
159+
return new Intl.DateTimeFormat(undefined, {
160+
month: 'short',
161+
day: 'numeric',
162+
year: 'numeric'
163+
}).format(parsedDate);
164+
}
165+
148166
function escapeText(value: string): string {
149167
return value
150168
.replace(/&/g, '&amp;')

0 commit comments

Comments
 (0)