Repository: directus/directus
File: app/src/composables/use-revisions.ts (TypeScript)

Code before:
				(revision) => {
					// revision's timestamp date is in iso-8601
					const date = new Date(new Date(revision.activity.timestamp).toDateString());
					return date;
				},
			);

			const revisionsGrouped: RevisionsByDate[] = [];

			for (const [key, value] of Object.entries(revisionsGroupedByDate)) {
				const date = new Date(key);
				const today = isToday(date);
				const yesterday = isYesterday(date);
				const thisYear = isThisYear(date);

				let dateFormatted: string;

				if (today) dateFormatted = t('today');
				else if (yesterday) dateFormatted = t('yesterday');
				else if (thisYear) dateFormatted = localizedFormat(date, String(t('date-fns_date_short_no_year')));
				else dateFormatted = localizedFormat(date, String(t('date-fns_date_short')));

				const revisions: RevisionWithTime[] = [];

				for (const revision of value) {
					const steps = revision?.data?.steps;
					const lastStepStatus = steps[steps.length - 1]?.status;

					revisions.push({
						...revision,
						timestampFormatted: `${localizedFormat(
							new Date(revision.activity?.timestamp),
							String(t('date-fns_date_short')),
						)} (${localizedFormat(new Date(revision.activity?.timestamp), String(t('date-fns_time')))})`,
						timeRelative: `${format(
							new Date(revision.activity?.timestamp),
							String(t('date-fns_time')),
						)} (${localizedFormatDistance(parseISO(revision.activity?.timestamp), new Date(), {
							addSuffix: true,
						})})`,
						status: lastStepStatus,
					});
				}

				revisionsGrouped.push({
					date: date,
					dateFormatted: String(dateFormatted),
					revisions,
				});
			}


Review comment (suggestion):

```suggestion
					const steps = (revision as Revision)?.data?.steps;
```

Code after:
				(revision) => {
					// revision's timestamp date is in iso-8601
					const date = new Date(new Date(revision.activity.timestamp).toDateString());
					return date;
				},
			);

			const revisionsGrouped: RevisionsByDate[] = [];

			for (const [key, value] of Object.entries(revisionsGroupedByDate)) {
				const date = new Date(key);
				const today = isToday(date);
				const yesterday = isYesterday(date);
				const thisYear = isThisYear(date);

				let dateFormatted: string;

				if (today) dateFormatted = t('today');
				else if (yesterday) dateFormatted = t('yesterday');
				else if (thisYear) dateFormatted = localizedFormat(date, String(t('date-fns_date_short_no_year')));
				else dateFormatted = localizedFormat(date, String(t('date-fns_date_short')));

				const revisions: RevisionWithTime[] = [];

				for (const revision of value) {
					const steps = (revision as Revision)?.data?.steps;
					const lastStepStatus = steps?.[steps.length - 1]?.status;

					revisions.push({
						...revision,
						timestampFormatted: `${localizedFormat(
							new Date(revision.activity?.timestamp),
							String(t('date-fns_date_short')),
						)} (${localizedFormat(new Date(revision.activity?.timestamp), String(t('date-fns_time')))})`,
						timeRelative: `${format(
							new Date(revision.activity?.timestamp),
							String(t('date-fns_time')),
						)} (${localizedFormatDistance(parseISO(revision.activity?.timestamp), new Date(), {
							addSuffix: true,
						})})`,
						status: lastStepStatus,
					});
				}

				revisionsGrouped.push({
					date: date,
					dateFormatted: String(dateFormatted),
					revisions,
				});
			}