| {{ stepNumber }} |
{{ step.title }} |
{{ step.estimation }} minutes |
diff --git a/src/modules/record/components/TaskRecord.vue b/src/modules/record/components/TaskRecord.vue
index 2278232..5416a78 100644
--- a/src/modules/record/components/TaskRecord.vue
+++ b/src/modules/record/components/TaskRecord.vue
@@ -26,7 +26,8 @@ const getNextStepId = () => {
}
if (!recordStore.currentStepId) {
- return task.value.steps[0].id
+ const [firstStep] = task.value.steps
+ return firstStep.id
}
const currentStepIndex = task.value.steps.findIndex(
@@ -73,7 +74,12 @@ const nextStep = () => {
Task: {{ task.title }}
start time: {{ formatDate(record.start) }}
-
+
diff --git a/src/modules/record/models/task-record.ts b/src/modules/record/models/task-record.ts
index 3b34466..e793708 100644
--- a/src/modules/record/models/task-record.ts
+++ b/src/modules/record/models/task-record.ts
@@ -1,3 +1,4 @@
+import { formatDiffInMinutes } from '@/shared/format-date'
import { toISODate, type ISODate } from '@/shared/types/date'
import type { Recordable } from '../interfaces/recordable'
import type { StepRecordable } from '../interfaces/step-recordable'
@@ -17,10 +18,7 @@ export class TaskRecord implements Recordable {
return null
}
- const durationMilliseconds =
- new Date(this.end).getTime() - new Date(this.start).getTime()
-
- return Math.round(durationMilliseconds / (1000 * 60))
+ return formatDiffInMinutes(this.start, this.end)
}
public get hasStepRecords() {
diff --git a/src/shared/format-date.ts b/src/shared/format-date.ts
index 2d180f8..fe05a6e 100644
--- a/src/shared/format-date.ts
+++ b/src/shared/format-date.ts
@@ -1,2 +1,9 @@
+import type { ISODate } from './types/date'
+
export const formatDate = (date: Date | string) =>
new Date(date).toLocaleString()
+
+export const formatDiffInMinutes = (date1: ISODate, date2: ISODate) => {
+ const diffInMs = new Date(date2).getTime() - new Date(date1).getTime()
+ return Math.max(0, Math.round(diffInMs / 1000))
+}